Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.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 如何使用SMBus执行非阻塞读取?_Python_Raspberry Pi_Nonblocking - Fatal编程技术网

Python 如何使用SMBus执行非阻塞读取?

Python 如何使用SMBus执行非阻塞读取?,python,raspberry-pi,nonblocking,Python,Raspberry Pi,Nonblocking,我有一个简单的代码: import smbus i2c = smbus.SMBus(1) i2c.read_byte(0x20) 但是,我希望使读取功能无阻塞,或者至少有一个短超时,即~100毫秒。原因是我正在使用第二块板来判断另一个I2C设备是否冻结。我看到了,但我认为在运行中停止此功能会导致I2C连接不稳定。有没有办法设置此函数的短超时

我有一个简单的代码:

import smbus

i2c = smbus.SMBus(1)

i2c.read_byte(0x20)
但是,我希望使读取功能无阻塞,或者至少有一个短超时,即~100毫秒。原因是我正在使用第二块板来判断另一个I2C设备是否冻结。我看到了,但我认为在运行中停止此功能会导致I2C连接不稳定。有没有办法设置此函数的短超时