AnsweredAssumed Answered

IIO channel read

Question asked by ajaykuruba143@gmail.com on May 19, 2017
Latest reply on May 29, 2017 by larsc

Hi

i am using ADIS16485 with iio.py library and i am using channels to read data

 

mport iio


def main():

# To print the IIO library version
print('IIO Library version: %u.%u (git tag: %s)' % iio.version)

contexts = iio.scan_contexts()
uri = next(iter(contexts),None)
ctx = iio.Context()

#if uri is not None:
# print('Using auto-detected IIO context at URI \"%s\"' % uri)

print('IIO context created: ' + ctx.name)
print('Backend version: %u.%u (git tag: %s)' % ctx.version)
print('Backend discription string: ' + ctx.description)

print('============================')

print('IIO contet has %u devices:' % len(ctx.devices))

for dev in ctx.devices:
print('\t' + dev.id + ': ' + dev.name)

iio.Device(dev)

if dev.name == 'adis16485':
adis16485_dev = dev

print('============================')

print('ADIS ISOLATED! :' + adis16485_dev.name)

print('\n%u Channels found: ' % len(adis16485_dev.channels))

for chn in adis16485_dev.channels:
print('\t%s: %s (%s)' % (chn.id, chn.name or "", 'output' if chn.output else 'input'))
if len(chn.attrs) != 0:
print('\t\t\t%u channel-specific attributes found:' % len(chn.attrs))
for attr in chn.attrs:
try:
print('\t\t\t\t' + attr + ', value: ' + chn.attrs[attr].value)
except OSError as e:
print('Unable to read ' + attr + ': ' + e.strerror)

# Print out accelerometer X values
if(chn.id == 'accel_x'):
x_raw = float(chn.attrs['raw'].value);
x_scale = float(chn.attrs['scale'].value);
x_axis_acceleration = x_raw * x_scale;
print('\nX axis raw = ' + str(x_raw))
print('\nX axis scale = ' + str(x_scale))
print('\nX axis acceleration = ' + str(x_axis_acceleration))
print('Found accel_x')

if __name__ == '__main__':
main()

 

and i am not able to read any data can you help us in fining a way to read raw values from channels

Outcomes