pyserial

Python serial read corrupting print statements

Python serial read corrupting print statements Question: I have this bizarre situation where reading from a serial port is appearing to corrupt calls to print. This code: ser = serial.Serial(‘COM13’, 115200, timeout=5) ser.reset_input_buffer() ser.reset_output_buffer() ser.write("statn".encode(‘utf-8’)) ser.flush() for i in range(10): print(f"read: <{self.ser.read(10).decode(‘utf-8’)}>") outputs >ead: <s read: < > read: <> read: <> read: <> … …

Total answers: 1

Python: How can I concatenate in a bytearray as I do with strings?

Python: How can I concatenate in a bytearray as I do with strings? Question: I would like to get part of a bytearray from a string or int but Python gives me an error. I tried this calling sendfallblatt.self(1,02) as those code are selected in GUI with a combolist of texts linked to numbers. sendfallblatt(fallblattadresse, …

Total answers: 1

Unable to find the right port to connect PySerial to USB device on Windows 11

Unable to find the right port to connect PySerial to USB device on Windows 11 Question: I’m trying to use the PySerial library on Windows 11 to connect to a USB device so I can communicate with it. However, I’m having trouble finding the right "address" to connect it too. I’m trying to run the …

Total answers: 1

python serial library issue with ser.write() command

python serial library issue with ser.write() command Question: I am looking for a solution to combine a string of integers(let’s say, ‘0000’ and ‘1000’ for example). But I need to encode to bytes anything that is sent through ser.write() with the b attribute that goes next to the string I want to send, which will …

Total answers: 1

TypeError: 'bytes' object cannot be interpreted as an integer

TypeError: 'bytes' object cannot be interpreted as an integer Question: I use OpenCV to read a barcode and send it to an Arduino via serial communication using package pyserial. The goal is to make a robotic arm move the object (much like in amazon warehouses). When sending the bytes it shows this error: C:UsersarccovenvScriptspython.exe D:PythonpythonProjecttest.py …

Total answers: 1

Clean way to send data struct from python to arduino?

Clean way to send data struct from python to arduino? Question: I’m working on a robot and I’d like to somehow send a command using pySerial to the arduino. The command would look like {MOVE, 60, 70} or {REQUEST_DATA}, where I’d have the arduino read in the first value, if it’s "MOVE" then it drives …

Total answers: 1

Can you read from serial buffer without knowing baudrate?

Can you read from serial buffer without knowing baudrate? Question: I’m just wondering why it’s necessary to know the baud rate when reading serial data from the buffer with PySerial. Shouldn’t the byte data in the buffer be the same regardless of 9600 or 38400 baud rate, with the exception that the latter fills faster? …

Total answers: 1