Closed blank-supportgis closed 1 year ago
It turns out you need to put a little pause in between the sent characters. The following script works for me:
import serial
from time import sleep
ser = serial.Serial(
port='/dev/serial0',
baudrate = 921600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=0.1,
xonxoff=1,
rtscts=0
)
print("sending...")
for c in "help\r":
ser.write(c.encode())
sleep(0.05)
print('receiving...')
received_data = ser.read() #read serial port
sleep(0.03)
data_left = ser.inWaiting() #check for remaining byte
received_data += ser.read(data_left)
print (received_data.decode())
I'm connecting the LiPow charger via UART to a Raspberry Pi 3. When opening a serial console with
cu -l /dev/ttyS0 -s 921600
, I can run commands without any problem.However, the following Python script, using the pySerial package
, yields the following output:
Note the
e
right afterreceiving
. It seems that the charger echoes part of the command back, as if only an arbitrary substring of the issued command was transmitted.I've also tried