Hi Craig

Thanks for your comment.

I placed timeout to zero, but the same error keeps coming:


def _binary_read(self,size,addr,offset=0):
        """ Reads data from the IBOB in binary mode.
        Offset and size are measured in 32 bit words. ie Requesting size of
1 will return 4 bytes.
        The IBOB addresses bytes, but the size is 32bit delimited."""
#pdb.set_trace()
        num_pkts = int(numpy.ceil(size/float(127)))
print 'num_pkts', num_pkts
        output = ''
        for i in range(num_pkts):
            st_offset = (i*127)+offset
   print 'st_offset', st_offset
            request_size = numpy.min([size-(i*127),127])
   print 'request_size', request_size
            cmd = chr((0<<7) + request_size)
   print 'this is the address', addr
   request_addr = struct.pack('>L',addr+(st_offset*4))
   wr = self.ser.write(chr(128) + cmd + request_addr)
   print 'what is being written', wr
   time.sleep(0)
            output+=self.ser.read(request_size*4)
return output


Error:


length argument 71
Traceback (most recent call last):
  File "plot_auto.py", line 74, in updatefig
    inputs[input] = brd.read_uint(bram_map[input], size=n_chans)
  File "/home/rolando/poco_arte/poco/ibob_serial.py", line 96, in read_uint
    out=struct.unpack('>%iL'%size,check)
struct.error: unpack requires a string argument of length 4096



I am doing this:

I'm trying to adapt this code to my correlator design:
https://casper.berkeley.edu/svn/trunk/projects/pocketcorrelator/poco-0.0.1/

This correlator design uses iADC, while my design uses QUADC.

I'm initializing the IBOB with this script:  init_poco.py (attached), while
the original design uses this code
https://casper.berkeley.edu/svn/trunk/projects/pocketcorrelator/poco-0.0.1/scripts/init_poco.py
.

The first initializes through Ethernet Port, and the second via the Serial
Port.

Can this be the problem?

Best Regard

Rolando Paz




2015-11-12 1:32 GMT-06:00 Craig Tong <[email protected]>:

