From 227a9b237410269cc5202e65cf5d1c99199b7b5a Mon Sep 17 00:00:00 2001 From: Paul Robson Date: Thu, 25 Jan 2024 11:36:33 +0000 Subject: [PATCH] Serial interface working --- Makefile | 4 +- documents/release/Changelog.txt | 3 +- firmware/Makefile | 6 ++ firmware/common/include/data/prompt.h | 2 +- firmware/common/include/data/sfxdata.h | 6 +- firmware/common/sources/interface/dispatch.o | Bin 15776 -> 15776 bytes .../common/sources/interface/sfxmanager.o | Bin 5072 -> 5072 bytes firmware/scripts/nxmit.py | 66 ++++++++++++++++-- 8 files changed, 74 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index f888bbf3..8e6f9ca6 100644 --- a/Makefile +++ b/Makefile @@ -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 # *************************************************************************************** # @@ -76,6 +77,7 @@ linux: make -B -C emulator clean make -B -C emulator elinux + # *************************************************************************************** # # Clean everything diff --git a/documents/release/Changelog.txt b/documents/release/Changelog.txt index 2d92057c..f6a5b1e2 100644 --- a/documents/release/Changelog.txt +++ b/documents/release/Changelog.txt @@ -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 \ No newline at end of file +25/01/24 IMP: Can send programs,data and commands over serial link. + *** Release 10 *** \ No newline at end of file diff --git a/firmware/Makefile b/firmware/Makefile index 9fc24256..50375b2d 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -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 # *************************************************************************************** # diff --git a/firmware/common/include/data/prompt.h b/firmware/common/include/data/prompt.h index 1f49a174..259db422 100644 --- a/firmware/common/include/data/prompt.h +++ b/firmware/common/include/data/prompt.h @@ -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" diff --git a/firmware/common/include/data/sfxdata.h b/firmware/common/include/data/sfxdata.h index eaa796e8..e6a5516b 100644 --- a/firmware/common/include/data/sfxdata.h +++ b/firmware/common/include/data/sfxdata.h @@ -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 }; diff --git a/firmware/common/sources/interface/dispatch.o b/firmware/common/sources/interface/dispatch.o index 4e72ab62d97789af6907b864cdb0074abd5bd613..1687487e33e75424649d35a89aabe931e8243d9c 100644 GIT binary patch delta 15 WcmZ2by`Xx7CO?yf!Dem#Qau1K<^>r5 delta 15 WcmZ2by`Xx7CO?z8*=BA2Qau1L0|g!c diff --git a/firmware/common/sources/interface/sfxmanager.o b/firmware/common/sources/interface/sfxmanager.o index e8ba6e5c6e35d24f2bb92d781dc7f03e150d0b1e..952a359f56695c4139e5d4005c83049f2f97431f 100644 GIT binary patch delta 361 zcmWmAzbi#?7{~GRJ$JbVr5IdSZWhPD%HkG=+x0V&QWj$L58NW;$6(VfStK$@DX}WD zT29GKp)CFfukY~g{rNnddY7*zNn*pU;lAnu3SuB?O2gso$?aAyf&QdVlG8Sum!EVoY=0tW`LgSfnGI3s+w$3Nj18)d{d6#2*N$y=S!2fY zsBFtc;$PL+GP{@Kl!;#(kWKmf|D^@J!XY1KBlhvS6?sQ|FJAwszjB#|x#U~vGmIy` j>u1E@j;Fntb?d9d6Y6G7TAq8T>N~RKl>VE&(o*jqyhb%N diff --git a/firmware/scripts/nxmit.py b/firmware/scripts/nxmit.py index a780afd8..35681bcb 100644 --- a/firmware/scripts/nxmit.py +++ b/firmware/scripts/nxmit.py @@ -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 ") + print("\t is COM1 or /dev/ttyUSB0 or similar.") + print("\tCommands supported are :") + print("\t\tB:\t\tloads as BASIC") + print("\t\tG:\t\tloads into Graphic Memory") + print("\t\tF:@\tLoads into CPU Memory at address ") + print("\t\tK:\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) + +