Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TerminalPython
==============

Simple Terminal interface written in Python. There is one script that works for both the W65C134SXB and W65C265SXB. This is meant to give a simple interface that the user can customize for their needs. This make the terminal interface much nicer then the default HyperTerm style terminal.
Simple Terminal interface written in Python. There is one script that works for both the W65C134SXB and W65C265SXB. This is meant to give a simple interface that the user can customize for their needs. This makes the terminal interface much nicer than the default HyperTerm style terminal.
153 changes: 88 additions & 65 deletions TerminalPython.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,88 @@
##Simple Python Script that will interface with WDC's W65C134SXB and W65C265SXB Boards.
##You can use this as a start to customize the interface for your needs.
##NOTE: Change Line 14 to have the proper COM port or it will not work!
##import serial lib
import msvcrt
import serial
import io
import time

##open serial port
print ("Welcome to WDC's 65xx Serial Monitor in Python");
print ("Press the reset button on your board to start reading serial data from the board");
## For now the Serial Port Needs to be set manually. Change the line below to your COMXX port
ser = serial.Serial("COM74", 9600,timeout=1)
ser.flushInput()
ser.flushOutput()
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
readser = 1
#while loop to read in serial data
#line will autofeed if reset is not pushed at beginning
while readser == 1:
hello = sio.readline()
#testing
#
if hello:
if "Copyright 1995" in hello:
hello = hello.replace("1995", "1995-2014"); ##Just an example of replacing text. Not needed.
print hello;
elif hello.strip() == '>':
readser = 0
print ("Enter a command. For a list of commands press h");
print hello;
writedata = msvcrt.getch()
ser.write(writedata)
readser = 1
elif "BB:AAAA" in hello:
readser = 0
print hello;
print ("Type in a 2 digit Bank Address - Press Enter");
writedata = raw_input()
if len(writedata) == 2:
ser.write(writedata)
readser = 1
else:
print ("Please re-enter the 2 digit hex Bank Address and press enter");
writedata = raw_input()
readser = 1
elif hello.endswith(':'):
readser = 0
print hello;
print ("Type in a 4 digit Address - Press Enter");
writedata = raw_input()
if len(writedata) == 4:
ser.write(writedata)
readser = 1
else:
print ("Please re-enter the 4 digit hex address and press enter");
writedata = raw_input()
readser = 1
else:
print hello;

##close serial connection
ser.close()
print ("Closing out!");
##Simple Python Script that will interface with WDC's W65C134SXB and W65C265SXB Boards.
##You can use this as a start to customize the interface for your needs.
##NOTE: Change Line 14 to have the proper COM port or it will not work!
## Updated for Python 3: change print statements to print functions
## Added recognition for W65C134SXB prompt of '.'
## Removed extra linefeeds from output
##import serial lib
##import msvcrt
import serial
import io
import time

try:
from msvcrt import getch
except ImportError:
''' we're not on Windows, so we try the Unix-like approach '''

def getch():
import sys
import tty
import termios
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(fd)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch

##open serial port
print("Welcome to WDC's 65xx Serial Monitor in Python")
print("Press the reset button on your board to start reading serial data from the board")
## For now the Serial Port Needs to be set manually. Change the line below to
## your COMXX port
ser = serial.Serial("COM79", 9600, timeout=1)
ser.flushInput()
ser.flushOutput()
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
readser = 1
#while loop to read in serial data
#line will autofeed if reset is not pushed at beginning
while readser == 1:
hello = sio.readline()
#testing
#
if hello:
if "Copyright 1995" in hello:
hello = hello.replace("1995", "1995-2014") ##Just an example of replacing text. Not needed.
print(hello.rstrip())
# The W65C134SXB uses '.' for it's Monitor ROM prompt
elif (hello.strip() == '>' or hello.strip() == '.'):
readser = 0
print("Enter a command. For a list of commands press h")
print(hello.rstrip())
writedata = getch()
ser.write(writedata)
readser = 1
elif "BB:AAAA" in hello:
readser = 0
print(hello.rstrip())
print("Type in a 2 digit Bank Address - Press Enter")
writedata = raw_input()
if len(writedata) == 2:
ser.write(writedata)
readser = 1
else:
print("Please re-enter the 2 digit hex Bank Address and press enter")
writedata = raw_input()
readser = 1
elif hello.endswith(':'):
readser = 0
print(hello.rstrip())
print("Type in a 4 digit Address - Press Enter")
writedata = raw_input()
if len(writedata) == 4:
ser.write(writedata)
readser = 1
else:
print("Please re-enter the 4 digit hex address and press enter")
writedata = raw_input()
readser = 1
else:
print(hello.rstrip())

##close serial connection
ser.close()
print("Closing out!")