Skip to content

Commit

Permalink
Serial interface working
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Robson committed Jan 25, 2024
1 parent 1864fa5 commit 227a9b2
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ DOCDIR = documents$(S)release$(S)
DOCUMENTS = $(DOCDIR)*.pdf $(DOCDIR)*.txt $(BINDIR)neo6502.inc
BINARIES = $(BINDIR)*.uf2 $(BINDIR)*.elf $(ROOTDIR)emulator$(S)cross-compile$(S)neowin.zip $(BINDIR)basic.bin \
$(ROOTDIR)emulator$(S)neolinux.zip
PYTHONAPPS = $(BINDIR)makebasic.zip $(BINDIR)listbasic.zip $(BINDIR)createblanks.zip $(BINDIR)makeimg.zip
PYTHONAPPS = $(BINDIR)makebasic.zip $(BINDIR)listbasic.zip $(BINDIR)createblanks.zip $(BINDIR)makeimg.zip \
$(BINDIR)nxmit.zip

# ***************************************************************************************
#
Expand Down Expand Up @@ -76,6 +77,7 @@ linux:
make -B -C emulator clean
make -B -C emulator elinux


# ***************************************************************************************
#
# Clean everything
Expand Down
3 changes: 2 additions & 1 deletion documents/release/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ Changes
IMP: Serial link to hardware alive at 460800 baud.
BUG: Fixed bug in maths test suite

25/01/24 IMP: Can send programs,data and commands over serial link
25/01/24 IMP: Can send programs,data and commands over serial link.
*** Release 10 ***
6 changes: 6 additions & 0 deletions firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ dual: prelim always
rm -Rf build
make -B clean
make -C build

pythonapps:
$(CMAKEDIR) build
$(CCOPY) scripts$(S)nxmit.py build$(S)__main__.py
zip -j $(BINDIR)nxmit.zip build$(S)__main__.py
$(CDEL) build$(S)*.py

