我现在正在使用USB Weatherboard V3。使用PySerial从usb weatherboard获取数据
数据每隔1秒从/ dev/ttyUSB *连续发送...我尝试使用PySerial获取数据,但仍然失败。
我只能在输出控制台中获得“RESET”。我无法获取数据。
我要的是输出这样的:
SHT15 temperature: 2.5 75.1 deg F
SHT15 humidity: 65%
SHT15 dewpoint: 62.7 deg F
BMP085 pressure: 2 2011, 10:05:235.967 in Hg FAIL
BMP085 temperature: 75.3 deg F
TEMT6000 light: 0.1%
Weather meters wind speed: speci0.0 MPH FAIL
Weather meters wind direction: -1 degrees FAIL
Weather meters rainfall: 0.00 inches FAIL
External power: 0.00 Volts FAIL
^它来自小型机(UNIX串行程序)。
有人可以帮助我吗?
顺便说一句,这是我目前的代码:
import serial;
import io;
import time;
import os;
# Weather board script #
if __name__ == '__main__' :
try :
print '===================================\n'
print 'USB Weatherboard V3 - Python Script'
print 'Connection datasheet : '
print '(+) Port : /dev/ttyUSB0'
print '(+) Baud rate : 9600'
print '(+) Type : 8N1'
print '===================================\n'
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=1, xonxoff=False, rtscts=False, dsrdtr=True)
while True :
arr = ser.readlines()
for strarr in arr :
s = strarr.decode('cp1252').replace('\00','')
#s2 = s.encode('ascii');
s2 = s
if s2[1:3] != '[H' :
print s2
pass
pass
pass
except :
print 'Program exit !'
pass
finally :
ser.close()
pass
请帮我纠正它,如果有人谁在我之前有它的代码,请与我:)
檐V3产品:https://www.sparkfun.com/products/10586
我已经提供了更多信息:) ...实际上它没有给出错误,但我无法获得与minicom一样的输出。 – psuedobot
在源代码中,你提到'问题:未知字符字节'。这应该是多行错误输出中的最后/第一行。 – phihag
哦,没有一个是以前的错误...现在,这是没有错误,但我的脚本并没有给我像minicom测量给我... – psuedobot