Packing byte fields and an array object into struct

2013-11-13 Thread krishna2prasad
Hello, I am trying to build a structure to be passed down to an I2C device driver. The driver expects a struct that has a data array of size 512 bytes among other things. This is my code - rd_wr = 0x0 # Read operation i2c_addr= addr mux = mux_sel multi_len

Re: Packing byte fields and an array object into struct

2013-11-13 Thread krishna2prasad
Correction in the last input line... In [16]: result = struct.unpack('5p', os_inst[11:16]) --- error Traceback (most recent call last) ipython-input-16-42b59e00d5af in module() 1

Re: Packing byte fields and an array object into struct

2013-11-13 Thread krishna2prasad
Thanks for your reply Ned! I tried this your suggestion and this is what it complains... os_inst_bytes = struct.pack('7BI512s', 0, 0x51, 0x10, 5, 0, 0xD, 0x80, 0, '') --- error Traceback

Illegal seek error with seek() and os.lseek()

2013-05-14 Thread krishna2prasad
I am trying to use os.open() and os.lseek() methods to operate on a device file in Linux. My code goes something like this - # first, open the file as a plain binary try: self.file = open(/dev/relpcfpga, r+b, buffering=0) except IOError: raise IOError ('Failed to open.') #