Code-And-Go Goes From No-Go to Bingo!
Below is the bootload sequence for the 1802 Olduino. The top line is RTS which resets the olduino. First you see RTS cycle a couple of times due to the MODE command. Then you see RX and TX going as the bootloader runs. Finally, two seconds after the RX activity stops, you see TX running as the 1802 prints “Hello World”.
MODE com3: rts=on >NUL
AVRDUDE -CC:\…/avrdude.conf -u -V -D -patmega644p -cstk500v1 -P\\.\COM3 -b57600 -U flash:w:%1.hex:i %2 %3
Next is what should be the equivalent sequence for the Olduino/Z (although it’s still connected to the 1802). Here you see RTS cycle then it goes low for the full duration of the xmodem transfer(which doesn’t actually happen) then go high again. You see the 1802 sending the “Hello..” sequence near the beginning and again after RTS comes high. This is not what I want.
MODE com3: rts=on >NUL
Then is the trace of just doing a pyserial open and close – this is clearly what is lowering and raising the RTS line. I need to deal with that or move away from python.
port = serial.Serial(port=’COM3′, parity=serial.PARITY_NONE,
And Bingo! Thanks to an answer on Stack Overflow I modified the python serial open sequence to stop it activating RTS. The result seems perfect. You see the RTS cycle at first, then the XMODEM load sequence, then the Hello World app gets run so the TX line shows activity again.
import logging logging.basicConfig() import serial try: from cStringIO import StringIO except: from StringIO import StringIO from xmodem import XMODEM, CRC from time import sleep import os fileSize=os.path.getsize('C:\\Users\\bill\\Documents\\olduinoz\\z88dk\\helloworld\\a_code.bin') print "File Size is",fileSize def getc(size, timeout=1): return port.read(size) xCount=0 def putc(data, timeout=1): global xCount xCount=xCount+1 port.write(data) print("TX# %d(%d)" % (xCount,len(data))) sleep(0.001) # give device time to send ACK #Main program starts here - define the serial port, set RTS off, then open it port = serial.Serial(parity=serial.PARITY_NONE, bytesize=serial.EIGHTBITS, stopbits=serial.STOPBITS_ONE,timeout=5,xonxoff=0, rtscts=0,dsrdtr=0,baudrate=9600) port.rts=False port.port='COM3' port.open() #open the file to be loaded stream = open('C:\\Users\\bill\\Documents\\olduinoz\\z88dk\\helloworld\\a_code.bin','rb') #transfer the file result=XMODEM(getc, putc).send(stream, quiet = 1) #close the file stream.close() #close the port port.close() if result: print "transfer successful" else: print "transfer unsuccessful"