Hello,
I want to use pi to automatically seeting some config for the notecard during the manufacturing stage.
and we have to use the USB port from notecard to talk with Pi.
I was able to open the USB serial port on pi when notecard connected to pi by usb interface.
but I cannot get any response from notecard.
any idea what would be the rig solution?
I think it should be regarded as a generic Serial port on Pi too, as on Windows computer, I can use a generic serial debug tools to send command and receive it
Because we want to use pi to do this work instead of computer during the manufacturing process.
so would be great if it works.
below is the simple debug code in python on raspberrypi
import serial
s = serial.Serial('/dev/ttyACM0',115200,timeout=2000)
if s.is_open:
print("port opened")
#s.write("trace +gpsmax".encode('utf-8'))
while True:
print(s.read())
Hi @kevin and welcome to the Blues Wireless community!
There are a couple of things you should be aware of that may help:
When you use diagnostic commands (i.e. a non-JSON command) with the Notecard, make sure you terminate them with a newline character \n.
These non-JSON commands can differ from one version of the Notecard to another, which is why we don’t document them, but instead we recommend you always use supported JSON requests like {"req":"card.trace","trace":"+gpsmax"} instead.
What exactly are you trying to accomplish? It may be that we can find the right set of JSON requests for you from the Notecard API.
hey Roblauer,
Thanks for your reply on it.
I tried to use the json format and again, there is no response from notecard. I’m suspect whether it’s possible to even communicate with it by this method.
weird thing is I can even get it work by using the arduino serial tools.
so it should be pretty similar?
Sorry - I wasn’t clear in my response above: all commands sent to the Notecard need to end with a newline character \n (JSON or not). Can you try that and let us know if it works?
hey RobLauer
Sorry still no response, my code is pretty simple and I thin it should works?
import serial
with serial.Serial('/dev/ttyACM0',115200,timeout=2000) as ser:
ser.write(b'{"req":"card.trace","trace":"+gpsmax"}\n')
while True:
x = ser.read_until('\n')
print(x)
Hey @RobLauer a quick update here. this piece of code seems working now.
with serial.Serial('/dev/ttyACM0',115200,timeout=20000) as ser:
ser.write('{"req":"card.trace","trace":"+gpsmax"}\n'.encode())
#ser.write('"trace +gpsmax"\n'.encode()) as ser:
while True:
x = ser.read_until()
print(x)
I got the response from notecard now
pi@raspberrypi:~/shareFolder/github/rig_noteCard $ python3 serialPortTest.py
b’{“stop”:true,“trace”:“comm,sync,mdm,mdmmax,mem,gps,gpsmax”}\r\n’
which matches the log from a computer.
hey @RobLauer I appreciate your help.
can you share me with another command in json format than stream out the log lively?
I once use sync-trace on computer. But seems that it cannot recieve any comomand that not in json format now
You can enable a trace with {"req":"card.trace","mode":"on"} and disable it with "mode":"off". Is there something in particular you want to capture with your trace?