I'm resuming a question which was already been asked (but with no relevant answers) here Using xonxoff-flow control with pyserial , because I'm having the same problem, trying to handle xonxoff on Windows with pyserial. I have to send data byte per byte to a POS printer which has a very small buffer, so I need to control Xoff value between every byte sent. I try to simply set True the xonxoff parameter of serial.Serial, but it doesn't seem to do anything. So I try to read the input buffer of the serial port before every send, but it still do nothing.
This is my code:
seriale = serial.Serial("COM1", xonxoff=True, rtscts=False, timeout=(0.1))
seriale.open()
for riga in scontrino.readlines():
try:
for b in riga: #leggo carattere per carattere
while (seriale.read_all().find(serial.XOFF)==True):
pass
b2=b.encode('utf-8') #codifico il carattere in bytes
seriale.write(b2)
except:
print("riga: " + riga + " NON stampata")
seriale.close()
So what I'm doing wrong?
Thanks in advance,
Alex