USB & RS232 Communication
Data Link Layer
EPOS4 Communication Guide
2-18
CCMC | 2019-11 | rel8759
3)
Calculate the CRC (use algorithm as to
chapter “2.2.3.2 CRC Algorithm” on page 2-14):
ArrayLength = Len + 2
CrcValue = CalcFieldCRC(&DataArray, ArrayLength)
DataArray[ArrayLength-1] = CrcValue
4)
Add the CRC value to the DataArray:
C) COMPLETION
5)
Pack the DataArray to a byte stream (low byte first).
6)
Add sync bytes.
7)
Add byte stuffing (
chapter “2.2.4 Byte Stuffing” on page 2-15).
8)
Transmit the stuffed byte stream (
chapter “2.2.5 Transmission Byte Order” on page 2-15):
SendStuffedData(&DataArray)
Transmission order (low byte first):
0x90
,
0x02
,0x60,0x02,0x01,0xB0,0x30,0x00,0x2E,0x62
D) WAIT FOR RECEIVE FRAME
9)
The EPOS4 will answer to the command “ReadObject” with an answer frame and the returned
parameters in the data block as follows:
Reception order (low byte first):
0x90
,
0x02
,0x00,0x04,0x00,0x00,0x00,0x00,0x01,0x90,0x90,0x00,0x00,0x9A,0x5C
Important:
• Do not send any data before the receive frame or a timeout is present.
• EPOS4 cannot process data simultaneously.
E) REMOVE BYTE STUFFING AND THE SYNCHRONIZATION ELEMENTS
10) Byte stream without stuffing and synchronization elements:
0x00,0x04,0x00,0x00,0x00,0x00,0x01,0x90,0x00,0x00,0x9A,0x5C
F) CRC CHECK
For details
chapter “2.2.3 Cyclic Redundancy Check (CRC)” on page 2-14):
11) Prepare the word DataArray for CRC calculation (little endian):
DataArray
DataArray[0]
0x0260
DataArray[1]
0xB001
DataArray[2]
0x0030
DataArray[3]
0x622E
the calculated CRC value
DataArray
DataArray[0]
0x0400
DataArray[1]
0x0000
DataArray[2]
0x0000
DataArray[3]
0x9001
DataArray[4]
0x0000
DataArray[5]
0x5C9A