hi,
I am want to communicate with nr52 dongle via serial. The dongle periodically outputs data which I read.
The problem is that is the python connect in the middle of printf the data is corrupted. Hence, I would like to reset the NRF51 dongle for fresh print outs. I tried same code sequence as Arduino but that does not work. Cant find any documentation for that. Following is the code I am running
def runSerial(BAUD=38400, size=16):
import serial.tools.list_ports
PORT =''
NAME =''
for p in list(serial.tools.list_ports.comports()):
if 'usbmodem' in p[0]:
PORT = p[0]
NAME = p[1]
break
if PORT:
ser = serial.Serial(PORT, BAUD)
ser.setDTR(level=False)
time.sleep(0.5)
# ensure there is no stale data in the buffer
ser.flushInput()
ser.setDTR()
time.sleep(0.5)
print( "waiting for NRF %s..." %NAME )
s = struct.Struct('16B')
read_byte = ser.read()
while True:
print s.unpack_from(ser.readline())
print " "