Crc Checksum - Bosch Rexroth SMART Flex Effector Manual

Table of Contents

Advertisement

50
6.3.2

CRC checksum

The cyclic redundancy check (CRC) is a method for determining a checksum for data in order to
identify errors during transmission or saving. As an option, the SFE also allows you to use this
procedure to ensure the correctness of the data which is sent by the user to the SFE unit, or from the
SFE unit to the user.
Modbus CRC16 is used as the checksum.
Using the checksum when communicating via serial interface
The data (responses) from the SFE unit always contain a checksum which depends on the actual
response value. The response value is separated by a "!". Example: GET;BAUD;921600!37EF
With this checksum, the data received by the user can be checked for transmission errors. This check
is optional. The checksum can be calculated by the user. Example function in C (Copyright (c) 1999-
2016 Lammert Bies - https://github.com/lammertb/libcrc, license text:
party license
information):
Checksum Modbus CRC16
1
/*
2
* uint16_t crc_modbus( const unsigned char *input_str, size_t num_bytes );
3
*
4
* The function crc_modbus() calculates the 16 bits Modbus CRC in one pass for
5
* a byte string of which the beginning has been passed to the function. The
6
* number of bytes to check is also a parameter.
7
*/
8
9
uint16_t crc_modbus( const unsigned char *input_str, size_t num_bytes ) {
10
11
uint16_t crc;
12
const
13
size_t
14
15
if
( ! crc_tab16_init ) init_crc16_tab();
16
17
crc = CRC_START_MODBUS;
18
ptr = input_str;
19
20
if
( ptr != NULL )
21
22
crc = (crc >> 8) ^ crc_tab16[ (crc ^ (uint16_t) *ptr++) & 0x00FF ];
23
}
24
25
return
26
27
}
/* crc_modbus */
en
unsigned char *ptr;
a;
for
(a=0; a<num_bytes; a++) {
crc;
Interface description
MIT License
in the section
6
Third-

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexroth sfe

Table of Contents