Hi. I have 5 anchors (one set to ANI, 3 set to AN, and one AN that also has UWB mode set to passive); and one tag.
Using Python code, I was able to set up the nodes, but when I run “les”, I get nothing. I suspect that the issue is that I’ve not set the position of the anchors, but I cannot figure that out from the limited explanation of commands in the manual. When I run “an”, I see the anchors, but their positions are all 0,0,0:
Hi @kbares
do you have also TAGs in your setup? You need to setup position in your anchors otherwise the tag nodes would not be able to calculate their position.
Please check this PDF MDEK1001_Quick_Start_Guide.pdf .
The issue you raise about the position of the anchors definitely seems to be my problem. I’m attempting to do all of this via Python code (don’t have the Android app running). I’ve not figured out the command to setup position of the anchors. Any clues? Related to this, do I need to tell the anchors and tag that they are all in the same network? Thanks again!
Hi @kbares
well as usual it is better to start with docs 8-).
You need to set everywhere the same PANID - example command: nis 0x1234
Then you need to set up the Anchor position command aps - position is in mm
I would heavily recommend to start with android phone and go trough the Quick start guide and play with it before trying to control “unknown” devices via python using shell, which totally not supposed to be used a module-program interface. Shell is only for module - human interface. For Module-application you should use binary API commands - see the DWM1001-API-Guide.pdf .
Thanks, @leapslabs. I did get an Android device set up and agree that it made setup much easier.
I have 5 anchors (one as initiator and one passive for listening) and a single tag. They all show up in the app. When I connect the tag via USB to run Python code, I can only get the tag location by passing “apg”–and the result looks like what is printed in the manual for “les”; passing “les” yields no results.
When I connect via USB to the passive anchor, I am not getting any results when I pass “les”. When I pass “la”, I do get the correct listing of anchors.
Adding my code below in case you have ideas on where I might be going wrong. Thx!
from curses import baudrate
import serial
import time
import sys
import glob
import subprocess
import shlex
import time
from argparse import ArgumentParser
class DecawaveCmds:
shell_mode = b'\x0D\x0D' # this sends two returns
nmg = b'nmg\n' # this gets node's mode
nmp = b'nmp\n' # this changes to passive mode
la = b'la\n' # show AN list
apg = b'apg\n' # this gets position
def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
"""
if sys.platform.startswith('win'):
ports = ['COM%s' % (i + 1) for i in range(256)]
elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
# this excludes your current terminal "/dev/tty"
ports = glob.glob('/dev/tty[A-Za-z]*')
elif sys.platform.startswith('darwin'):
ports = glob.glob('/dev/tty.*')
else:
raise EnvironmentError('Unsupported platform')
result = []
for port in ports:
try:
s = serial.Serial(port)
s.close()
result.append(port)
except (OSError, serial.SerialException):
pass
return result
def send_receive(port, command, length):
ser = serial.Serial(port, 115200, timeout=0.1)
ser.write(DecawaveCmds.shell_mode)
time.sleep(1)
st = ser.read(300) # len 225
data = st
print("DATA: ", data)
print("LEN: ", len(data))
print("------------------------\n")
command_string = ('{}\n').format(command)
command_string_as_bytes = str.encode(command_string)
ser.write(command_string_as_bytes)
read_length = len(data)
st = ser.read(read_length)
print("Data for {}: {}".format(command, st))
print("LEN: ", len(st))
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--command', required=True, help='command to send to transceiver.')
parser.add_argument('--length', required=True, type=int, help='length.')
args = parser.parse_args()
ports = serial_ports()
port = ports[0]
print('port: ', port)
send_receive(port, args.command, args.length)
Hi @kbares
as I mentioned shell is not meant to be used as module - machine interface! This leads to first problem - shell is not capable to handle a stream of bytes there must be a cca 20ms separation between chars - example:
les command:
send(“l”)
delay(20ms)
send(“e”)
delay(20ms)
send(“s”)
delay(20ms)
send("\n")
another notes:
dont use nmg - this switch the node to gateway node not to anchor anchor mode! Use nma.
apg command returns the anchor position set by aps command. On TN use only les/sec/lep commands
TN and not printing anything - try to set maximum update rate aurs 1 1. If it not help please print here the output of si command.