ERROR invalid crc received 13

Asked by diamondboy

Hello,
   I come from China, I am sorry my English is not very good.
   I use codeblocks compiler "win32-native" to provide an example, suggesting the following crc error:

winxp sp3, chinese.

//****** Slave
Opening COM1 at 19200 bauds (none)
Waiting for a message...
<11><05><00><13><FF><00><00><13>

ERROR invalid crc received 13 - crc_calc 7F6F (-16)
[11][05][00][13][FF][00][00][00][60][1C]
Waiting for a message...
<11><01><00><13><00><01><00><13>

ERROR invalid crc received 13 - crc_calc E9F (-16)
[11][01][01][01][94][88]
Waiting for a message...
<11><0F><00><13><00><25><05><00><13><B2><0E><1B><10><35>

ERROR invalid crc received 1035 - crc_calc 2545 (-16)
[11][0F][00][13][00][25][67][45]
Waiting for a message...

//****** Master

** UNIT TESTING **

TEST WRITE/READ:

ERROR invalid crc received 0 - crc_calc 7F6F (-16)
1/2 force_single_coil: OK

ERROR invalid crc received 101 - crc_calc 1272 (-16)
2/2 read_coil_status: OK

ERROR invalid crc received 25 - crc_calc 8822 (-16)
1/2 force_multiple_coils: FAILED

Question information

Language:
English Edit question
Status:
Answered
For:
libmodbus Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Stéphane Raimbault (sra) said :
#1

The original libmodbus library is designed to run on Linux, FreeBSD and MacOX so I don't know how the library works under Windows but I'm pretty sure something is wrong in the way the serial connection is etablished.

The character 0x13 has a special meaning in serial communication and you need a raw communication

Canonical input is line-oriented. Input characters are put
           into a buffer which can be edited interactively by the user
           until a CR (carriage return) or LF (line feed) character is
           received.

           Raw input is unprocessed. Input characters are passed
           through exactly as they are received, when they are
           received. Generally you'll deselect the ICANON, ECHO,
           ECHOE, and ISIG options when using raw input
        */

        /* Raw input */
        tios.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);

You could have a look to other free software to see examples of serial communication under Windows.

Can you help with this problem?

Provide an answer of your own, or ask diamondboy for more information if necessary.

To post a message you must log in.