Question
How to continuously read LSM6DSRTR data under Linux iio?
I am using LSM6DSRTR, and the device-tree compatible is "st,lsm6dsr".
I can see two iio device node under
/sys/bus/iio/devices/iio:device1
/sys/bus/iio/devices/iio:device2But when I try to read in a python loop, it gets really slow.
Anyway better to read it?
def getData(self, path):
fd = open(path, "r")
data = fd.read().strip()
fd.close()
return data
def testData(self):
iio_oneshot_path = "/sys/bus/iio/devices/iio:device2/in_accel_x_raw"
fd = open(iio_oneshot_path, "r")
while self.refresh:
self.accX = self.getData('/sys/bus/iio/devices/iio:device2/in_accel_x_raw')
self.accY = self.getData('/sys/bus/iio/devices/iio:device2/in_accel_y_raw')
self.accZ = self.getData('/sys/bus/iio/devices/iio:device2/in_accel_z_raw')
self.gyroX = self.getData('/sys/bus/iio/devices/iio:device1/in_anglvel_x_raw')
self.gyroY = self.getData('/sys/bus/iio/devices/iio:device1/in_anglvel_y_raw')
self.gyroZ = self.getData('/sys/bus/iio/devices/iio:device1/in_anglvel_z_raw')
print(self.accX)
time.sleep(0.01)
