Skip to main content
1-Visitor
November 11, 2016
Question

How to read modbus with lua script?

  • November 11, 2016
  • 1 reply
  • 6336 views

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

1 reply

5-Regular Member
November 11, 2016

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.

jkunelius1-VisitorAuthor
1-Visitor
November 15, 2016

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

5-Regular Member
November 15, 2016

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