if (not file_path): print "no file selected" sys.exit(0) file_size = os.path.getsize(file_path) print("file size = " + str(file_size)) if (file_size == 0): sys.exit(0) if ((file_size & 0x01) != 0): print "WARNING! File size is odd. " + str( file_size + 1) + " bytes will be sent instead." f = open(file_path, 'rb') if (f == None): print "can not open file." sys.exit(0) data = bytearray(f.read()) f.close() if ((len(data) & 0x01) != 0): data.append(0x5A) if (put_buffer(ser, data) == 0): sys.exit(0) usb2io_sendcmd(ser, "service serial bufsend " + str(len(data) / 2) + "\r\n") raw_input("Press Enter to exit...")
'type': "ext", "id": 0x12345678, "data": "0xBE, 0xEF, 0xCA, 0xFE" }) tx_messages.append({'type': "ext", "id": 0x1F7, "data": "0x03,0x04, 0x05"}) tx_messages.append({ 'type': "ext", "id": 0x12345678, "data": "0xBE, 0xEF, 0xCA, 0xFE" }) tx_array = serialize_messages(tx_messages) if (tx_array == None): sys.exit(0) #use put_buffer to send messages to uC if (put_buffer(ser, tx_array) == 0): sys.exit(0) # send messages from buffer and wait for RX_TIMEOUT for received messages wro = ser.write("fdcan buffer " + str(len(tx_messages)) + ", " + str(TRX_TIMEOUT) + "\r\n") #wait for finish done = 0 rrd = str() while (done == 0): rrd = ser.readline() if (rrd != ''): print(rrd) done = 1 else:
data[34] = 0; data[35] = 0; data[36] = 1; data[37] = 0; data[38] = 1; data[39] = 0; for i in range (4, segment_size): data[40 + i] = 0; # send to target print("Sending buffer...") if (put_buffer(ser, data) == 0): sys.exit(0) print("Config wfg...") rrd = usb2io_sendcmd(ser, "waveform gen configure\r\n") if (rrd != 'OK\r\n'): sys.exit(0) print("Starting wfg...") wro = ser.write("waveform gen start\r\n") time.sleep(0.1) rrd = ser.readline() print(rrd)
#the waveform, bit[0] matters data[32] = 0 data[33] = 0 data[34] = 0 data[35] = 0 data[36] = 4 data[37] = 0 data[38] = 4 data[39] = 0 # send to target print("Sending buffer...") if (put_buffer(ser, data) == 0): sys.exit(0) print("Config wfg...") wro = ser.write("waveform gen configure\r\n") time.sleep(0.1) rrd = ser.readline() print(rrd) if (rrd != 'OK\r\n'): sys.exit(0) print("Starting wfg...") wro = ser.write("waveform gen start\r\n") time.sleep(0.1) rrd = ser.readline()
AddCommand(buffer, 0xad) #/* master configuration */ AddCommand(buffer, 0x8e) #/* external vcc supply */ AddCommand(buffer, 0xc8) #/* set com scan direction */ AddCommand(buffer, 0xd3) #/* set display offset */ AddCommand(buffer, 0x40) # AddCommand(buffer, 0xd5) #/* set display clock divide/oscillator frequency */ AddCommand(buffer, 0xf0) # AddCommand(buffer, 0xD8) #/*set area color mode off */ AddCommand(buffer, 0x05) # AddCommand(buffer, 0xD9) # AddCommand(buffer, 0xF1) # AddCommand(buffer, 0xda) #/* set com pin configuartion */ AddCommand(buffer, 0x12) # AddCommand(buffer, 0x91) # AddCommand(buffer, 0x3F) # AddCommand(buffer, 0x3F) # AddCommand(buffer, 0x3F) # AddCommand(buffer, 0x3F) # AddCommand(buffer, 0xaf) # /* set display on */ # send buffer to uC SDRAM if (put_buffer(ser, buffer) == 0): sys.exit(0) usb2io_sendcmd(ser, "lcd fpga buffer write " + str(len(buffer) / 2) + "\r\n") ser.close() print "Done" raw_input("Press Enter to exit ...")
data[32] = 0; data[33] = 0; data[34] = 0; data[35] = 0; data[36] = 1; data[37] = 0; data[38] = 1; data[39] = 0; # send to target print("Sending buffer...") if (put_buffer(ser, data) == 0): sys.exit(0) print("Config wfg...") wro = ser.write("waveform gen configure\r\n") time.sleep(0.1) rrd = ser.readline() print(rrd) if (rrd != 'OK\r\n'): sys.exit(0) print("Starting wfg...") wro = ser.write("waveform gen start\r\n") time.sleep(0.1)
#the waveform, bit[0] matters data[32] = 0 data[33] = 0 data[34] = 0 data[35] = 0 data[36] = 1 data[37] = 0 data[38] = 1 data[39] = 0 # send to target print("Sending buffer...") if (put_buffer(ser, data) == 0): sys.exit(0) print("Config wfg...") wro = ser.write("waveform gen configure\r\n") time.sleep(0.1) rrd = ser.readline() print(rrd) if (rrd != 'OK\r\n'): sys.exit(0) print("Starting wfg...") wro = ser.write("waveform gen start\r\n") time.sleep(0.1) rrd = ser.readline()
sys.exit(0) usb2io_sendcmd(ser, "hello\r\n") print "Preparing data..." src = bytearray(data_cnt) dest = bytearray(data_cnt) for i in range(0, data_cnt): src[i] = random.randrange(256) # send to target print("Sending buffer...") print("len = " + str(len(src))) if (put_buffer(ser, src) == 0): print("Failed.") sys.exit(0) # get buffer print("Reading...") (status, data_out) = get_buffer(ser, data_cnt) print "get_buffer return status: %r" % status dest[0:data_cnt] = data_out print("Compare...") errCnt = 0 for i in range(0, data_cnt): if (dest[i] != src[i]):
#the waveform, bit[0] matters data[32] = 0 data[33] = 0 data[34] = 0 data[35] = 0 data[36] = 1 data[37] = 0 data[38] = 1 data[39] = 0 # send to target print("Sending buffer...") if (put_buffer(ser, data) == 0): sys.exit(0) print("Config wfg...") wro = ser.write("waveform gen configure\r\n") time.sleep(0.1) rrd = ser.readline() print(rrd) if (rrd != 'OK\r\n'): sys.exit(0) print("Starting wfg...") wro = ser.write("waveform gen start\r\n") time.sleep(0.1) rrd = ser.readline()