Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 电子秤的RS232端口_Python - Fatal编程技术网

Python 电子秤的RS232端口

Python 电子秤的RS232端口,python,Python,我想从秤上取重量 这是我的代码: import serial ser = serial.Serial('com3', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS,

我想从秤上取重量 这是我的代码:

import serial
ser = serial.Serial('com3',
                    baudrate=9600,
                    parity=serial.PARITY_NONE,
                    stopbits=serial.STOPBITS_ONE,
                    bytesize=serial.EIGHTBITS,
                    timeout = 3)

print(ser.read())
但我得到的只是b'\x00'


您可以查看解释scale如何将信息发送到计算机的图像(来自制造商手册)

没有图像是的,我将编辑该图像。
ser.read()
仅读取一个字节。可能是您需要从流中读取更多信息吗?如果我使用print(ser.read(100))它会给我b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ x00\…根据我在文档中看到的内容,您可能需要一直阅读,直到看到
0xBB
。如果不是这样,我不知道有谁能帮你。您的设置可能错误,但我们无法知道。这里没有别的事可做。