Reading data from serial port (COM3) using pyserial module on Windows XP
The baudrate is missing. You must specify baudrate. Most serial devices can not tolerate a wrong communication speed.
user699540
Updated on June 18, 2022Comments
-
user699540 almost 2 years
Before going into the problem, here is some hardware/software information:
Device accessed: Ohaus Scout Pro Digital Weight Machine (product link) Interface used: USB (product link) Serial Port: COM3 OS: WinXP Python Version: Activestate Python 2.7 pyserial version: 2.5
Python recognized this serial port and had no problems opening it. I am new to python as well as pyserial. I couldn't figure out how exactly can I read data from the serial port. I used the following code:
1 import serial 2 ser=serial.Serial(port='COM3',timeout=3) 3 s=ser.read(100) #reading up to 100 bytes 4 print s
This prints nothing. During those 3 seconds timeout, I placed an object on the weighing machine and it showed 100grams on the machine. But, this data is not showing on the computer. How can I read this data using pyserial?