|
| 1 | +##Simple Python Script that will interface with WDC's W65C134SXB and W65C265SXB Boards. |
| 2 | +##You can use this as a start to customize the interface for your needs. |
| 3 | +##NOTE: Change Line 14 to have the proper COM port or it will not work! |
| 4 | +##import serial lib |
| 5 | +import msvcrt |
| 6 | +import serial |
| 7 | +import io |
| 8 | +import time |
| 9 | + |
| 10 | +##open serial port |
| 11 | +print ("Welcome to WDC's 65xx Serial Monitor in Python"); |
| 12 | +print ("Press the reset button on your board to start reading serial data from the board"); |
| 13 | +## For now the Serial Port Needs to be set manually. Change the line below to your COMXX port |
| 14 | +ser = serial.Serial("COM74", 9600,timeout=1) |
| 15 | +ser.flushInput() |
| 16 | +ser.flushOutput() |
| 17 | +sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser)) |
| 18 | +readser = 1 |
| 19 | +#while loop to read in serial data |
| 20 | +#line will autofeed if reset is not pushed at beginning |
| 21 | +while readser == 1: |
| 22 | + hello = sio.readline() |
| 23 | + #testing |
| 24 | + # |
| 25 | + if hello: |
| 26 | + if "Copyright 1995" in hello: |
| 27 | + hello = hello.replace("1995", "1995-2014"); ##Just an example of replacing text. Not needed. |
| 28 | + print hello; |
| 29 | + elif hello.strip() == '>': |
| 30 | + readser = 0 |
| 31 | + print ("Enter a command. For a list of commands press h"); |
| 32 | + print hello; |
| 33 | + writedata = msvcrt.getch() |
| 34 | + ser.write(writedata) |
| 35 | + readser = 1 |
| 36 | + elif "BB:AAAA" in hello: |
| 37 | + readser = 0 |
| 38 | + print hello; |
| 39 | + print ("Type in a 2 digit Bank Address - Press Enter"); |
| 40 | + writedata = raw_input() |
| 41 | + if len(writedata) == 2: |
| 42 | + ser.write(writedata) |
| 43 | + readser = 1 |
| 44 | + else: |
| 45 | + print ("Please re-enter the 2 digit hex Bank Address and press enter"); |
| 46 | + writedata = raw_input() |
| 47 | + readser = 1 |
| 48 | + elif hello.endswith(':'): |
| 49 | + readser = 0 |
| 50 | + print hello; |
| 51 | + print ("Type in a 4 digit Address - Press Enter"); |
| 52 | + writedata = raw_input() |
| 53 | + if len(writedata) == 4: |
| 54 | + ser.write(writedata) |
| 55 | + readser = 1 |
| 56 | + else: |
| 57 | + print ("Please re-enter the 4 digit hex address and press enter"); |
| 58 | + writedata = raw_input() |
| 59 | + readser = 1 |
| 60 | + else: |
| 61 | + print hello; |
| 62 | + |
| 63 | +##close serial connection |
| 64 | +ser.close() |
| 65 | +print ("Closing out!"); |
0 commit comments