Menu

TCP Slave and master

Anonymous
2012-07-19
2013-05-28
  • Anonymous

    Anonymous - 2012-07-19

    Hi,

    I want to build TCP master-slave with jamod but I do not suceed.

    I think the problem is in the slave program because, when I use "Multiway" software to run a Modbus server, the master program (based on "how-to master" sample" run well.

    If I understanf well the "how-to slave" sample program:
    - the "process image" lines are to do a test, but they are not required in a real program. Is it right?
    - a minimal program could be the following:

    ******************
    listener = new ModbusTCPListener(3,InetAddress.getByName(myIP));
    listener.setPort(port);
    listener.start();             
    ****************

    but what is missed, because error occured when I run it with the "master" program….

    (java.lang.ClassCastException: net.wimpi.modbus.msg.ExceptionResponse cannot be cast to net.wimpi.modbus.msg.ReadInputDiscretesResponse)

    thanks by advance for answers….

     
  • Julie Haugh

    Julie Haugh - 2012-08-05

    The "ProcessImage" classes are for a Modbus slave that is providing the data.  In your slave program, when you receive a request, use the request object to create the response object with the createResponse() method for the request.

    When you use the Listener class, it handles all of the work, and that includes invoking the createResponse() method for each request.

    In your case, it sounds like there was an exception in the slave, possibly because you aren't initializing the ProcessImage properly, and your Master assumed (incorrectly) that it was always going to receive a ReadInputDiscretesResponse message.  When an exception is returned by the slave, the object class is different, and you have to test for that before casting to the expected class.

    The documentation for "jamod" is rather weak, and many of these issues aren't discussed.  Not only is the "j2mod" fork I recently created less bug-ridden, but I'm also working on adding more documentation.  You might want to check it out.

     
  • Dieter Wimberger

    Hi Julie:

    I have checked the Bug Tracker and I did not find a single bug that was reported by you.
    Then I have checked the Feature Requests and I did not find a single request that was filed by you.
    There was also not a single Patch filed by you, nor was there any Support Request.

    (Note: filtered for jfhaugh)

    I worked on this back in 2000 and it started on an embedded system, without any support for the serial protocols. Actually this support has been added by John, whom I am thankful for supporting his implementation ever since as well as he could.
    All of our work has been available to the public free of charge and under a license liberal enough to allow anybody to use it for their own efforts (even commercially without retribution).

    I have very often supported people that requested help from me directly and I have gone through some really difficult times, so that I might as well have sometimes left behind one or the other request (shame on me, but a roof above the head and some food on the table for my family might have been more important).

    Jamod might not be a product by itself, but for open source jamod is actually pretty well documented:
    http://dieter.wimpi.net/2007/03/os-project-feature-jamod.html
    http://dieter.wimpi.net/2010/04/jamod-some-faqs.html

    You would have been welcome to actually take a stake in jamod and help to make it better. But it's great that you took our work and derived something more useful from it. Many more have done this before you (and I have and will link those efforts from the site when I do updates again).

    If you think we are doing something wrong, please file a report and maybe even a possible fix, instead of pointing out everywhere that you are doing everything better and that jamod sucks.

    I am sorry if you feel that we did a bad job or that we didn't take your contributions (whereever they may have gone instead of into the trackers) into account.

    But please, for the sake of tolerance and my believe in humankind, stop bashing and start to be more constructive either here or over at your own project.

    Thanks and best regards,
    Dieter

     

Log in to post a comment.

MongoDB Logo MongoDB