Ah, thanks Glenn! I should have figured that out... Dale
On Mon, Jun 10, 2013 at 1:46 PM, G Jones <[email protected]> wrote: > I think this is a common thing run into: it takes a moment for the > FpgaClient to actually connect to the ROACH and this happens in the > background. The FpgaClient instance is returned immediately, and if > you try to talk to the ROACH too soon, it will complain about not > being connected. > In my opinion, the proper thing to do is to use the .is_connected() > method to see when it gets connected. I.e. something like: > > tic = time.time() > while (time.time() - tic < timeout): > if fpga[-1].is_connected(): > break > time.sleep(0.01) > else: > print "fpga connection timed out" > > Glenn > > On Mon, Jun 10, 2013 at 9:40 AM, Gary, Dale E. <[email protected]> > wrote: > > Hi All, > > > > This may be a Python question rather than a CASPER/KATCP one, but I have > not > > been able to solve it. I am trying to connect to multiple ROACHes in > order > > to write delays to the coarse delay registers once per second. I > attempted > > to do the following (minimal code that displays the bug) to check the > > availability of each ROACH, and this works fine when typed into an > > interactive session, but when used in a program it fails with a "Client > not > > connected" error. > > > > roach_ip = ('roach1.solar.pvt','roach2.solar.pvt') > > fpga = [] > > for roach in roach_ip: > > # Make connection to ROACHes > > fpga.append( corr.katcp_wrapper.FpgaClient(roach) ) > > fpga[-1].ping() > > > > I am guessing that the difference is that something goes awry when run as > > compiled code. Still, this must be a fairly common thing to do. I could > > get around this by just connecting to each client once a second, sending > the > > delay values, and disconnecting, but this seems unnecessary overhead > > compared with maintaining the open connection all of the time. > > > > Can someone suggest a fix, or a better method for what I want to do? > > > > Thanks, > > Dale >

