FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
656 views 3 comments
by

I wanted to query the database from modbus_serial_master which (I assume) is located at /tmp/.modbus_tcp_master_db

Therefore I did

opkg update

opkg install sqlite3-cli

but it seems it is not linked correctly

root@rut:/tmp# sqlite3

sqlite3: can't load library 'libreadline.so.6'

root@rut:/tmp#

apparently it is linked against libreadline 6 and currently there is 7 installed:

root@rut:/tmp# opkg info libreadline

Package: libreadline

Version: 6.3-1

Depends: libc

Status: unknown ok not-installed

Section: libs

Architecture: ar71xx

MD5Sum: 11817fad3b5f829ee731901c6c7d708e

Size: 101515

Filename: libreadline_6.3-1_ar71xx.ipk

Source: package/libs/libreadline

Description: The Readline library provides a set of functions for use by applications

 that allow users to edit command lines as they are typed in. Both Emacs

 and vi editing modes are available. The Readline library includes

 additional functions to maintain a list of previously-entered command

 lines, to recall and perhaps reedit those lines, and perform csh-like

 history expansion on previous commands.

Package: libreadline

Version: 7.0-1

Depends: libc

Status: install user installed

Architecture: ar71xx

Installed-Time: 1584092182

root@rut:/tmp# opkg files libreadline

Package libreadline (7.0-1) is installed on root and has the following files:

/usr/lib/libreadline.so.7.0

/usr/lib/libhistory.so.7.0

/usr/lib/libreadline.so.7

/usr/lib/libhistory.so

/usr/lib/libhistory.so.7

/usr/lib/libreadline.so

root@rut:/tmp#

So I tried to install 6 alongside 7, therefore I downloaded libreadline_6.3-1_ar71xx.ipk and tried to install that one:

root@rut:/tmp# opkg install libreadline_6.3-1_ar71xx.ipk

Not downgrading package libreadline on root from 7.0-1 to 6.3-1.

root@rut:/tmp#

Now I am unsure if I can safely downgrade libreadline...

Anyways - to get to the basic point of what I am looking for:

  • Is there a recommended way I can access the modbus device variables from command line?
  • Do I really need to fiddle around with sqlite3 dependencies in my case?
    • I downloaded libreadline_6.3-1_ar71xx and libncurses_5.9-2_ar71xx and extracted the missing linked libraries to /usr/lib manually, this helps for now but I am not that satisfied working my way outside of the packagemanager for productive environment...

Regards

C

by anonymous

Just to give an update:

the files I downloaded and placed in /usr/lib survived the reboot. 

I have hooked up a WTR10-E RS485 modbus temperature and humidity sensor to the RUT955 and set up a job in the modbus_serial_master to query the two registers.

Using sqlite3 I am now able to get the latest temperature from the requests like

sqlite3 /tmp/.modbus_tcp_master_db "SELECT CAST(SUBSTR(response_data, 2, LENGTH(response_data) - 3) AS DECIMAL) / 10.0 FROM modbus_data WHERE request_name = \"cfg08b95a\" ORDER BY time desc LIMIT 1"

and humidity

sqlite3 /tmp/.modbus_tcp_master_db "SELECT CAST(SUBSTR(response_data, 2, LENGTH(response_data) - 3) AS DECIMAL) / 10.0 FROM modbus_data WHERE request_name = \"cfg09b95a\" ORDER BY time desc LIMIT 1"

In case someone wants some more values along with the time in a human readable manner (just posting as a reference):

/tmp/.modbus_tcp_master_db "SELECT strftime(\"%Y-%m-%d %H:%M\", datetime(time, 'unixepoch')), CAST(SUBSTR(response_data, 2, LENGTH(response_data) - 3) AS DECIMAL) / 10.0 FROM modbus_data WHERE request_name = \"cfg08b95a\" ORDER BY time desc LIMIT 500"

I still have not figured out how to get the "cfg08b95a" from the config since the string is not contained in

uci show modbus_serial_master

(the b95a but not the 08 for temperature and 09 for humidity - and those are not the 8th or 9th value defined). 

But it is working for now.

New Questions

  • Is there any info about how many of the records are kept in the /tmp/.modbus_tcp_master_db? Do I have to delete old values by myself?
  • How can I extrace the request_name from the config?

I am a bit worried this will fill the RAM over time.

Regards

C

1 Answer

0 votes
by anonymous

Hello,

Modbus does not store data inside router DB. It stores a little bit of data in that file you tried to reach only when you enable data to server feature. You could remove libreadline package and install older version. However, deleting and reinstalling libreadline may affect the proper operation of other services:

 opkg remove --force-depends libpreadline.

Regards.

by

Thanks for the reply - I was already thinking about removing libreadline but I do not want to break the other packages.

 * print_dependents_warning:    freeradius2

 * print_dependents_warning:    quagga-vtysh

I was hoping for something more "sane" (in terms of system stability) to do than to break radius.
by anonymous

I just removed libreadline and libncurses packages and installed older versions. Sqlite3 works fine right now. Also tested router main functions and everything seems intact. But please proceed with caution while doing it.