I'm trying to receive data from a COM port and send it to another COM port with some filter applied on data. but I have a weird problem and I can't find the source of it.
the data contains ZPL commands(zebra printer commands e.g : ^XA^LRY^F0350 and etc) and I want to ignore these commands and only send actual data to printer port.
the problem is when I get data it randomly has data loss! sometimes a few characters and sometimes so many of them ant it is very random!!! for example sometimes for 2 weeks it works fine and sometimes it does not get a single print correctly! at first I think it is because of my filters but then I just completely send data to printer COM without any filter and still have those data losses...
can anyone help me with that? this is the code I write, and how I use it is written at the end of question
receive_ser= serial.Serial()
receive_ser.timeout = None
receive_ser.port = RES_PORT
receive_ser.parity = "N"
printer_ser = serial.Serial(timeout=None)
printer_ser.port = PRINTER_PORT
while True:
time.sleep(1)
receive_ser.open()
bytesToRead = receive_ser.inWaiting()
data = receive_ser.read(bytesToRead)
if data != b'':
printer_ser.open()
printer_ser.write(data)
receive_ser.close()
printer_ser.close()
I turn this .py file into .exe file using pyinstaller in a virtual machine with XP 32 bit OS using this command:
pyinstaller --console --onefile code.py
then I use this .exe file on another PC with Windows XP 32 bit. Is it possible that com srvice of windows not works properly?