| Author |
Message |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 03/03/2012 18:26:04
|
greenday
Initiate
Joined: 03/03/2012 17:37:51
Messages: 4
Offline
|
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 ...¨...)?
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 03/03/2012 21:04:18
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1847
Offline
|
Can you turn on IO logging to get a trace of what the lib is seeing?
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 04/03/2012 06:42:08
|
greenday
Initiate
Joined: 03/03/2012 17:37:51
Messages: 4
Offline
|
Thanks for your reply, but how to enable IO logging ?
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 04/03/2012 23:06:50
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1847
Offline
|
ModbusMaster.setIoLog(PrintWriter)
Also, have you tried ModbusMaster.setDiscardDataDelay. Maybe try setting that to something like 200ms and see if that helps.
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 05/03/2012 07:14:34
|
greenday
Initiate
Joined: 03/03/2012 17:37:51
Messages: 4
Offline
|
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 here
update 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?
This message was edited 2 times. Last update was at 05/03/2012 10:21:38
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 05/03/2012 15:16:26
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1847
Offline
|
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.
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 07/03/2012 12:00:23
|
greenday
Initiate
Joined: 03/03/2012 17:37:51
Messages: 4
Offline
|
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)
This message was edited 1 time. Last update was at 07/03/2012 12:02:51
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 07/03/2012 15:28:56
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1847
Offline
|
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.
|
Best regards,
Matthew Lohbihler |
|
|
 |
|
|