Hello, I am new in using Labjack U3, I tried to make a stream data program using labjack python. Here is my code :
o_file = "data_log.csv" import u3 import time d = u3.U3() d.configU3() try: d.streamStop() except: pass d.streamConfig(PChannels = , NChannels = , SamplesPerPacket = 1) def MeasureData(): try: for r in d.streamData(): if r is not None: if r['errors'] or r['numPackets'] != d.packetsPerRequest or r['missed']: print "error : errors = %s, numpackets = %d, missed = %s" %(r['errors'],r['numPackets'],r['missed']) break finally: pass return r def PrintData(r): chans = r['AIN0'] for c in chans: print chans d.streamStart() loop = 0 try: start = time.time() while loop < 10: with open(o_file, 'a') as f: PrintData(MeasureData()) loop+=1 f.write("%.4d %.2f s\n" %(loop, time.time() - start)) finally: d.streamStop() d.close()
The data stream run well, but at the end of run, when the python reachs d.streamStop() it returns :
if results != 0:
IndexError: list index out of range
As a result, I must unplugged and the plugged the LabJack if I want to run the same code.
Can anyone tell me why this might happen? Any suggestions how to solve this problem?