Writing postitoning data into a variable in python

Hello! I’m searching for a possibility to write the realtime position of a tag in a python variable to use it afterwards. I’m using a Raspberry pi model 3B+ and, if its possible, I want to use the USB port. I searched a lot in the last few days but I could not find any useful ways.

Hi RedRobin,

What you are trying to achieve is not really clear to me.

Can you please elaborate ? What Hardware, Software you are using ?

Python is not a real time language, so you’re going to have some limitation with regards to performances.

Regards
Yves

Hi Yves,
I‘m using a Raspberry Pi Model 3 B+ with the dwm1001-dev Boards with the firmware that they are shipped with. Therefore, I have a Listener Tag configured, that should be connected ( if possible via USB to the dwm100) to the raspberry pi. On the raspberry pi should run a (if possible) python script, that writes the data from one ore mire tags into a json file, so I can use it afterwards, in other scripts (for example home automation or something like this).

Regards
Robin

So you want the python script to get the current values being sent from the decawave system for position/range?

Isn’t this just a case of parsing the serial stream that the decawave system outputs to extract the correct fields?

I think yes, but the problem is, that I don‘t know how I can make this.

Hi RedRobin,

Maybe have a look at tutorial for PySerial. You basically need to open the com port in python, send command in the utf8 format, and then process the readbuffer periodically.

The read buffer will contain the string with the distance, you need to do a bit a string processing to extract the distance. There are many way to do that, you can look at the regular expression, python regex library.

Hope it helps,
Yves

Thank you! I will have a look on it!

Robin

So now I hav this code:

import serial
import time

def read():
data = s.readline()
data = data.decode(‘utf-8’)
print(data)
time.sleep(1)
read()

s = serial.Serial("/dev/ttyAMA0", 115200, timeout = 1)

read()

s.close()

but I just get empty lines in the shell.
How do I get the positioning data now?

Robin