Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
CRC mismatch
-
i have a problem to send a command to a device and get response,
there is an exception that say CRC is mismatch but, i attached the request and response sniffed by serial monitor
it seems everything is ok, but why i get CRC mismatch exception!!!?Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
ready to send connect command
com.serotonin.modbus4j.exception.ModbusTransportException: CRC mismatch: given=1
065, calc=49192
at com.serotonin.modbus4j.base.ModbusUtils.checkCRC(ModbusUtils.java:87)at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessage
Response(RtuMessageResponse.java:21)
at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(R
tuMessageParser.java:21)
at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessag
eParser.java:17)
at com.serotonin.messaging.MessageControl.data(MessageControl.java:133)
at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.j
ava:76)
at java.lang.Thread.run(Unknown Source)
**Request: 2012/03/03 02:26:34 ?.?.07964 (+23.5156 seconds)
01 10 00 A8 00 02 04 35 35 35 35 30 F4 ...¨...55550ô
Answer: 2012/03/03 02:26:34 ?.?.12664 (+0.0469 seconds)
01 10 00 A8 00 02 04 29 93 ...¨...)?
**
-
Can you turn on IO logging to get a trace of what the lib is seeing?
-
Thanks for your reply, but how to enable IO logging ?
-
ModbusMaster.setIoLog(PrintWriter)
Also, have you tried ModbusMaster.setDiscardDataDelay. Maybe try setting that to something like 200ms and see if that helps.
-
Sorry, but i can not find ModbusMaster.setIoLog(...) or ModbusMaster.setDiscardDataDelay(...) in Modbus4j library project.
I'm sure that i use last version of modbus4j that i download from sourceforge, so what can i do now?update 1 -------------------------------------
Ok now i found that those functions are in cvs repository,
i will try them and send report hereupdate 2 -------------------------------------
i try to use IoLog, but nothing happen, logger did not write even an character!!!
about setDiscardDataDelay also nothing happen,but i found that if i ignore the exception, i can run the next command on my device without error!
because the data that we send and receive is correct.so what is that crc problem?
-
I uploaded a newer jar file to the repo. It includes epoll support now too.
Try setting the iolog to System.out or something like that. It works for me.
-
Hi
my problem still exist and my code throw CRC exception.
but finally i can run I/O logging and here is the result:Stable Library
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
ready to send connect command
1331106184515 O 011000a80002043535353530f4
1331106184609 I 011000a80002042993
com.serotonin.modbus4j.exception.ModbusTransportException: CRC mismatch: given=1
065, calc=49192
at com.serotonin.modbus4j.base.ModbusUtils.checkCRC(ModbusUtils.java:104
)
at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessage
Response(RtuMessageResponse.java:41)
at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(R
tuMessageParser.java:41)
at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessag
eParser.java:37)
at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.j
ava:76)
at java.lang.Thread.run(Unknown Source)
1331106186531 O 011000a80002043535353530f4
1331106186562 I 011000a80002042993
com.serotonin.modbus4j.exception.ModbusTransportException: CRC mismatch: given=1
065, calc=49192
at com.serotonin.modbus4j.base.ModbusUtils.checkCRC(ModbusUtils.java:104
)
at com.serotonin.modbus4j.serial.rtu.RtuMessageResponse.createRtuMessage
Response(RtuMessageResponse.java:41)
at com.serotonin.modbus4j.serial.rtu.RtuMessageParser.parseMessageImpl(R
tuMessageParser.java:41)
at com.serotonin.modbus4j.base.BaseMessageParser.parseMessage(BaseMessag
eParser.java:37)
at com.serotonin.messaging.MessageControl.data(MessageControl.java:170)
at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.j
ava:76) -
I get the same result. The incoming response looks otherwise ok. The part "011000a80002" looks right. What is suspicious is that the response has 3 bytes at its tail instead of just two: "042993". A CRC is only two bytes.