Menu

Catch exception

Alikxus
2015-09-14
2015-12-26
  • Alikxus

    Alikxus - 2015-09-14

    Hi! I need in to catch exception when port is busy or error CRC. How to do it? Thanks!

     
  • Julie Haugh

    Julie Haugh - 2015-09-14

    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.

     
  • Alikxus

    Alikxus - 2015-09-15

    Thaks. Sometimes for testing is necessary to know the cause of the error.

     
  • Julie Haugh

    Julie Haugh - 2015-09-20

    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.

     
  • Alikxus

    Alikxus - 2015-12-18

    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
  • Julie Haugh

    Julie Haugh - 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.

     
  • Alikxus

    Alikxus - 2015-12-23

    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
  • Julie Haugh

    Julie Haugh - 2015-12-26

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.