cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to read modbus with lua script?

jkunelius
1-Newbie

How to read modbus with lua script?

I'm trying to read modbus values with a lua script.

I have EMS and lua script running ok, and I can bind remote properties to a created thing.

The only problem I have is that I don't know where should I determine the modbus 'source'/host (I'm using a plc simulator on another computer).

- Juho

5 REPLIES 5

Juho, you can set the host (host ip where your sim is running) under the scripts.modbus_handler section in your config.lua. It usually runs on port 502, the EMS should be able to pick it up.

Thank you for your quick response!

However, I'm getting following error codes when running luaScriptResource:

luaScriptProxy::execute: [1982854224] Error executing script modbus_handler, Error = Error: error loading module 'socket.core' from file '/home/pi/micro/etc/community/clibs/socket/core.so':

/home/pi/micro/etc/community/clibs/socket/core.so: cannot open shared object file: No such file or directory

AND

[WARN ] 2016-11-15 11:23:14,398 ScriptResource::executeScriptRequest: Path /scripts/modbus_handler/holding_register/1/40001/ not found

[ERROR] 2016-11-15 11:23:14,398 luaInterscriptBinding::l_executeCallback: Error executing callback 'modbus_handler//scripts/modbus_handler/holding_register/1/40001'

Returned: 404 /scripts/modbus_handler/holding_register/1/40001/ not found

It's obvious that I'm missing something crucial here, but what?

- Juho

Do you have the modbus package? If not, please download this.

Yes I do, I have the linux_ARM version of it that can be found in Edge help center modbus example.

The one I had linked has the updated version, I believe. You can swap out the (modbus) contents in this with your version.

Top Tags