jrlen balane wrote: [from further down in the message] > could somebody out there help me.
You could try helping yourself. Insert some print statements at salient points. [see examples below; you'll need to get the indentation correct, of course] Try to understand what is happening. > ok heres the code, i'm trying on IDLE: > > import sys > import serial > import sys, os > import serial > import string > import time > from struct import * > > data_file = open('C:/Documents and Settings/nyer/Desktop/IRRADIANCE.txt', 'r') > data = data_file.readlines() > > def process(list_of_lines): > data_points = [] > for line in list_of_lines: > data_points.append(int(line)) > return data_points > > irradiance = process(data) > > ser = serial.Serial() > ser.baudrate = 9600 > ser.port = 0 > ser I'll ask, for the 3rd time, what the @#$% is the above line meant to achieve? > > ser.open() > tx_command = 67 > tx_no_databyte = 2 > tx_message_no = 1 > tx_len = len (irradiance) > > for j in range (tx_len) : > start_time = time.time() > > temp1 = [] > temp2 = [] > pyra1 = [] > pyra2 = [] > voltage = [] > current = [] > > current_time = time.time() print 'before while stmt', j, start_time, current time > > while( current_time >= start_time + 300): > print 'inside while stmt', j, start_time, current time > data_hi, data_lo = divmod(irradiance[j], 0x100) > tx_checksum = -(data_hi + data_lo + tx_command + tx_message_no > + tx_no_databyte) & 0xff > ser.write(pack('6B', tx_command, tx_message_no, > tx_no_databyte, data_lo, data_hi, tx_checksum)) > > rx_data = ser.read(19) > rx_len = len(rx_data) > byte = [ord(x) for x in rx_data] > > if rx_len < 10: > #print 'it is not pumping data out as fast as we assumed' > sys.exit(1) > > for k in range (rx_len-9): > if byte[k] == 70 and byte [k+2] == 6 and sum(byte[k:k+10]) > & 0xff == 0: > #print byte[k:k+10] > > temp1.append(byte[k+3]) > temp2.append(byte[k+4]) > pyra1.append(byte[k+5]) > pyra2.append(byte[k+6]) > voltage.append(byte[k+7]) > current.append(byte[k+8]) > print temp1, temp2, pyra1, pyra2, voltage, current > > current_time = time.time() print 'after while stmt', j, start_time, current time > > while theres no error in the output, there is also no response from > the hardware or maybe communication is off. > -- http://mail.python.org/mailman/listinfo/python-list