Modbus Handler

Martin Schmid
Posts: 34
Joined: Fri Aug 15, 2014 5:22 pm

Modbus Handler

Post by Martin Schmid » Tue Sep 16, 2014 3:02 pm

Dear Odysseus Team,


I was testing the modbus handler using the following Script

Code: Select all

#DROPALLSOURCES
#PARSER PQL
#RUNQUERY
modbussource := RETRIEVE({
            transport = 'modbustcp',
            source = 'modbussource',
            datahandler = 'tuple',
            protocol = 'none',
            schema = [['value', 'BitVector']],
            options = [
              ['slave','x.x.x.x'],
              ['port','502'],
              ['ref','0'],
              ['count','4'],
              ['scheduler.delay','1000']
            ]         
          }       
        )
 
#PARSER PQL
#RUNQUERY
out1 = MAP({
            expressions = [
                'toLong(value)',
                'toLong(subset(value,0,1))',
                'value [0]',
                'value [1]',
                'value [2]',
                'value [3]',
                'value [4]'
            ]
          },
          modbussource
        )
The stack trace:

Code: Select all

43733 ERROR AccessPO  - Error Reading from input - de.uniol.inf.is.odysseus.core.server.physicaloperator.access.pull.AccessPO.transferNext(AccessPO.java:116) 
java.lang.NullPointerException
	at de.uniol.inf.is.odysseus.modbus.ModbusTCPTransportHandler.getNext(ModbusTCPTransportHandler.java:161)
	at de.uniol.inf.is.odysseus.modbus.ModbusTCPTransportHandler.getNext(ModbusTCPTransportHandler.java:1)
	at de.uniol.inf.is.odysseus.core.physicaloperator.access.protocol.NoProtocolHandler.getNext(NoProtocolHandler.java:49)
	at de.uniol.inf.is.odysseus.core.server.physicaloperator.access.pull.AccessPO.transferNext(AccessPO.java:105)
	at de.uniol.inf.is.odysseus.scheduler.singlethreadscheduler.MultipleSourceExecutor.transfer(MultipleSourceExecutor.java:253)
	at de.uniol.inf.is.odysseus.scheduler.singlethreadscheduler.MultipleSourceExecutor.processSources(MultipleSourceExecutor.java:166)
	at de.uniol.inf.is.odysseus.scheduler.singlethreadscheduler.MultipleSourceExecutor.run(MultipleSourceExecutor.java:63)
Is there any additional information on this?

Thanks in advance

MS
Last edited by Martin Schmid on Mon Sep 29, 2014 11:47 am, edited 2 times in total.

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Modbus Handler

Post by Marco Grawunder » Tue Sep 16, 2014 3:57 pm

Seems, that there is no reply from the modbus source. I changed the behavior a little bit, so no exception should be thrown anymore in this case and null values are delivered.

Could you please make an update.

What for a result do you exspect?

Please enable advanced logging and attach the whole log-File.

http://odysseus.offis.uni-oldenburg.de: ... ed+logging

P.S.:Unfortunetly, we are not able to test the modbus handler on real hardware.

Martin Schmid
Posts: 34
Joined: Fri Aug 15, 2014 5:22 pm

Re: Modbus Handler

Post by Martin Schmid » Wed Sep 17, 2014 11:34 am

There seems to be an issue as a whole to reach the modbus server from our virtual machine, so that is most likely the issue.

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Modbus Handler

Post by Marco Grawunder » Wed Sep 17, 2014 12:07 pm

Yes, the problem is, that the slave does not allow to connect.

"java.io.IOException: java.net.ConnectException: Verbindungsaufbau abgelehnt"

stemming from:

com.ghgande.j2mod.modbus.net.TCPMasterConnection.connect(TCPMasterConnection.java:95)

Is the server reachable from the Odysseus system? Ist address and port set correctly?

Martin Schmid
Posts: 34
Joined: Fri Aug 15, 2014 5:22 pm

Re: Modbus Handler

Post by Martin Schmid » Wed Sep 17, 2014 3:17 pm

So far so good. After resolving our internal problems with accessing the Modbus Server I am actually getting data now with the following script:

Code: Select all

#DROPALLSOURCES
#PARSER PQL
#RUNQUERY
modbussource := RETRIEVE({
            transport = 'modbustcp',
            source = 'modbussource',
            datahandler = 'tuple',
            protocol = 'none',
            schema = [['value', 'BitVector']],
            options = [
              ['slave','x.x.x.x'],
              ['port','502'],
              ['ref','0'],
              ['count','4'],
              ['scheduler.delay','1000']
            ]         
          }       
        )
 
However, the value I'm getting returned always amounts to <null>. I do realize that this is a object with Datatype Bitvector, so I tried to remap it by using

Code: Select all

#PARSER PQL
#RUNQUERY
out1 = MAP({
            expressions = [
                'toLong(value)',
                'toLong(subset(value,0,1))',
                'value [0]',
                'value [1]',
                'value [2]',
                'value [3]',
                'value [4]',
                'value [5]',
                'value [6]',
                'value [7]'
            ]
          },
          modbussource
        )
As far as I understood, this maps all 8 bits of the 4 bytes I read in to a Long Value. However, when I click on "Show Data" I can't see any data coming in. Is there some key information I am missing?
Last edited by Martin Schmid on Mon Sep 29, 2014 11:47 am, edited 1 time in total.

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Modbus Handler

Post by Marco Grawunder » Wed Sep 17, 2014 3:38 pm

<null> means, no value from modbus server.

In the new version of Odysseus (in about 15 Minutes on the update site) bug report also includes the console ouput. Please send a bug report after running the query :-)

Martin Schmid
Posts: 34
Joined: Fri Aug 15, 2014 5:22 pm

Re: Modbus Handler

Post by Martin Schmid » Thu Sep 18, 2014 8:05 am

Updated Odysseus, enabled advanced logging and sent another bug report :)
Attachments
output.log
output.log 18/09/2014
(22.49 KiB) Downloaded 18 times

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Modbus Handler

Post by Marco Grawunder » Thu Sep 18, 2014 11:17 am

Hmm, it seems to be alright from Odysseus side. Nothing strange in the log...

I will add further logging infos ...

In about 30 Minutes, they will be available on the update site.

Martin Schmid
Posts: 34
Joined: Fri Aug 15, 2014 5:22 pm

Re: Modbus Handler

Post by Martin Schmid » Thu Sep 18, 2014 2:55 pm

I am assuming by now there are simply some parameters missing in the handler.

In particular we need to specify the address/unit id (probably 1 by default) and the function code (should be t3:float in our case).
I guess Odysseus uses hidden standard values for these parameters, is there any way to experiment with those?

Modbus server was verified to be online, sending data and reachable from the system that Odysseus is installed on.

Thanks in advance

MS

User avatar
Marco Grawunder
Posts: 272
Joined: Tue Jul 29, 2014 10:29 am
Location: Oldenburg, Germany
Contact:

Re: Modbus Handler

Post by Marco Grawunder » Thu Sep 18, 2014 3:32 pm

This line states, the is no content in the response.

Code: Select all

37065 ERROR ModbusTCPTransportHandler - Slave did not deliver any values - 
Our implementation is based on
http://sourceforge.net/projects/jamod/ and
http://sourceforge.net/projects/j2mod/

especially:

http://jamod.sourceforge.net/kb/tcp_master_howto.html

Maybe you can see something here? Maybe, this implementation is not appropriate? Can you access your modbus slave with this tool?

We are totally helpless without a real device ;-)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest