rflog_db.py - issues

54 views
Skip to first unread message

paul arthur

unread,
Sep 26, 2023, 9:52:42 PM9/26/23
to PrivateEyePi
Hello,

While trying to follow this tutorial i had a few issues when executing the script rflog_db.py. The error code i'm receiving is

pi@mopi:~/projects $ /usr/bin/python3 /home/pi/projects/Data-logging/rflog_db.py
An exception of type TypeError occurred. Arguments:
('can only concatenate str (not "bytes") to str',)
can only concatenate str (not "bytes") to str


The sensors are working. Please see the result of serial_mon.py below:

JemRF Serial Monitor 2.3.0

Press ctrl-c to exit

01HELLO----

Wed Sep 27 02:04:34 2023 43 AWAKE----

Wed Sep 27 02:04:34 2023 43 TMPA22.19

Wed Sep 27 02:04:34 2023 43 SLEEPING-

Wed Sep 27 02:05:58 2023 84 TMPA22.05

Wed Sep 27 02:05:58 2023 84 SLEEPING-

Wed Sep 27 02:09:46 2023 43 AWAKE----

Wed Sep 27 02:09:46 2023 43 TMPA21.60

Wed Sep 27 02:09:46 2023 43 SLEEPING-

Any ideas as to why this is happening?

Thank you,

Paul

paul

unread,
Oct 1, 2023, 7:52:45 PM10/1/23
to PrivateEyePi

I figured it out. The problem was in the rf2serial.py file. here it's trying to concatenate received data (ser.read()) to the llapMsg variable. In Python 3, you need to make sure that you are working consistently with either bytes or strings. The problem was the following line of code: 

llapMsg += ser.read()

I changed to the following:

llapMsg += ser.read().decode(‘utf-8’, ‘ignore’)

Hopefully this helps somebody else. I tested the db and it is storing the data. 

Kind Regards,


Paul

Glenn Seaton

unread,
Oct 1, 2023, 7:55:17 PM10/1/23
to PrivateEyePi
Thank You Paul!!!!
I had started looking but with no luck so far. This was a great help!
I will update the master download files.

Glenn

Glenn Seaton

unread,
Oct 3, 2023, 11:28:44 AM10/3/23
to PrivateEyePi
The Git download has been updated.
I updated the fix to support BME devices that send binary messages that Python decodes into values.
I also updated the Button and State functions to log into the database.
The rflog_db.py current version is 3.10.
I updated the screen sample display to space columns.
The rf2serial.py and rflog_db.py apps in the Python3 folder were changed.
The two .PHP apps index.php and dblogger.php were updated.

Glenn

paul

unread,
Oct 3, 2023, 9:38:18 PM10/3/23
to PrivateEyePi
Oh wow, awesome! Looks like you made the entire code base more robust.

Paul

Reply all
Reply to author
Forward
0 new messages