Description

u8_get_reset_message() reads out the customisable part of the CAN reset message. The device will perform a reset if it receives this message, if it is addressed to it and if it comes with the right CAN identifier (typically from the PC – 0x765).

Syntax

u8_get_reset_message( opu8_reset_msg );

Parameters

uint8_t* opu8_reset_msg; pointer to a target buffer of uint8_t (min. size 6) where this function will copy the reset mesg. bytes into.

Returns

uint8_t – 0

Example Code

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

void setup()
{  
  Serial.begin();
  while (!Serial) 
  {
    yield(); // wait for PC CAN2SER-monitor to open 
  }

  uint8_t au8_tempString[6];
  Serial.print(" - reset msg:       ID 0x");
  Serial.print(BOOTLOADER_SETTING.u16_get_can_listen_id(), HEX);
  Serial.print(" DLC:8 - ");
  Serial.print((BOOTLOADER_SETTING.u8_get_local_id() << 2), HEX);
  Serial.print(" 0x07");
  BOOTLOADER_SETTING.u8_get_reset_message(au8_tempString);
  for(int i=0; i < 6; i++)
  {
	Serial.print(" 0x");
	Serial.print(((char)au8_tempString[i]), HEX);
  }
  
  delay(2000);
  Serial.println("Modify the settings");
  uint8_t au8_newResetMsg[6] = {'R','E','S','E','T','\0'};
  BOOTLOADER_SETTING.u8_set_reset_message(au8_newResetMsg);
  
  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

The reset message consists of more than the 6 bytes that is read out with the example above. It also contains information about the addressed device or if it is a broadcasting message, respectively. Also, the device apparently only accepts reset messages from the CAN-ID it is listening on. Find further details in the users manual.

See also

u8_store_bootloader_settings()
u16_get_can_listen_id()
u8_set_reset_message()
SAMC21_CAN
Device addressing