The underlying library should throw an exception when a port is busy.
There is no way to catch an exception on an invalid CRC - if the CRC check fails, the packet is simply discarded. That said, CRC failures can result in timeouts, which are thrown as exceptions. The usual Modbus paradigm is to use response timeouts to indicate the request needs to be retried.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The j2mod library does support the DIAGNOSTICS command. Your device would have to support it (not many do, unfortunately), but you could query the slave to find out how many responses it sent, and how many requests it received with invalid CRCs.
That's the only way I know to figure out where CRC errors are happening, which makes the lack of support for the command so annoying.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That's how j2mod handles error responses -- it throws an exception. You must then query the exception object to determine what happened. You don't get a ModbusResponse object as you do with a regular, successful response.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are Javadocs for the package, if that's what you're asking for. There weren't a lot of docs when I forked jamod years ago. I'm not sure I want to invest the time in creating a user's manual, if that's the question you're asking.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi! I need in to catch exception when port is busy or error CRC. How to do it? Thanks!
The underlying library should throw an exception when a port is busy.
There is no way to catch an exception on an invalid CRC - if the CRC check fails, the packet is simply discarded. That said, CRC failures can result in timeouts, which are thrown as exceptions. The usual Modbus paradigm is to use response timeouts to indicate the request needs to be retried.
Thaks. Sometimes for testing is necessary to know the cause of the error.
The j2mod library does support the DIAGNOSTICS command. Your device would have to support it (not many do, unfortunately), but you could query the slave to find out how many responses it sent, and how many requests it received with invalid CRCs.
That's the only way I know to figure out where CRC errors are happening, which makes the lack of support for the command so annoying.
Hi Julie. Say me, please - your library supports error answer? Example, master sends request 0c 03 00 07 00 0d, slave answers 0c 83 11. However i have error ModbusException - com.ghgande.j2mod.modbus.ModbusSlaveException: Illegal Function
http://www.modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf page 15
Last edit: Alikxus 2015-12-18
Alikxus -
That's how j2mod handles error responses -- it throws an exception. You must then query the exception object to determine what happened. You don't get a ModbusResponse object as you do with a regular, successful response.
Thank you. I did not know that i can to get response after error. Do you have instruction or other manual for your library?
Last edit: Alikxus 2015-12-23
There are Javadocs for the package, if that's what you're asking for. There weren't a lot of docs when I forked
jamod
years ago. I'm not sure I want to invest the time in creating a user's manual, if that's the question you're asking.