Description

u8_set_device_name() allows you to set a descriptive set of 6 characters representing the ‘name’ of the device. This short name appears for example in the diceConfig and the CAN2SER monitor.

Syntax

u8_set_device_name( os_new_device_name );

Parameters

String os_new_device_name: String that represents the new device name. Only the first 6 characters of the string will be used.

Returns

uint8_t return value meaning:
0 – setting changed (accepted).

Example Code

This example shows how to read, set and store the ‘device name’ of the bootloader settings.

void setup()
{  
  Serial.begin();
  while (!Serial) 
  {
    yield(); // wait for PC CAN2SER-monitor to open 
  }
  String s_device_name = BOOTLOADER_SETTING.s_get_device_name();
  
  Serial.println("Current bootloader settings:");
  Serial.println(" - device name:    " + s_device_name);
  
  
  delay(2000);
  Serial.println("Modify the settings");
  BOOTLOADER_SETTING.u8_set_device_name("myDICE");
  
  delay(2000);
  Serial.println("Store the settings in flash");
  
  uint8_t u8_ret = BOOTLOADER_SETTING.u8_store_bootloader_settings();
  
  if(u8_ret != 0)
	Serial.println("Error writing into flash");
  
  Serial.println("DONE");
}

void loop () 
{
}

Notes and Warnings

Don’t forget to call the function u8_store_bootloader_settings() to write the changed settings into flash, so that the bootloader (and app.) has the new values at the next system start / reset.

The device name can be used for example in systems with several devices of the same kind (several dice-IOs). The device name can help to identify the specific device by its name e.g. ‘IOrear’, ‘IOfrot’ etc.

See also

u8_store_bootloader_settings()
s_get_device_name()
SAMC21_CAN