Difference between revisions of "CanServo/Protocol/LongMessage"

From HITEC_HELP
Jump to navigation Jump to search
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Up ==
* Up page: [[CanServo/Protocol/0]]
== Long Message ==
== Long Message ==


* 각 패킷마다 Tail Byte가 있어서, 1개 혹은 여러개의 패킷으로 보낼 수 있는 방식입니다.
* A method of sending a long message by dividing it into multiple packets.
** Of course, 1 packet is also possible.


* This content refers to the message format of UAVCAN.
* This content refers to the message format of UAVCAN.
Line 12: Line 17:
** [[Code/CRC16]]
** [[Code/CRC16]]


=== CAN 2.0 ===
* Transmission method
** Check the length of the message to be sent, and if it cannot be sent in one packet, calculate CRC16 and add it to the end of the message.
*** The starting value for CRC16 calculation is 0xFFFF (-1).
** Repeat the process of cutting from the front, attaching the Tail Byte, and sending it as one packet.
*** At this time, if the length (including Tail Byte) exceeds 8 bytes, the exact length is placed in the first byte.
** NOTE: If it is not an FD, the maximum is 8 bytes, so it can be up to 7 bytes.
*** In the case of FD, the maximum is 64 bytes, so excluding the first byte of length, it can be up to 62 bytes.


* Packaging the message to be sent.
* 주의 사항
** If the message to be sent is 8 bytes or more, CRC16 is added.
** Host가 발신하는 경우는, 동시에 전송하지 않으면 되지만,
** 서보가 보내는 경우는, 여러 서보가 동시에 보낼 수 있습니다.
** 같은 CAN ID 로 동시에 여러 Long Message가 전송 될 때에는, Tail Byte 의 변화와 CRC16 등으로 분석합니다.


* Packet's Data Format
=== CAN 2.0 ===
** < Data : max 7 byte, cut from packed Message >, <Tail Byte>
 
* Messages less than 8 bytes long are transmitted as one packet.
 
* CRC starting value is 0xFFFF (-1)


=== CAN-FD ===
=== CAN-FD ===


* CAN-FD는 data가 64바이트까지 확장됩니다.
* CAN-FD data is expanded up to 64 bytes.
** 0~8, 12, 16, 20, 24, 32, 48, 64
** 0~8, 12, 16, 20, 24, 32, 48, 64


* Packaging the message to be sent.
* [[CanServo/Protocol/CAN-FD]]
** If the message to be sent is 63 bytes or more, CRC16 is added.
** 메시지의 길이가 62바이트 이하이면, crc16을 붙이지 않고, single packet으로 전송
 
* packet data format:
** data len <= 7: < data: max 7 bytes >, < tail byte >
** 8바이트를 초과하는 경우에는 첫 바이트에 전송 데이터 길이를 지정합니다.
** data len >= 8, len <= 62: < data len : 1 byte >, < data: len byte >, < tail byte >


=== Tail Byte ===
=== Tail Byte ===
Line 43: Line 44:
** bit 7 = first packet
** bit 7 = first packet
** bit 6 = last packet
** bit 6 = last packet
** bit 5 = Toggle, first packet = 1, toggle bit on each packet
** bit 5 = 1 if first packet, toggle bit on each packet
** bit 4:0 = Seq, 0 ~ 31, inc 1 on each message
** bit 4:0 = Seq, 0 ~ 31, inc 1 on each message

Latest revision as of 10:06, 26 February 2026

Up

Long Message

  • A method of sending a long message by dividing it into multiple packets.
    • Of course, 1 packet is also possible.
  • This content refers to the message format of UAVCAN.
    • Thanks to UAVCAN
  • Note:
    • CRC16 : byte order : low byte first, little endian
  • Transmission method
    • Check the length of the message to be sent, and if it cannot be sent in one packet, calculate CRC16 and add it to the end of the message.
      • The starting value for CRC16 calculation is 0xFFFF (-1).
    • Repeat the process of cutting from the front, attaching the Tail Byte, and sending it as one packet.
      • At this time, if the length (including Tail Byte) exceeds 8 bytes, the exact length is placed in the first byte.
    • NOTE: If it is not an FD, the maximum is 8 bytes, so it can be up to 7 bytes.
      • In the case of FD, the maximum is 64 bytes, so excluding the first byte of length, it can be up to 62 bytes.
  • 주의 사항
    • Host가 발신하는 경우는, 동시에 전송하지 않으면 되지만,
    • 서보가 보내는 경우는, 여러 서보가 동시에 보낼 수 있습니다.
    • 같은 CAN ID 로 동시에 여러 Long Message가 전송 될 때에는, Tail Byte 의 변화와 CRC16 등으로 분석합니다.

CAN 2.0

CAN-FD

  • CAN-FD data is expanded up to 64 bytes.
    • 0~8, 12, 16, 20, 24, 32, 48, 64

Tail Byte

  • Tail Byte
    • bit 7 = first packet
    • bit 6 = last packet
    • bit 5 = 1 if first packet, toggle bit on each packet
    • bit 4:0 = Seq, 0 ~ 31, inc 1 on each message