AnsweredAssumed Answered

ad9361 python binding

Question asked by nacbapat on Feb 7, 2017
Latest reply on Feb 8, 2017 by pcercuei

Hi,

Im using  ZC702 + Ad9361 twinchip. Im getting an array mismatch error in the iio.py as follows:

 

Program Code(apologies for the bad indentations):

 

import iio
from sys import argv

def main():
print('Library version: %u.%u (git tag: %s)' % iio.version)

ctx = iio.LocalContext()
for dev in ctx.devices:
new = ctx.find_device(dev.name)
new.enable = True
print "sample size" + str(new.sample_size)
print dev.name
for chan_nos in new.channels:
chan_nos.enabled = True
print "channel nos " + str(chan_nos.name)

if (dev.name == "cf-ad9361-A"):
# print new.sample_size
buffer_object = iio.Buffer(new,128,False)
print "buffer object length" + str(buffer_object._length)
values = buffer_object.read()

if __name__ == '__main__':
   main()

 

The terminal output throws the following error:

analog@analog:~$ python upload.py
Library version: 0.8 (git tag: c48c08a)
buffer object length2048
Traceback (most recent call last):
File "upload.py", line 39, in <module>
main()
File "upload.py", line 36, in main
values = buffer_object.read()
File "/usr/lib/python2.7/dist-packages/iio.py", line 482, in read
array = bytearray(end - start)
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

 

I digged into the iio.py and it seems that buffer_start() function returns a "NoneType" whereas the buffer_end() returns an "Int" type. and thus the error in the console .

 

 

In C the void* pointer is type casted into an int16_t and it works.

The same code implemented in the binding throws up the error.

1. How to fix the type casting error ?

2. Are there any configuration settings that i am missing which shall fix the change ?

 

Mit freundlichen Grüßen,

Nachiket Bapat

Outcomes