ParaCAN 0.0.40-master SHA: 4c1cf74739
ParaCAN

This library allows a device access with the Hermes Parameterinterface over the Controller Area Network (CAN). All communication is done with four CAN-Message identifiers. The Base-Address is defined in the global const cui16_CANBaseAddress which must be set in Project. An additional address defined in const cui16_CANBroadcastAddress is used for automatic connection to the PC-Software.

To interact with the hardware to send telegrams, the function CAN_SendTelegram has to be implemented:

void CAN_SendTelegram(uint8_t data_length, uint8_t *data, uint16_t id_value);
void CAN_SendTelegram(uint8_t data_length, uint8_t *data, uint16_t id_value)
Send CAN Message to transmit Buffer.
Definition: CAN_Para_STM32.c:41

In the Receive-Interrupt the here defined function CAN_Para_ReceiveIRQ has to be called from hardware-driver.

CAN-Messages used for Parameter-Interface

Connect from PC (command 1)

PC tries to connect the Device.

  • Address: Base-ID
  • DLC: 2
  • Data[0]: running request ID
  • Data[1]: Command-Identifier, always 1 for this command

Answer from Device

  • Address: Base-ID + 1
  • DLC: 4
  • Data[0]: running request ID (same as in request)
  • Data[1]: Command-Identifier, always 1
  • Data[2]: spare, always 0
  • Data[3]: Version of the Interface Specification. This is Version 6
msc_inline_mscgraph_1

The Connection is established, all other commands can be used from now on.

Read one SubID (command 2)

PC wants to read one single sub-ID of one Parameter.

  • Address: Base-ID
  • DLC: 6
  • Data[0]: running request ID
  • Data[1]: Command-Identifier, always 2 for this command
  • Data[2-3]: Parameter-ID
  • Data[4-5]: Sub-ID

Answer from Device

  • Address: Base-ID + 1
  • DLC: 4-8 (depends on datatype)
  • Data[0]: running request ID (same as in request)
  • Data[1-2]: Data-length in bytes
  • Data[3-7]: Data (length can be 1-5 bytes, depending on data-type)

If Data length that have to be transferred is more than 5 bytes, additional follow-up telegrams are sent without request. If more than 255 follow-up telegrams are neccessary, the running counter can overflow.

  • Address: Base-ID + 3
  • DLC: 3-8 (depends on amount of data)
  • Data[0]: running request ID (same as in request)
  • Data[1]: running counter of follow-up telegram starting with 0
  • Data[2-7]: Data (length can be 1-6 bytes, depending on data-type)
msc_inline_mscgraph_2

Write of one Sub-ID (command 3)

PC wants to write one single sub-ID of one Parameter.

  • Address: Base-ID
  • DLC: 8
  • Data[0]: running request ID
  • Data[1]: Command-Identifier, always 3 for this command
  • Data[2-3]: Parameter-ID
  • Data[4-5]: Sub-ID
  • Data[6-7]: Data length in Bytes

The Data is transmitted in follow-up telegrams without any answer between the telegrams. If more than 255 follow-up telegrams are neccessary, the running counter can overflow.

  • Address: Base-ID + 2
  • DLC: 3-8 (depends on datatype / amount of data)
  • Data[0]: running request ID (same as in request)
  • Data[1]: running counter of follow-up telegram starting with 0
  • Data[2-7]: Data (length can be 1-6 bytes, depending on data-type)

Answer from Device

  • Address: Base-ID + 1
  • DLC: 4-8 (depends on datatype)
  • Data[0]: running request ID (same as in request)
  • Data[1-2]: Data-length in bytes, always 0 to signalize a status code transmission.
  • Data[3]: Error-Code, 0 to signalize success
msc_inline_mscgraph_3

Read all SubIDs (command 4)

PC wants to read all sub-IDs of one Parameter.

  • Address: Base-ID
  • DLC: 4
  • Data[0]: running request ID
  • Data[1]: Command-Identifier, always 4 for this command
  • Data[2-3]: Parameter-ID

Answer from Device

  • Address: Base-ID + 1
  • DLC: 4-8 (depends on datatype/amount of data)
  • Data[0]: running request ID (same as in request)
  • Data[1-2]: Data-length in bytes
  • Data[3-7]: Data (length can be 1-5 bytes, depending on data-type/amount of data)

If Data length that have to be transferred is more than 5 bytes, additional follow-up telegrams are sent without request. If more than 255 follow-up telegrams are neccessary, the running counter can overflow.

  • Address: Base-ID + 3
  • DLC: 3-8 (depends on amount of data)
  • Data[0]: running request ID (same as in request)
  • Data[1]: running counter of follow-up telegram starting with 0
  • Data[2-7]: Data (length can be 1-6 bytes, depending on data-type)
msc_inline_mscgraph_4

Read Memory Area (command 5)

PC wants to read a Memory-Area. The Memory Area must be allowed (see Parameterinterface).

  • Address: Base-ID
  • DLC: 8
  • Data[0]: running request ID
  • Data[1]: Command-Identifier, always 5 for this command
  • Data[2-5]: Address of the Memory Area
  • Data[6-7]: length of the Memory Area

Answer from Device

  • Address: Base-ID + 1
  • DLC: 4-8 (depends on datatype/amount of data)
  • Data[0]: running request ID (same as in request)
  • Data[1-2]: Data-length in bytes
  • Data[3-7]: Data (length can be 1-5 bytes, depending on data-type/amount of data)

If Data length that have to be transferred is more than 5 bytes, additional follow-up telegrams are sent without request. If more than 255 follow-up telegrams are neccessary, the running counter can overflow.

  • Address: Base-ID + 3
  • DLC: 3-8 (depends on amount of data)
  • Data[0]: running request ID (same as in request)
  • Data[1]: running counter of follow-up telegram starting with 0
  • Data[2-7]: Data (length can be 1-6 bytes, depending on data-type)
msc_inline_mscgraph_5

Ping from Device for Autoconnect

The Device can optionally send ping-telegrams, which triggers a connect request from all connected PCs. With this Ping-Telegram the PC can monitor, which devices are present on CAN-Bus if thge CAN-Address of the Device is not known.

  • Address: Broadcast-ID (normally 0x7F0)
  • DLC: 3
  • Data[0]: Version of CAN Parameterinterface
  • Data[1-2]: Base Address

Error

In case of an Error on Device as answer of one of the previous defined messages

  • Address: Base-ID + 1
  • DLC: 3
  • Data[0]: running request ID (same as in request)
  • Data[1-2]: reserved, always 0
  • Data[3]: Error Code

The following Error Codes are defined:

  • 1: The Parameter-ID is not found
  • 2: Memory Area is not permitted to read