Can anyone help me out as to how sending a message works? I'm not totally sure how to input the CAN-BUS message address even because how do you fit 0x290 (the address for the mazda screen), in 3 bits? 0x290 in binary is 001010010000. How does that fie in 3 bits? Or should I be using extended ID? I'm so confused here. banghead
The format of the 64 byte buffers is pretty simple, and can be determined without much difficulty by looking at the firmware source code. The important fields are:
Bytes 0..51: CAN messages (see below for details). [IN/OUT]
Byte 52: Number of CAN messages to send. I have only tried sending a single message at a time. [OUT]
Byte 55: Transmit Error Counter. [IN]
Byte 56: Receive Error Counter. [IN]
Byte 57: CANSTAT register - see datasheet for details. [IN]
Byte 58: CANCTRL register - see datasheet for details. [OUT]
Byte 60: SPI command. For incoming messages, this echos back the command that was sent. Commands are 0xC0 (CAN reset), 0x03 (read register), 0x02 (write register), 0
x80 (RTS - ?), 0xB0 (RD Status - ?) and 0xD0 (Read Firmware Version). [IN/OUT]
Byte 61: Register. Set to the register to read or write. The response to a read request contains the same value. [IN/OUT]
Byte 62: Data. The value to be written to a register for outgoing messages, or retrieved from a register for incoming messages. [IN/OUT]
CAN message format
Byte 0: Most significant bit (bit 7) indicates the presence of a CAN message. Bit 5 indicates an extended (29 bit) identifier. Bit 4 indicates a remote transmission request (RTR). Bits 0-3 contain the data length.
[Standard ID] Bytes 1-2: Byte 1 and bits 5-7 of byte 2 contain the identifier, big endian.
[Extended ID] Bytes 1-4: From most significant to least significant, the message ID is in byte 1, byte 2 (bits 5-7), byte 2 (bits 0-1), byte 3, and byte 4.
Next [len] bytes: If this is not an RTR message, the content of the message follows (up to 8 bytes).