import serial import time import binascii sleep_time = 0.1 #per iMDF protocol, this is the down time between packets time_to_run = 60*5 #60 seconds * 5 Min = 300 seconds to run for_range = time_to_run/sleep_time #iteration number of times throug the for-loop ser = serial.Serial()#Create a serial object ser.baudrate = 19200 #baudrate ser.xonxoff = False #software flow contro is off #Using com0com, I emulated 2 comports, COM4 and COM5. #Emulated comports are set up as COM5 -> COM4. Anything written to COM5 can be read from COM4 ser.port = 'COM5' #change this to w/e you need ser.timeout = 1 #something data = '80000000013700120009240019000125001A000F2840' #data coming from SM-AFR module in ascii data2 = binascii.unhexlify(((str(data))))# ASCII value to ASCII number conversion. print ser #Display serial configuration ser.open() #open connection ser.send_break() #send a break for fun print "Press Enter to Start Sending Data" #allows the user to set up stuff before starting the sending of data raw_input() #wait for a button press print "sending data lenght:", len(data2) for i in range (0, int(for_range)): bytes = ser.write(data2) print "sent: ", bytes, " bytes" time.sleep(sleep_time)