Why not make the programs in Python3?

More
1 year 5 months ago #6243 by oz1ewr
I have downloaded the PIRadmon.pi ver 1.2, and online converted it to python 3.
BUT I still get the error"('Could not communicate with the Server, timeout reached. => geiger 1: ', TypeError("a bytes-like object is required, not 'str'"), '\r\n')
Can anybody help ?????

Regards Erik Nielsen, oz1ewr, Slagelse DK

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #6244 by whyza
I am guessing the age of PIRadmon is the issue, it was probably written before python3 was the norm.

Are you trying to simply capture geiger data over a serial port on the Pi or something more complex ?

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #6245 by oz1ewr
I would like to use the programs PyRadmon.py to upload from my geiger, but even when I have convertet til program to Python3, I simply can't get it working without the type-error. I have used 3 days now, without success.
I think the type-error is in this lines:
url = "GET /radmon.php?user=" + self.user + "&password=" + self.password + "&function=submit&datetime=" + dtime+"&value=" + str(sampleCPM) + "&unit=CPM HTTP/1.1"
request = url + "\r\nHost: www.radmon.org\r\nUser-Agent: pyRadMon " + VERSION + "\r\n\r\n"
print("Sending average sample => geiger 1: ", str(sampleCPM), " CPM\r\n")
Regards Erik

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #6246 by whyza
I tried the same to convert it to python3 without success.

After that I spent a fraction of the time creating a bash script that did what I needed.

Hence the question what are you trying to do ?
How does your geiger 'upload' data ?
Via a serial/usb link ?

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago - 1 year 5 months ago #6247 by whyza
At a guess it looks like this str

 + str(sampleCPM)

is the issue. The error indicates it should perhaps not be a string ?

"a bytes-like object is required, not 'str'"

This may also assist.

Below is the minimum HTTP Get you need to use to "upload" to radmon, which looks the same as your URL minus the date and time. Radmon will use the current/upload data and time if it is not specified in the URL.

http://radmon.org/radmon.php?function=submit&user=USERNAME&password=PASSWORD&value=UPLOAD&unit=CPM"

Where USERNAME and PASSWORD are your Radmon credentials and UPLOAD is the CPM value you want to upload.

you can test it with this command

curl http://radmon.org/radmon.php?function=submit&user=USERNAME&password=PASSWORD&value=UPLOAD&unit=CPM"

and you should get back an OK
Last edit: 1 year 5 months ago by whyza. Reason: typo

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #6248 by oz1ewr
Thanks for answer.
It shall only be used to upload cpm.data to radmon.org. I am collecting cpm from my geiger via serial FTDI usb, where i collect every count during 1 min. I am doing it now om my gaming PC, using 500 W, but i will be happy using my old rasberry3 on 3W.
I will try your script.
Regards QZ1EWR.

Please Log in or Create an account to join the conversation.

Moderators: Gamma-Man
Time to create page: 0.215 seconds
Powered by Kunena Forum
Everything's free. Please support us by considering a donation. Log in first!
Solar powered Raspberry Pi 4 server stats: CPU 63% Memory 12% Swap 18% CPU temp=54.5'C Uptime 41 Days