# ***************************************************************************************
#
Expand Down
2 changes: 1 addition & 1 deletion firmware/common/include/data/prompt.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
// This file is automatically generated
//
#define PROMPT "(Build 2378 25-Jan-24)\r"
#define PROMPT "(Build 2380 25-Jan-24)\r"
6 changes: 3 additions & 3 deletions firmware/common/include/data/sfxdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ static const uint16_t sfxData18[] = {
740,75,0,50,740,75,0,50,740,75,0,50,740,75,0,50,65535 };
// 19 expl100
static const uint16_t sfxData19[] = {
408,1,408,1,368,1,657,1,643,1,386,1,572,1,595,1,342,1,403,1,338,1,423,1,581,1,356,1,332,1,248,1,321,1,338,1,587,1,215,1,501,1,414,1,441,1,428,1,265,1,678,1,436,1,526,1,439,1,607,1,310,1,289,1,679,1,252,1,380,1,380,1,532,1,475,1,580,1,265,1,403,1,553,1,643,1,209,1,586,1,288,1,559,1,375,1,368,1,283,1,65535 };
282,1,557,1,520,1,646,1,227,1,485,1,536,1,356,1,637,1,542,1,294,1,294,1,674,1,637,1,289,1,484,1,333,1,326,1,662,1,355,1,311,1,685,1,389,1,521,1,584,1,572,1,281,1,690,1,450,1,420,1,377,1,264,1,213,1,408,1,337,1,633,1,539,1,223,1,339,1,300,1,394,1,388,1,669,1,586,1,387,1,227,1,208,1,417,1,203,1,296,1,65535 };
// 20 expl50
static const uint16_t sfxData20[] = {
534,1,497,1,691,1,474,1,259,1,421,1,321,1,654,1,700,1,448,1,323,1,386,1,317,1,302,1,671,1,441,1,303,1,658,1,415,1,597,1,516,1,381,1,695,1,209,1,480,1,65535 };
536,1,488,1,590,1,401,1,447,1,276,1,680,1,341,1,587,1,525,1,573,1,287,1,332,1,531,1,337,1,320,1,380,1,585,1,608,1,512,1,321,1,584,1,540,1,493,1,448,1,65535 };
// 21 expl20
static const uint16_t sfxData21[] = {
498,1,212,1,516,1,531,1,700,1,556,1,534,1,377,1,253,1,412,1,65535 };
620,1,344,1,211,1,317,1,566,1,208,1,444,1,682,1,322,1,603,1,65535 };
// 22 las30
static const uint16_t sfxData22[] = {
600,1,574,1,547,1,520,1,494,1,467,1,440,1,414,1,387,1,360,1,334,1,307,1,280,1,254,1,227,1,65535 };
Expand Down
Binary file modified firmware/common/sources/interface/dispatch.o
Binary file not shown.
Binary file modified firmware/common/sources/interface/sfxmanager.o
Binary file not shown.
66 changes: 59 additions & 7 deletions firmware/scripts/nxmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,71 @@ def transmitDataBlock(self,data):
self.transmit([1]+data[:count]) # Append command 1, data transmit and send it
data = data[count:] # Trim from data
packets += 1 # Bump packet count.
print("Sent {0} bytes in {1} packets.".format(size,packets))
print("\tSent {0} bytes in {1} packets.".format(size,packets))
#
# Insert the given string in the keyboard queue (use chr(13) for return)
# Insert the given string in the keyboard queue (use ! for return)
#
def transmitString(self,s):
s = s.replace("!",chr(13))
for c in s: # Send all character in turn.
self.transmit([5,ord(c)])
#
# Send a file to 6502 memory.
#
def transmit6502File(self,fileName,loadAddress,loadIndirect = False):
self.transmit([4 if loadIndirect else 2, # 4 is address indirect, 2 is address
loadAddress & 0xFF,loadAddress >> 8])
self._transmitFile(fileName)
#
# Send a BASIC program *MUST* be tokenised
#
def transmitBASICCode(self,fileName):
self.transmit6502File(fileName,0x820,True) # In BASIC $820/1 holds PAGE.
#
# Load a file to graphics memory
#
def transmitGraphicFile(self,fileName):
self.transmit([3,0,0]) # 3 sends to graphic memory.
self._transmitFile(fileName)
#
# Transmit a file.
#
def _transmitFile(self,file):
print("Sending file {0}".format(file))
self.transmitDataBlock([x for x in open(file,"rb").read(-1)])

# ***************************************************************************************
#
# A simple command line driven application
#
# ***************************************************************************************

if __name__ == "__main__":
si = SerialInterface('/dev/ttyUSB0')
si.transmit([4,32,8])
d = [x for x in open("../basic/build/tokenised.dat","rb").read(-1)]
si.transmitDataBlock(d)
si.transmitString("RUN"+chr(13))
if len(sys.argv) < 2:
print("python nxmit.zip <port> <cmd list>")
print("\t<port> is COM1 or /dev/ttyUSB0 or similar.")
print("\tCommands supported are :")
print("\t\tB:<file>\t\tloads <file> as BASIC")
print("\t\tG:<file>\t\tloads <file> into Graphic Memory")
print("\t\tF:<file>@<hex>\tLoads <file> into CPU Memory at address <hex>")
print("\t\tK:<text>\t\tPush text into keyboard buffer. Use ! for return")
sys.exit(1)

serial = SerialInterface(sys.argv[1])
for cmd in sys.argv[2:]:
if cmd.startswith("b:"):
serial.transmitBASICCode(cmd[2:])
elif cmd.startswith("g:"):
serial.transmitGraphicFile(cmd[2:])
elif cmd.startswith("f:"):
cmd = cmd[2:].split("@")
serial.transmit6502File(cmd[0],int(cmd[1],16),False)
elif cmd.startswith("k:"):
serial.transmitString(cmd[2:])
else:
print("Unknown command "+cmd)
sys.exit(1)




0 comments on commit 227a9b2

Please sign in to comment.