The main point of this is to be able to upgrade module software without having to send it back to the maker to be re-programmed.
The loader occupies the lowest 4k bytes of program memory and gains control after a reset. If there is a valid program loaded above it then it enters the program.
If there is no valid program loaded, then it executes its own main loop, performing anything that may be relavent to a node which can't do anything. This includes read block, write block, setting the canid and NN, NN refresh as well as the loader function. This means it can cope with an error or power failure during re-programming, but not with loading a faulty program.
If a working module receives a software download start packet, it needs to turn off any pulsed outputs, disable interrupts and then jump to the loader at 0x000030.
program baseaddress = 0x1000
Note. In C18, 16 and 32 bit (2 and 4 byte) data are stored low byte first, the opposite way to CBUS packet data.
Format: <5C><NNhigh><NNlow>
Directs the module with nodenumber NN to enter the loader in order to receive a software download. The module should stop running by turning off any pulsed outputs, disable interrupts and enter the boot loader. The loader will send an ack back to the PC. The loader should then load a complete program and execute the restart cmd.
Format: <5D><NNhigh><NNlow>
Directs the module with nodenumber NN to set the valid program loaded flag to 0x00, and execute a reset instruction. Used after loading a compete program without error.
Format: [<Priority><CANID>]<7C><NNhigh><NNlow><status>
The module with nodenumber NN sends this to indicate its status after executing something that takes time. Currently used for a block write to a module, Event teaching and Node variables. The status can be application dependant. Currently the status is:
Format: <BC><NNhigh><NNlow><AddressUpper><AddressHigh><AddressLow>
Requests the node with nodenumber NN to transmit a block of 64 bytes from program memory at the address. The reply is 17 memory data packets.
Format: <BD><NNhigh><NNlow><AddressUpper><AddressHigh><AddressLow>
Commands the node with nodenumber NN to write a 64 byte block of data to program memory or eeprom. This is followed by 17 memory data packets and the module should then send an ACKNN after the block is written.
Format: <FC><NNhigh><NNlow><Offset><data0><data1><data2><data3>
A packet containing 4 bytes of memory data. Since data is always transfered in 64 byte blocks with a CRC8 byte there will always be 17 data packets for a complete block. The CRC8 byte has offset = 64. Since packets do not arrive in order the offset is the address with the 64 byte block. The number of blocks has to be counted to check that they have all arrived.