Using PAN over Raspberry Python UART API

I’m still looking for a solution to get all units locations from SPI.
But if you want to use python to access over uart api you can use these codes;

les , lec or lep command is works forever as i want but if you dont want this you can easily change while condition to do that.

import serial
import time

port = '/dev/ttyS0'
baud = 115200

ser = serial.Serial(port, baud, timeout=0)


def read_msg(msg):
    response = ""
    ser.flushOutput()
    msg = msg + "\r"
    msg=msg.encode()
    ser.write(msg)
    time.sleep(0.1)
    while response != "".encode():
        response = ser.readline()
        time.sleep(0.1)
        if response != "dwm> ".encode() and response.decode().strip() != msg.decode().strip():
            # do whatever you want with this response
            print(response.decode().strip())
    ser.flushInput()


ser.write(b'\r\r')
time.sleep(0.5)
ser.flushInput()

# read anchors list
read_msg("la")
# read unit modes
read_msg("nmg")
# read accelerometer values
read_msg("av")

example outputs:

read_msg(“av”)
acc: x = 96, y = 816, z = 16208

read_msg(“la”)
[006019.650 INF] AN: cnt=0 seq=xFF
[006019.650 INF]

read_msg(“nmg”)
mode: ani (pasv,-,-)

New forums interface for sharing codes is not shinny. You can find the code that i wrote in

1 Like

Now i realized that serial data couldn’t be realtime. Because of the serial buffer mechanism when i start get location command like lep in listener mode coordinates became flow in uncertain timeframe and this data has no timestamp. When you listen it from serial you did not get the new data , you get the data waiting in queue :frowning:
Now finally if we want to use this MDEK system with realtime tracking we need a sytem works with callbacks. Same problem could still in SPI communication too. Because it works with TVL frames not addresses and registers.
I’m waiting for the new firmware for MDEK1001 to make that happen. We need to read datas with timestamped and if possible reading accelerometer data realtime remotely will be good.