Help with serial communication on DWM1001

Hello,

I have 3 anchors and 2 tags connected, I can see the coordinates on the Android APP.

I’m trying to get the tag coordinates through the serial port, I have one connected through USB to my PC and the other through the serial port to a Raspberry Pi.

Both are connected at 115200 bauds, and I’m sending the “lec” command, and as a response I’m getting just 3 characters. 0x40, 0x01 and 0x01. What am I doing wrong?

Please help, I’ve been stuck on this for the last 3 days. :huh:

1 Like

Hi daraos,

In order to use the command “lec”, you need to be in the uart shell mode.

In order to start the shell mode, you have to send “\r” twice or press enter key twice within one second and then wait for a bit. The dwm1001 should answer and then you should be able to use the “lec” command.

You can find more details in the DWM1001-API-guide

Let me know how it goes
Thanks
Yves

Thanks for your answer Yves.

I get the same result. When I send any text (be it lec, les, fwfbskdjf, etc) the response is always 0x40 0x01 0x01 (or an @ if shown as ascii)
Maybe it is already in shell mode? should I get a command prompt in shell mode?

edit:
I use this Python code to read from the DWM1001-DEV board:

import serial
import time
try:
ser = serial.Serial(
port=‘/dev/serial0’,
baudrate=115200,
timeout=0.5
)
except:
ser = serial.Serial(
port=‘/dev/ttyACM1’,
baudrate=115200,
timeout=0.5
)

ser.write(b’/x0D’)
time.sleep(0.2)
ser.write(b’/x0D’)
time.sleep(0.2)
ser.write(b’/x0D’)
time.sleep(0.2)
ser.write(b’/x0D’)
time.sleep(1)

while True:
res=ser.read(100)
print
print time.strftime(“%Y-%m-%d %H:%M:%S”, time.gmtime()),

for letra in res:
    print ord(letra),
ser.write(b'lec/x0d')

The response is:

pi@raspberrypi:~ $ python decawave.py

2018-04-03 12:55:04 64 1 1 64 1 1 64 1 1 64 1 1
2018-04-03 12:55:05 64 1 1
2018-04-03 12:55:05 64 1 1
2018-04-03 12:55:06 64 1 1
2018-04-03 12:55:06 64 1 1
2018-04-03 12:55:07 64 1 1
2018-04-03 12:55:07 64 1 1
2018-04-03 12:55:08 64 1 1

Hi Daraos,

Can you try the following :

[color=#333333]time.sleep(1)[/color]
[color=#333333]ser.write(b’/x0D’)[/color]
[color=#333333]time.sleep(0.05)[/color]
[color=#333333]ser.write(b’/x0D’)[/color]
[color=#333333]time.sleep(1)[/color]

[color=#333333](Basically send \r only twice and then wait 1 second.)[/color]

[color=#333333]The message you get back is an error message from the DWM1001 when it is in generic UART mode. It basically tells it does not understand your request.[/color]

[color=#333333]Let me know how it goes,[/color]
[color=#333333]Thanks[/color]
[color=#333333]Yves [/color]

Thanks Yves,

I managed to get it to work. The ser.write were wrong, now I have ser.write(b’\r\r’) and it enters shell mode with a “dwm>” response

My code is now:

[code]import serial
import time

ser = serial.Serial(
port=’/dev/serial0’,
baudrate=115200,
timeout=0.1
)

ser.write(b’\r\r’)

res=ser.read(10)
time.sleep(0.5)
ser.write(b’lep\r’)

print res

while True:
res=ser.read(100)
if len(res)>0:
print res[/code]

I’m now trying to get the listener to send the position of all the tags.

thanks again!

iam using a python script too , have u tried to run your script on booting raspberry in rc.local !!
or u tried runninng script after shutdown or unplugging (hardware disconnection)
coz iam have a problem getting it to work ,after shutdown it stucks in generic mode knowing that it works perfectly while a normal reboot.

Hello Shaima,

I’m running my script as a service, so it restart if something goes wrong.

You can constantly check if the TAG is in shell mode, if you don’t receive a position from another tag in 5 seconds, assume that it is not inshell mode, there you can send ‘\r’ to check if you receive a ‘DWM>’ (so it is in shell mode but there’s no data being received), if you don’t receive it, start sending ‘lep\r’ (or les, or lec) until you receive a position.

I made a state machine:
mode=0 ==> initial state, not in shell mode ==> send ‘\r\r’ and receive data that includes ‘DWM>’ (data.find(‘DMW>’) >= 0)
mode=1 ==> On shell mode but not receiving data ==> send ‘lep\n’ and receive ‘DWM>’
mode=2 ==> working state, on shell mode and receiving position ==> If it doesn’t receive data for 5 seconds (or more, or less), jump to mode=0

Hope this helps.
Daniel