> Hi Rolando
>
> Quickly skimming your code I would guess you may be getting read timeouts
> in your _binary_read function.
>
> As a first step try setting the timeout of the serial port to zero then
> the read function should block indefinitely. If this is in fact the problem
> a better solution would to leave the timeout in place change to loop to
> iterate until you have all the data (while sizeof(output) < size) and not
> for a fixed *for i in range(num_pkts): *where some iterations are lost to
> timeouts.
>
> Kind regards
> Craig
>
> Craig Tong
> Digital Engineer
> African VLBI Network
> SKA South Africa
> +27 21 506 7300 (ext 7378) [image: SKA Logos]
>
>
>
>
>
>
>
>
>
>
> On 2015-11-12 00:02, Rolando Paz wrote:
>
> Hi
>
> If any one can give me your advices I will apreciate the help.
>
> For some reason the struct.unpack argument receives only 71 bytes, when
> should receive 4096 bytes.
>
> I placed several prints in the code.
>
>
> rolando@rolando-MS-7815:~/poco_arte$ sudo python plot_auto.py
> i4_c1024_arte.config
>
> Parsing config file i4_c1024_arte.config...OK
> Connecting to IBOB on port /dev/ttyUSB0.
> listdev
>
> Address map :
>
> <NO ADDR>  -> XSG core config
>
> <NO ADDR>  -> XSG core config
>
> 0xD0000000 -> acc_num
>
> Trying to decode address of
> 0xD0000000 -> acc_num
> 13 9 48 120 68 48 48 48 48 48 48 48 32 45 62 32 97 99 99 95 110 117 109 10
> This is the address of register or bram 3489660928
> 0xD0000100 -> ant0_sum_sq
>
> Trying to decode address of
> 0xD0000100 -> ant0_sum_sq
> 13 9 48 120 68 48 48 48 48 49 48 48 32 45 62 32 97 110 116 48 95 115 117
> 109 95 115 113 10
> This is the address of register or bram 3489661184
> 0xD0000200 -> ant1_sum_sq
>
> Trying to decode address of
> 0xD0000200 -> ant1_sum_sq
> 13 9 48 120 68 48 48 48 48 50 48 48 32 45 62 32 97 110 116 49 95 115 117
> 109 95 115 113 10
> This is the address of register or bram 3489661440
> 0xD0000300 -> ant2_sum_sq
>
> Trying to decode address of
> 0xD0000300 -> ant2_sum_sq
> 13 9 48 120 68 48 48 48 48 51 48 48 32 45 62 32 97 110 116 50 95 115 117
> 109 95 115 113 10
> This is the address of register or bram 3489661696
> 0xD0000400 -> ant3_sum_sq
>
> Trying to decode address of
> 0xD0000400 -> ant3_sum_sq
> 13 9 48 120 68 48 48 48 48 52 48 48 32 45 62 32 97 110 116 51 95 115 117
> 109 95 115 113 10
> This is the address of register or bram 3489661952
> 0xD0000500 -> ctrl_sw
>
> Trying to decode address of
> 0xD0000500 -> ctrl_sw
> 13 9 48 120 68 48 48 48 48 53 48 48 32 45 62 32 99 116 114 108 95 115 119
> 10
> This is the address of register or bram 3489662208
> 0xD0000600 -> delay_a
>
> Trying to decode address of
> 0xD0000600 -> delay_a
> 13 9 48 120 68 48 48 48 48 54 48 48 32 45 62 32 100 101 108 97 121 95 97
> 10
> This is the address of register or bram 3489662464
> 0xD0000700 -> delay_b
>
> Trying to decode address of
> 0xD0000700 -> delay_b
> 13 9 48 120 68 48 48 48 48 55 48 48 32 45 62 32 100 101 108 97 121 95 98
> 10
> This is the address of register or bram 3489662720
> 0xD0000800 -> delay_c
>
> Trying to decode address of
> 0xD0000800 -> delay_c
> 13 9 48 120 68 48 48 48 48 56 48 48 32 45 62 32 100 101 108 97 121 95 99
> 10
> This is the address of register or bram 3489662976
> 0xD0000900 -> delay_d
>
> Trying to decode address of
> 0xD0000900 -> delay_d
> 13 9 48 120 68 48 48 48 48 57 48 48 32 45 62 32 100 101 108 97 121 95 100
> 10
> This is the address of register or bram 3489663232
> 0xD0000A00 -> eq_coeff
>
> Trying to decode address of
> 0xD0000A00 -> eq_coeff
> 13 9 48 120 68 48 48 48 48 65 48 48 32 45 62 32 101 113 95 99 111 101 102
> 102 10
> This is the address of register or bram 3489663488
> 0xD0002000 -> ibob_lwip/ethlite
>
> Trying to decode address of
> 0xD0002000 -> ibob_lwip/ethlite
> 13 9 48 120 68 48 48 48 50 48 48 48 32 45 62 32 105 98 111 98 95 108 119
> 105 112 47 101 116 104 108 105 116 101 10
> This is the address of register or bram 3489669120
> <NO ADDR>  -> ibob_lwip/lwip
>
> 0xD0004000 -> ibob_lwip/macbits
>
> Trying to decode address of
> 0xD0004000 -> ibob_lwip/macbits
> 13 9 48 120 68 48 48 48 52 48 48 48 32 45 62 32 105 98 111 98 95 108 119
> 105 112 47 109 97 99 98 105 116 115 10
> This is the address of register or bram 3489677312
> <NO ADDR>  -> ibob_lwip/machdr
>
> <NO ADDR>  -> led1_sync_rnd
>
> <NO ADDR>  -> led2_sync_gen
>
> <NO ADDR>  -> led4_eq_clip
>
> <NO ADDR>  -> quadc0
>
> 0xD1000000 -> sync_gen/period
>
> Trying to decode address of
> 0xD1000000 -> sync_gen/period
> 13 9 48 120 68 49 48 48 48 48 48 48 32 45 62 32 115 121 110 99 95 103 101
> 110 47 112 101 114 105 111 100 10
> This is the address of register or bram 3506438144
> 0xD1002000 -> xengine/aa/real
>
> Trying to decode address of
> 0xD1002000 -> xengine/aa/real
> 13 9 48 120 68 49 48 48 50 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 97 97 47 114 101 97 108 10
> This is the address of register or bram 3506446336
> 0xD1004000 -> xengine/ab/imag
>
> Trying to decode address of
> 0xD1004000 -> xengine/ab/imag
> 13 9 48 120 68 49 48 48 52 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 97 98 47 105 109 97 103 10
> This is the address of register or bram 3506454528
> 0xD1006000 -> xengine/ab/real
>
> Trying to decode address of
> 0xD1006000 -> xengine/ab/real
> 13 9 48 120 68 49 48 48 54 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 97 98 47 114 101 97 108 10
> This is the address of register or bram 3506462720
> 0xD1008000 -> xengine/ac/imag
>
> Trying to decode address of
> 0xD1008000 -> xengine/ac/imag
> 13 9 48 120 68 49 48 48 56 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 97 99 47 105 109 97 103 10
> This is the address of register or bram 3506470912
> 0xD100A000 -> xengine/ac/real
>
> Trying to decode address of
> 0xD100A000 -> xengine/ac/real
> 13 9 48 120 68 49 48 48 65 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 97 99 47 114 101 97 108 10
> This is the address of register or bram 3506479104
> 0xD100C000 -> xengine/ad/imag
>
> Trying to decode address of
> 0xD100C000 -> xengine/ad/imag
> 13 9 48 120 68 49 48 48 67 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 97 100 47 105 109 97 103 10
> This is the address of register or bram 3506487296
> 0xD100E000 -> xengine/ad/real
>
> Trying to decode address of
> 0xD100E000 -> xengine/ad/real
> 13 9 48 120 68 49 48 48 69 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 97 100 47 114 101 97 108 10
> This is the address of register or bram 3506495488
> 0xD1010000 -> xengine/bb/real
>
> Trying to decode address of
> 0xD1010000 -> xengine/bb/real
> 13 9 48 120 68 49 48 49 48 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 98 98 47 114 101 97 108 10
> This is the address of register or bram 3506503680
> 0xD1012000 -> xengine/bc/imag
>
> Trying to decode address of
> 0xD1012000 -> xengine/bc/imag
> 13 9 48 120 68 49 48 49 50 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 98 99 47 105 109 97 103 10
> This is the address of register or bram 3506511872
> 0xD1014000 -> xengine/bc/real
>
> Trying to decode address of
> 0xD1014000 -> xengine/bc/real
> 13 9 48 120 68 49 48 49 52 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 98 99 47 114 101 97 108 10
> This is the address of register or bram 3506520064
> 0xD1016000 -> xengine/bd/imag
>
> Trying to decode address of
> 0xD1016000 -> xengine/bd/imag
> 13 9 48 120 68 49 48 49 54 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 98 100 47 105 109 97 103 10
> This is the address of register or bram 3506528256
> 0xD1018000 -> xengine/bd/real
>
> Trying to decode address of
> 0xD1018000 -> xengine/bd/real
> 13 9 48 120 68 49 48 49 56 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 98 100 47 114 101 97 108 10
> This is the address of register or bram 3506536448
> 0xD101A000 -> xengine/cc/real
>
> Trying to decode address of
> 0xD101A000 -> xengine/cc/real
> 13 9 48 120 68 49 48 49 65 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 99 99 47 114 101 97 108 10
> This is the address of register or bram 3506544640
> 0xD101C000 -> xengine/cd/imag
>
> Trying to decode address of
> 0xD101C000 -> xengine/cd/imag
> 13 9 48 120 68 49 48 49 67 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 99 100 47 105 109 97 103 10
> This is the address of register or bram 3506552832
> 0xD101E000 -> xengine/cd/real
>
> Trying to decode address of
> 0xD101E000 -> xengine/cd/real
> 13 9 48 120 68 49 48 49 69 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 99 100 47 114 101 97 108 10
> This is the address of register or bram 3506561024
> 0xD1020000 -> xengine/dd/real
>
> Trying to decode address of
> 0xD1020000 -> xengine/dd/real
> 13 9 48 120 68 49 48 50 48 48 48 48 32 45 62 32 120 101 110 103 105 110
> 101 47 100 100 47 114 101 97 108 10
> This is the address of register or bram 3506569216
> Grabbing spectrum number 1
> Sleeping in 1 for 2 Seconds
> This is the read address 3506446336
> num_pkts 9
> st_offset 0
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 127
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 254
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 381
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 508
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 635
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 762
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 889
> request_size 127
> this is the address 3506446336
> what is being written 6
> st_offset 1016
> request_size 8
> this is the address 3506446336
> what is being written 6
> length argument 71
> Traceback (most recent call last):
>   File "plot_auto.py", line 74, in updatefig
>     inputs[input] = brd.read_uint(bram_map[input], size=n_chans)
>   File "/home/rolando/poco_arte/poco/ibob_serial.py", line 89, in read_uint
>     out=struct.unpack('>%iL'%size,check)
> struct.error: unpack requires a string argument of length 4096
>
>
> Best Regards
>
> RP
>
>
>
#!/usr/bin/python
"""
Initialize CASPER pocket correlator
Author: Griffin Foster 
Date: 2009/09/12
"""

