本文整理匯總了Python中protocol.Protocol.getPressure方法的典型用法代碼示例。如果您正苦於以下問題:Python Protocol.getPressure方法的具體用法?Python Protocol.getPressure怎麽用?Python Protocol.getPressure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.getPressure方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: len
# 需要導入模塊: from protocol import Protocol [as 別名]
# 或者: from protocol.Protocol import getPressure [as 別名]
baudRate = sys.argv[2]
deviceAddress = sys.argv[3]
logEnabled = sys.argv[4]
elif len(sys.argv) == 1:
print ('Command line: getweather.py serial_port serial_speed')
print ('Trying with serial_port = ' + serialPort + ' and serial_speed = ' + str(baudRate))
else:
print ('Command line: getweather.py serial_port serial_speed')
sys.exit(1)
currenttime = time.time()
db = DBHelper(dbFileName)
device = Protocol(serialPort, baudRate, logEnabled)
if device.ping(deviceAddress):
pressure, sernumP = device.getPressure(deviceAddress)
if 10 < pressure < 1000:
print ('Pressure - ' + str(pressure) + ' mmHg')
pressureSensorId = db.getSensorId(pressureSensorType, sernumP)
db.storeValue(currenttime, pressure, pressureSensorId)
humidity, sernumH = device.getHumidity(deviceAddress)
if not math.isnan(humidity):
print ('Humidity - ' + str(humidity) + '%')
humiditySensorID = db.getSensorId(humiditySensorType, sernumH)
db.storeValue(currenttime, humidity, humiditySensorID)
values = device.getTemp(deviceAddress)
i = 1
for (temperature, sn) in values:
print ('T' + str(i) + ' - ' + "%.1f" % temperature + ' C, sensor'),
device.printPacket(sn)
i += 1