Description
u8_set_can_send_id()
allows you to configure the CAN ID (11 bit – standard ID) that the bootloader and CAN2SER instances will use to send CAN messages. [default 0x766].
Syntax
u8_set_can_send_id( ou16_new_can_id );
Parameters
uint16_t ou16_new_can_id: the new CAN send ID for this device.
Returns
uint8_t return value meaning:
0 – setting changed (accepted).
2 – the parameter ou16_new_can_id is out of range (0 … 0x7FF)
Example Code
This example shows how to read, set and store the ‘can send id’ of the bootloader settings.
void setup()
{
Serial.begin();
while (!Serial)
{
yield(); // wait for PC CAN2SER-monitor to open
}
Serial.println("Current bootloader settings:");
Serial.print(" - can send id: 0x");
Serial.println(String( BOOTLOADER_SETTING.u16_get_can_send_id(), HEX ));
delay(2000);
Serial.println("Modify the settings");
BOOTLOADER_SETTING.u8_set_can_send_id(0x766);
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.
Each device must use a unique CAN ID on the same CAN bus. This means that this ID might need to be customised if there are more than one dice device connected to the bus or in cases where the identifier is already in use by another node. If you change this ID it would be recommendable to also change the local ID (LID) accordingly. Find addressing details and recommended settings here and in the users manual.
See also
u8_store_bootloader_settings()
u16_get_can_listen_id()
SAMC21_CAN
u8_set_local_id()
u16_get_can_send_id()
device addressing