import sys,socket,time
import poco.poco_conf
from optparse import OptionParser

p = OptionParser()
p.set_usage('init_poco.py [options] CONFIG_FILE')
p.set_description(__doc__)

p.add_option('-v', '--verbose', dest='verbose', action='store_true',
    help='Be verbose (good for debugging)')
p.add_option('-e', '--eq', dest='flat_eq', default='',
    help='Set a flat equalization level for all eq blocks and channels')
p.add_option('-o', '--override', dest='override_list', default = '',
    help='Override options in the config file, don\'t use any whitespace, example: -o n_chans=32,n_ants=8')

opts, args = p.parse_args(sys.argv[1:])

if args==[]:
    print 'Please specify a configuration file! \nExiting.'
    exit()

config = poco.poco_conf.CorrConf(args[0])
config_status = config.read_all()
print '\nParsing config file %s...%s'%(args[0],config_status)
sys.stdout.flush()
if not config_status == 'OK': exit()

print '\nWriting override variables...',
if not opts.override_list == '':
    oride = opts.override_list.split(',')
    for o in oride:
        oname = o.split('=')[0]
        ovalue = o.split('=')[1]
        if oname in ['fft_shift','rx_ip_address','ibob_ip']: config[oname] = ovalue
        else: config[oname] = int(ovalue)
