subscribe to our Youtube


13387 questions

15914 answers


50509 members

0 votes
246 views 0 comments

I've created some custom Lua scripts on TRB140 which read measurements from different devices via Modbus and do some special processing before the data is sent to cloud. I'm using the custom register block as described here:

My custom regfile is located at /tmp/modbus/regfile

When the device is restarted, the regfile is removed (as expected). The problem is that if I create the regfile in my Lua script or shell script after restart, it does not work: The Modbus request test tool just throws the "Unexpected response length" error regardless of contents of the file. However, if I go to Modbus slave settings and change something (like register count) and save, the regfile is created by the system and it works again.

I've also tried different methods for creating the file, like taking a backup of a working regfile and copying to the desired location on device startup, but it still keeps throwing the same error. I've also set identical file permissions so it's not about them either. The only way to create a functioning regfile is by changing the settings and saving. I also tried to inspect how the file is actually created when saving the settings, but I haven't found anything so far.

The device is using firmware version TRB1_R_00.07.01

1 Answer

0 votes
Well...this one got solved sooner than I thought: The regfile was not created on startup because the folder /tmp/modbus did not exist. Things started to work correctly after I added the folder creation script to the startup before Modbus services are started. All good now.

However, if anyone has any insight on why a copied regfile did not do the job, I'd be glad to hear. In other words, what is special about the system-created regfile or what does the system do differently so that things start to work.
Best answer