print 'OK'

brd = poco.ibob_serial.IbobClient(config['connection']['port'])
fft_shift = int(config['fft_shift'],16)
n_chans = config['eq_chans']
acc_len = config['acc_len']
rx_ip_address = config['rx_ip_address']
udp_port = config['udp_port']
auto_eq = config['auto_eq']
eq_blocks = config['eq_blocks']
ibob_ip = config['ibob_ip']

HOST = ibob_ip
PORT = 23
print '\nConnecting to iBOB...',
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
print 'OK'
s.send("regwrite ctrl_sw %s\n" % fft_shift)
time.sleep(.1)
s.send("regread ctrl_sw\n")
time.sleep(.1)
s.send("regwrite sync_gen/period %i\n" % acc_len)
time.sleep(.1)
s.send("regread sync_gen/period\n")
time.sleep(.1)
if opts.verbose is True:
    print("regwrite ctrl_sw %s" % fft_shift)
    print("regwrite sync_gen/period %i" % acc_len)

# eq_coeff: bits 0-16
# coeff_en: bit 17
# coeff_addr: bits 20-26
# eq_sel: bits 30-31
for b in range(eq_blocks):
    if not opts.flat_eq == '': eq_level = int(opts.flat_eq)
    else: eq_level = config['eq']['eq_polys'][b][0]
    for c in range(n_chans):
        eq_coeff = b
        
        #shift 10 bits
        eq_coeff *= 2**10
        eq_coeff += c
        
        #shift 3 bits
        eq_coeff *= 2**3
        eq_coeff += 1
        
        #shift 17 bits
        eq_coeff *= 2**17
        eq_coeff += eq_level
        if opts.verbose is True: print 'EQ Block: %i Channel: %i EQ Level: %i' % (b,c,eq_level)
        s.send("regwrite eq_coeff %i\n"% eq_coeff)
        time.sleep(.1)
        s.send("regread eq_coeff\n")
        #print("regwrite eq_coeff %i\n"% eq_coeff)
        time.sleep(.1)
        #print("regread eq_coeff\n")

"""
eq poly
auto eq

[equalisation]
#Starting point for auto-equalization or values for manual eq programming.
#One line entry per antenna. Item is a list of polynomial coefficients.
#Eg,
#EQ_poly_0 = 10, 30 ,40
#corresponds to 10 + 30x^2 + 40x^4
EQ_poly_0 = 1
EQ_poly_1 = 1
EQ_poly_2 = 1
EQ_poly_3 = 1"""

rx_ip_address = rx_ip_address.replace('.',' ')
s.send("startudpdump %s %i\n" % (rx_ip_address, udp_port))
if opts.verbose is True: print("startudpdump %s %i\n" % (rx_ip_address, udp_port))
s.close()

Reply via email to