diff --git a/bin/flash/admflash.binary b/bin/flash/admflash.binary index 7103be7..c65a6e5 100644 Binary files a/bin/flash/admflash.binary and b/bin/flash/admflash.binary differ diff --git a/bin/flash/belflash.binary b/bin/flash/belflash.binary index 074f9f1..1ddebbe 100644 Binary files a/bin/flash/belflash.binary and b/bin/flash/belflash.binary differ diff --git a/bin/sdcard/reg.sys b/bin/sdcard/reg.sys index 47c7a83..925bd3c 100644 Binary files a/bin/sdcard/reg.sys and b/bin/sdcard/reg.sys differ diff --git a/bin/sdcard/system/admnet.adm b/bin/sdcard/system/admnet.adm new file mode 100644 index 0000000..0dbb3b1 Binary files /dev/null and b/bin/sdcard/system/admnet.adm differ diff --git a/bin/sdcard/system/admsys.adm b/bin/sdcard/system/admsys.adm index 7103be7..c65a6e5 100644 Binary files a/bin/sdcard/system/admsys.adm and b/bin/sdcard/system/admsys.adm differ diff --git a/bin/sdcard/system/admtest.bin b/bin/sdcard/system/admtest.bin index 995c373..0015626 100644 Binary files a/bin/sdcard/system/admtest.bin and b/bin/sdcard/system/admtest.bin differ diff --git a/bin/sdcard/system/basics.mod b/bin/sdcard/system/basics.mod index aa7be0a..463403a 100644 --- a/bin/sdcard/system/basics.mod +++ b/bin/sdcard/system/basics.mod @@ -481,5 +481,9 @@ wvariable lcog \ nummer interaktiven cog : _ob onboot ; : onboot _ob start ; +saveforth + +reboot + diff --git a/bin/sdcard/system/beltest.bin b/bin/sdcard/system/beltest.bin index 510844d..544d039 100644 Binary files a/bin/sdcard/system/beltest.bin and b/bin/sdcard/system/beltest.bin differ diff --git a/bin/sdcard/system/charmap.bin b/bin/sdcard/system/charmap.bin index f74269c..23948af 100644 Binary files a/bin/sdcard/system/charmap.bin and b/bin/sdcard/system/charmap.bin differ diff --git a/bin/sdcard/system/eram.bin b/bin/sdcard/system/eram.bin index 1e21a88..8454f1b 100644 Binary files a/bin/sdcard/system/eram.bin and b/bin/sdcard/system/eram.bin differ diff --git a/bin/sdcard/system/flash.bin b/bin/sdcard/system/flash.bin index a5aa340..c39692c 100644 Binary files a/bin/sdcard/system/flash.bin and b/bin/sdcard/system/flash.bin differ diff --git a/bin/sdcard/system/fm.bin b/bin/sdcard/system/fm.bin index d2d3405..5b7db27 100644 Binary files a/bin/sdcard/system/fm.bin and b/bin/sdcard/system/fm.bin differ diff --git a/bin/sdcard/system/fterm.bin b/bin/sdcard/system/fterm.bin index 96a03cf..6ef1362 100644 Binary files a/bin/sdcard/system/fterm.bin and b/bin/sdcard/system/fterm.bin differ diff --git a/bin/sdcard/system/ftp.bin b/bin/sdcard/system/ftp.bin new file mode 100644 index 0000000..0752be3 Binary files /dev/null and b/bin/sdcard/system/ftp.bin differ diff --git a/bin/sdcard/system/ftp.man b/bin/sdcard/system/ftp.man new file mode 100644 index 0000000..416f04c --- /dev/null +++ b/bin/sdcard/system/ftp.man @@ -0,0 +1,39 @@ + +/h : FTP-Server-Adresse (Host) + (default: mit ipconfig gesetzter Boot-Server) +/d : in entferntes Verzeichnis wechseln + (default: /hive/sdcard/system) +/f : Download +/u : Benutzername am FTP-Server + (default: anonymous) +/p : Paßwort am FTP-Server + (default: anonymous@hive) +/s : Datei auf SD-Card speichern + + +Ein Beispiel: +Zum Download von + + ftp://1.2.3.4/verzeichnis/unterverzeichnis/datei.txt + +verwendet man folgende Befehlszeile: + + ftp /h 1.2.3.4 /d /verzeichnis/unterverzeichnis /f datei.txt + +Dabei erfolgt die Anmeldung wegen der fehlenden Parameter +/u und /p als "anonymous" mit dem Pawort "anonymous@hivexxx" +(xxx: mit ipconfig gesetzte Hive-Id). Die Datei wird in +der RAM-Disk gespeichert (s. Kommando "xdir") und knnte +mittels "xsave" auf SD-Card gespeichert werden. + +Mit Nutzung aller Default-Werte gengt die Eingabe des +folgenden Befehls: + + ftp /s /f ipconfig.bin + +Damit wird die Datei "ipconfig.bin" vom FTP-Server mit der +IP-Adresse des mittels "ipconfig" konfigurierten Boot- +Servers aus dem Verzeichnis "/hive/sdcard/system" geladen +und im aktuellen Verzeichnis auf der SD-Card +abgespeichert. Von dort knnte sie direkt gestartet werden. + diff --git a/bin/sdcard/system/g0test.bin b/bin/sdcard/system/g0test.bin index efaadcf..0611247 100644 Binary files a/bin/sdcard/system/g0test.bin and b/bin/sdcard/system/g0test.bin differ diff --git a/bin/sdcard/system/hplay.bin b/bin/sdcard/system/hplay.bin index 65235b9..8ac95ca 100644 Binary files a/bin/sdcard/system/hplay.bin and b/bin/sdcard/system/hplay.bin differ diff --git a/bin/sdcard/system/ipconfig.bin b/bin/sdcard/system/ipconfig.bin new file mode 100644 index 0000000..bbf44a0 Binary files /dev/null and b/bin/sdcard/system/ipconfig.bin differ diff --git a/bin/sdcard/system/irc.bin b/bin/sdcard/system/irc.bin new file mode 100644 index 0000000..0fa0020 Binary files /dev/null and b/bin/sdcard/system/irc.bin differ diff --git a/bin/sdcard/system/keycode.bin b/bin/sdcard/system/keycode.bin index 2a14fec..06e1d62 100644 Binary files a/bin/sdcard/system/keycode.bin and b/bin/sdcard/system/keycode.bin differ diff --git a/bin/sdcard/system/m.bin b/bin/sdcard/system/m.bin index 15a184a..f2e3fac 100644 Binary files a/bin/sdcard/system/m.bin and b/bin/sdcard/system/m.bin differ diff --git a/bin/sdcard/system/man.bin b/bin/sdcard/system/man.bin index e33cb55..76e1909 100644 Binary files a/bin/sdcard/system/man.bin and b/bin/sdcard/system/man.bin differ diff --git a/bin/sdcard/system/perplex.bin b/bin/sdcard/system/perplex.bin new file mode 100644 index 0000000..0c835f5 Binary files /dev/null and b/bin/sdcard/system/perplex.bin differ diff --git a/bin/sdcard/system/ramtest.bin b/bin/sdcard/system/ramtest.bin index 7d24452..67b51e0 100644 Binary files a/bin/sdcard/system/ramtest.bin and b/bin/sdcard/system/ramtest.bin differ diff --git a/bin/sdcard/system/regime.bin b/bin/sdcard/system/regime.bin index 47c7a83..925bd3c 100644 Binary files a/bin/sdcard/system/regime.bin and b/bin/sdcard/system/regime.bin differ diff --git a/bin/sdcard/system/rom.bin b/bin/sdcard/system/rom.bin index 07183b5..2d664a3 100644 Binary files a/bin/sdcard/system/rom.bin and b/bin/sdcard/system/rom.bin differ diff --git a/bin/sdcard/system/sfxtool.bin b/bin/sdcard/system/sfxtool.bin index 7dde763..55aca0e 100644 Binary files a/bin/sdcard/system/sfxtool.bin and b/bin/sdcard/system/sfxtool.bin differ diff --git a/bin/sdcard/system/splay.bin b/bin/sdcard/system/splay.bin index 9497795..8755b85 100644 Binary files a/bin/sdcard/system/splay.bin and b/bin/sdcard/system/splay.bin differ diff --git a/bin/sdcard/system/sysconf.bin b/bin/sdcard/system/sysconf.bin index fa3d56c..6b49153 100644 Binary files a/bin/sdcard/system/sysconf.bin and b/bin/sdcard/system/sysconf.bin differ diff --git a/bin/sdcard/system/sysconf.man b/bin/sdcard/system/sysconf.man index 484e2f7..57a412f 100644 --- a/bin/sdcard/system/sysconf.man +++ b/bin/sdcard/system/sysconf.man @@ -1,18 +1,18 @@ -/? : Hilfe -/l : Konfiguration anzeigen ------------ Administra-Funktionen -/ah 0|1 : hss ab-/anschalten -/aw 0|1 : wav ab-/anschalten -/as 0|1 : systemklnge ab-/anschalten -/al 0..100 : wav-lautstrke links -/ar 0..100 : wav-lautstrke rechts -/ah 0..15 : hss-lautstrke -/af : administra reset, flash booten -/at : transfergeschwindigkeit messen ------------ Bellatrix-Funktionen -/ci : farbtabelle anzeigen -/cs datei : farbtabelle speichern -/cl datei : farbtabelle laden ------------ Port-Funktionen -/po nr anz : Impulse an port ausgeben -/pi : Status der Port abfragen \ No newline at end of file +/? : Hilfe +/l : Konfiguration anzeigen +---------------- Administra-Funktionen +/ah 0|1 : hss ab-/anschalten +/aw 0|1 : wav ab-/anschalten +/as 0|1 : systemklnge ab-/anschalten +/al 0..100 : wav-lautstrke links +/ar 0..100 : wav-lautstrke rechts +/ah 0..15 : hss-lautstrke +/af : administra reset, flash booten +/at : transfergeschwindigkeit messen +---------------- Bellatrix-Funktionen +/ci : farbtabelle anzeigen +/cs datei : farbtabelle speichern +/cl datei : farbtabelle laden +---------------- Port-Funktionen +/po nr anz time : Impulse an port ausgeben +/pi : Status der Port abfragen \ No newline at end of file diff --git a/bin/sdcard/system/tapecut.bin b/bin/sdcard/system/tapecut.bin index 513fbb1..234416b 100644 Binary files a/bin/sdcard/system/tapecut.bin and b/bin/sdcard/system/tapecut.bin differ diff --git a/bin/sdcard/system/time.bin b/bin/sdcard/system/time.bin index 5116c72..c76f515 100644 Binary files a/bin/sdcard/system/time.bin and b/bin/sdcard/system/time.bin differ diff --git a/bin/sdcard/system/vga.bel b/bin/sdcard/system/vga.bel index 074f9f1..1ddebbe 100644 Binary files a/bin/sdcard/system/vga.bel and b/bin/sdcard/system/vga.bel differ diff --git a/bin/sdcard/system/wplay.bin b/bin/sdcard/system/wplay.bin index f53d87e..c1acf97 100644 Binary files a/bin/sdcard/system/wplay.bin and b/bin/sdcard/system/wplay.bin differ diff --git a/bin/sdcard/system/yplay.bin b/bin/sdcard/system/yplay.bin index df27086..369b5de 100644 Binary files a/bin/sdcard/system/yplay.bin and b/bin/sdcard/system/yplay.bin differ diff --git a/doku/1-einfache-installation.txt b/doku/1-einfache-installation.txt new file mode 100644 index 0000000..47efa7d --- /dev/null +++ b/doku/1-einfache-installation.txt @@ -0,0 +1,23 @@ +Einfache Installation: + +Eine einfache Installation ist sowohl mit dem Propeller Tool von Parallax, als auch mit Brat's Spin Tool (BST) mglich. Die aktuelle Version von TriOS ist auf der Webseite zum Hive-Projekt zu finden. + +Downloadlink TriOS: http://hive-project.de/downloads + +Downloadlink Propeller Tool: http://www.parallax.com/downloads/propeller-tool-software +Downloadlink BST: http://www.fnarfbargle.com/bst.html + +Nach dem entpacken der TriOS-Archivdatei findet man alle ntigen Dateien fr eine Grundinstallation im Unterverzeichnis "bin". Die Installation erfolgt in zwei Schritten: + +1. Vorbereitung des TriOS-Datentrgers (SD-Card) +2. Flashen der drei Propellerchips im Hive + +1. TriOS-Disk: Die SD-Card muss im Format FAT16 oder FAT32 formatiert werden. Alle Dateien aus dem Unterverzeichnis "bin\sdcard" werden auf die Karte kopiert - fertig! + +2. Flashen: Im Unterverzeichnis "bin\flash" befinden sich die Binary-Dateien fr die drei Chips. Bei korrekt installiertem Propellertool oder BST wird bei einem Doppelklick auf diese Dateien das entsprechende Tool zum flashen gestarten. Nicht vergessen, den DIP-Switch auf dem Hiveboard auf den entsprechenden Chip einzustellen! + +Bei eingelegter SD-Card und nach dem Flashen der drei Chipcodes startet TriOS automatisch die Kommandozeile "Regime" und ist betriebsbereit. + +Im Tutorial "010 - Lizenz zum Lten! - Lang lebe die Knigin" kannst du dir die Grundinstallation auch als Video anschauen: http://hive-project.de/content/3651 + +Viel Spa! :) \ No newline at end of file diff --git a/doku/2-installation-mit-forth.txt b/doku/2-installation-mit-forth.txt new file mode 100644 index 0000000..5db072b --- /dev/null +++ b/doku/2-installation-mit-forth.txt @@ -0,0 +1,66 @@ +Installation des Grundsystems: +============================== + +TriOS kann in zwei Versionen installiert werden: Mit oder ohne Forth als integrierte Programmiersprache. Als Standard wird das System ohne Forth installiert. Die Installation ist so fr den Einsteiger einfacher. Mchte man auch PropForth installieren, mu nur eine Konfiguration gendert werden und ein Basiswortschatz im Forth selbst kompiliert werden - keine Panik, klingt komplizierter als es ist! ;) + +WICHTIG: Das System kann nur mit Brat's Spin Tool - kurz BST - compiliert werden. In den Einstellungen des Compilers (Tools/Compiler Preferences/Search Paths) muss das lib-Verzeichnis eingetragen werden. + +Downloadlink BST: http://www.fnarfbargle.com/bst.html + + + +Installation ohne Forth (Standard): +----------------------------------- + +1. Mikrocontroller flashen: + +\flash\administra\admflash.spin --> Administra +\flash\bellatrix\belflash.spin --> Bellatrix +\flash\regnatix\regflash.spin --> Regnatix + + +Installation mit Forth: +----------------------- + +1. Umstellung auf Forth + +In der Datei \flash\regnatix\regflash.spin kann ber zwei Compilervariablen eingestellt werden, ob TriOS whrend dem Bootvorgang die Kommandozeile Regime oder PropForth startet. Dafr ist am Anfang der Datei folgende Sequenz zu suchen: + +#define forth ' forth + spin-loader +'#define regime ' spin-loader OHNE FORTH, reg.sys wird sofort automatisch gestartet + +Einfach "#define forth" aktivieren und die Datei speichern. + + +2. Mikrocontroller flashen: + +Nacheinander die drei BIOS-Dateien in den Flash des entsprechenden Chips flashen. + +\flash\administra\admflash.spin --> Administra +\flash\bellatrix\belflash.spin --> Bellatrix +\flash\regnatix\regflash.spin --> Regnatix + + +3. Der Schalter bleibt ab jetzt auf Regnatix stehen. Ein Terminalprogramm (ich verwende Tera Term) starten und 57600 Baud auf die Schnittstelle vom Hive (DIP steht auf Regnatix!) einstellen. Nach einem Reset meldet sich das Propforth im Terminalprogramm auf dem Hostcomputer. Datei "forth\basics.mod" in einem Editor ffnen, alles markieren, kopieren und im Terminal einfgen. Der Quelltext wird jetzt im Forth compiliert. Sind alle Erweiterungen compiliert, wird automatisch das Forth in den Flash geschrieben. + +Nach einem automatischen Reset sollte sich das Forth jetzt komplett mit seinem Prompt sowohl auf dem angeschlossenen VGA-Monitor, als auch im Terminal melden. Im Prinzip bentigen wir nun das Terminalprogramm nicht mehr und knnen direkt am Hive arbeiten. Spter, wenn man in Forth programmiert, ist die vorhandene Terminalschnittstelle aber manchmal sehr ntzlich. + + + +Erstellen der SDCard: +--------------------- + +Im Prinzip kann jede normale FAT16/32 Karte verwendet werden. Lange Dateinamen werden nicht verwendet, Unterverzeichnisse sind kein Problem. Es ist sinnvoll, alle Dateien aus dem Verzeichnis "bin\sd-card\" auf die SD-Karte zu kopieren. + +Das Verzeichnis "system" hat eine besondere Bedeutung: Hier sollten sich die Tools, Erweiterungen und Bibliotheken befinden. Im PropForth: Mit dem Kommando "sys name.f" kann aus jedem anderen Verzeichnis ohne Wechsel eine Datei name.f im Verzeichnis System geladen und compiliert werden. + + + +Systemstart: +------------ + +Beim Systemstart wird immer das Forth aus dem EEPROM gestartet. So kann, wie mit den klassischen Homecomputern, sofort unkompliziert programmiert werden. Neben dem Forth gibt es im TriOS noch ein in Spin programmiertes Betriebssystem, welches sich dem Benutzer durch den Kommandointerpreter Regime prsentiert. Aus dem Forth kann diese mit dem Kommando "regime" gestartet werden. Im Gegenzug kann im laufenden Regime mit dem Kommando "forth" wieder zur integrierten Programmiersprache gewechselt werden. + +Wurde TriOS ohne Forth installiert, wird der Loader aus dem EEPROM gestartet und sofort die Kommandozeile "Regime" aus der Datei reg.sys gestartet. + + diff --git a/doku/3-regime-im-überblick.txt b/doku/3-regime-im-überblick.txt new file mode 100644 index 0000000..6b5d8e6 --- /dev/null +++ b/doku/3-regime-im-überblick.txt @@ -0,0 +1,100 @@ +Regime im berblick +=================== + +Da wir ja drei verschiedene Teilsystem in unserem Computer haben, muss Regime wissen, fr welchen Chip eine ausfhrbare Datei bestimmt ist. Den Typ ausfhrbarer Dateien kann Regime automatisch anhand der Dateinamenserweiterung unterscheiden: + +*.bin Regnatix-Code +*.bel Bellatrix-Code +*.adm Administra-Code + +Dabei gengt es, den Namen ohne Erweiterung einzugeben. Dennoch kann es vorkommen, das man eine normale Spin-Datei mit einer beliebigen Erweiterung gespeichert hat. Diese Datei kann man dann mit den Kommandos rload, aload oder bload ganz gezielt in einen Chip laden. + + - bin/adm/bel-datei wird gestartet +mount - SD-aufwerk mounten +unmount - SD-Laufwerk freigeben +dir wh - Verzeichnis anzeigen +type - Anzeige einer Textdatei +aload - Administra-Code laden +bload - Bellatrix-Code laden +rload - Regnatix-Code laden +del - Datei lschen +cls - Bildschirm lschen +free - Anzeige des freien Speichers auf SD-Card +attrib ashr - Dateiattribute ndern +cd - Verzeichnis wechseln +mkdir - Verzeichnis erstellen +rename - datei/verzeichnis umbenennen +format - SD-Laufwerk formatieren +reboot - Hive neu starten +sysinfo - Systeminformationen +color <0..7> - Farbe whlen +cogs - Belegung der COG's anzeigen +dmlist - Anzeige der Verzeichnis-Marker +dm - Marker-Verzeichnis wechseln +dmset - Marker setzen +dmclr - Marker lschen +forth - Forth starten + +Marker: +r - Marker fr Root-Verzeichnis +s - Marker fr System-Verzeichnis +u - Marker fr User-Verzeichnis +a/b/c - Benutzerdefinierte Verzeichnismarker + +Die r, s, u-Marker werden vom System automatisch gesetzt und intern verwendet. + +RAMDISK: + +xload - Datei von SD-Laufwerk in RAM laden +xsave - Datei aus RAM auf SD-Laufwerk speichern +xdir - Verzeichnis im RAM anzeigen +xrename - Datei im RAM umbenennen +xdel - Datei im RAM lschen +xtype - Textdatei im RAM anzeigen + + + +EXTERNE KOMMANDOS: +------------------ + +Die meisten Kommandozeilentools zeigen mit dem Parameter /? eine Liste der Optionen an. + +beltest - Testprogramm fr Bellatrix-Funktionen +charmap - Ausgabe des aktuellen nutzbaren Zeichensatzes +eram - Debugtool fr eRAM/Ramdisk +flash - Flash-Tool fr EEProms > 32 KByte +fm - [F]ile [M]anager +fterm - minimalstes Terminal fr PropForth-Experimente +ftp - FTP-Downloadprogramm +g0test - Testprogramm der Grafikmodus 0 Funktionen (TV) +hplay - HSS-Player +ipconfig - Setup fr Netzwerkparameter (IP/GW usw.) +irc - IRC-Client +keycode - Tastaturcodes anzeigen +m - Startcode fr mental unter TriOS (sofern installiert) +man - Anzeige von Manual-Pages +perplex - PlexBus-Tool +ramtest - eRAM Testprogramm +rom - startet ein Image aus dem EEPROM > 32 KByte +sfxtool - HSS-Soundeffekte erstellen +splay - SID-Player +sysconf - Systemeinstellungen +tapecut - Tool um eine Containerdatei (Tape) fr mental zu erzeugen +time - Zeit/Datum anzeigen bzw. im RTC setzen +wplay - WAV-Player +yplay - Yamaha-Soundchip-Player + +Bellatrix-Codes: + +vga - VGA 1024 x 768 Pixel, 64 x 24 Zeichen +htext - VGA 1024 x 768 Pixel, 128 x 48 Zeichen +tv - TV-Textmodus 40 x 13 Zeichen + +Administra-Codes: + +admay - Yamaha-Soundchip-Emulation +admnet - LAN + HSS-Light-Sound +admsid - SID-Chip-Emulation +admsys - HSS/WAV-Sound (Defaultcode) + + diff --git a/doku/4-forth-im-überblick.txt b/doku/4-forth-im-überblick.txt new file mode 100644 index 0000000..e8eab08 --- /dev/null +++ b/doku/4-forth-im-überblick.txt @@ -0,0 +1,135 @@ +Forth im berblick: +=================== + +Einige ntzliche Kommandos befinden sich in dem Modul tools.mod. In den meisten Fllen ist es sinnvoll dieses Modul mit der Befehlssequenz "sys tools.mod saveforth" fest im Forth einzubinden. + + + +Wichtige Tastencodes: +--------------------- + +[ESC]-1 Screen 1, COG 1 +[ESC]-2 Screen 2, COG 2 +[ESC]-3 Screen 3, COG 3 +[ESC]-b Break, Reset der aktuellen COG +[ESC]-r Reset, Neustart Regnatix + + + +Wichtige Kommandos: +------------------- + +load - Datei laden und comilieren, Ausgabe Screen 3 +dload - wie load, aber Ausgabe aktueller Screen +sys - Datei aus sys-Verzeichnis laden und compilieren +ls - Dateiliste +lsl - Dateiliste- Long-Format +cd - in Verzeichniss wechseln +mount - SD-Card einbinden +unmount - SD-Card freigeben +words - Anzeige Wterbuch +mod? - (tools.mod) Anzeige compilierter Erweiterungen +lib? - (tools.mod) Anzeige compilierter Bibliotheken +cog? - (tools.mod) Anzeige COG-Liste +cat - (tools.mod) Ausgabe einer Textdatei +less - (tools.mod) Zeilenweise Textausgabe +dm? - (tools.mod) Anzeige der Systemverzeichnisse +regime - CLI starten +aload - Adminsitra-Code laden +bload - Bellatrix-Code laden +spin - Spin-Programm starten + + + +Wichtige Dateien: +----------------- + +Die Dateien *.mod und *.lib enthalten ganz normale Forth-Quelltexte. Damit hat man schnell eine bersicht ber die grobe Funktion dieser Quellen: Lib's sind halt reine Sammlungen von Worten zu einer bestimmten Funktionsgruppe und MOD's sind mehr oder weniger fertige und abgeschlossene Programme. Ein Beispiel: + +Die Datei hss.lib enthlt Worte um die HSS-Funktionen von Administra anzusprechen. Mit diesen Funktionen kann man nun ein Modul (Programm) wie einen HSS-Soundplayer schreiben. + +Im Gegensatz dazu die Datei splay.mod: Mit diesem Modul wird ein HSS-Soundplayer ins System eingefgt, welcher Funktionen aus der hss.lib verwendet. + +Die Datei bentigt man aber mehr oder weniger nur zur Entwicklung, ein fertiges Modul wie splay.mod enthlt dann schon die die entsprechenden HSS-Worte die bentigt werden. + +Die ifnot: ... Anweisung sorgt dabei dafr, dass keine Funktionen doppelt in das Wrterbuch compiliert werden. Das ist quasi ein verteiltes und fein granuliertes Konzept analog zu einer DLL. Die Forth-Version funktioniert dabei aber im Gegensatz zu DLL's nicht auf Bibliotheks-, sondern auf Funktionsebene. + +*.mod Module, Forth-Erweiterungen fr das System +*.lib Bibliotheken, grundlegende Wortsammlungen +*.adm Administra-Code (z.Bsp. admsid.adm fr SIDCog-Code) +*.bel Bellatrix-Code +*.bin Spin-Code, im Normalfall zur Ausfhrung in Regnatix + +basics.f - (mod:basics) Hive-Core fr PropForth +ari.lib - (lib:ari) Zustzliche arithmetische Funktionen +cog.lib - (lib:cog) Zustzliche COG-Funktionen +adm.lib - (lib:adm) Administra-Chipmanagment-Funktionen +hss.lib - (lib:hss) Bibliothek fr Hydra-Sound-System +sfx.lib - (lib:sfx) Soundeffekt-Bibliothek +wav.lib - (lib:wav) Wave-Soundbibliothek + +bel.lib - (lib:bel) Bellatrix-Chipmanagment-Funktionen +key.lib - (lib:key) Tastatur-Bibliothek +scr.lib - (lib:scr) Screen-Bibliothek +sd0.lib - (lib:sd0) SD-Card-Bibliothek + +debug.f - Ntzliche Worte zur Fehlersuche und Entwicklung +rom.f - EEPROM-Dateisystem +tools.f - Ntzliche Tools (cat, less, dm?...) +hplay.f - HSS-Player +wplay.f - WAV-Player +splay.f - SID-Player + +Administra-Codedateien im SYS-Verzeichnis: + +admled.adm Testprogramm - HBeat-LED blinken lassen +admsid.adm SidCog-Version (wird von splay bentigt) +admsys.adm Standardcode fr ADM mit SD/HSS/WAV +admym.adm Yamaha-Soundchip-Version +aterm96.adm Mini-OS fr Administra (Testzwecke) + + + +Reset-Fehlercodes: +------------------ + +0011FFFF - stack overflow +0012FFFF - return stack overflow +0021FFFF - stack underflow +0022FFFF - return stack underflow +8100FFFF - no free cogs +8200FFFF - no free main memory +8400FFFF - fl no free main memory +8500FFFF - no free cog memory +8800FFFF - eeprom write error +9000FFFF - eeprom read error + + + +.err-Fehlercodes: +----------------- + +0 no error +1 fsys unmounted +2 fsys corrupted +3 fsys unsupported +4 not found +5 file not found +6 dir not found +7 file read only +8 end of file +9 end of directory +10 end of root +11 dir is full +12 dir is not empty +13 checksum error +14 reboot error +15 bpb corrupt +16 fsi corrupt +17 dir already exist +18 file already exist +19 out of disk free space +20 disk io error +21 command not found +22 timeout +23 parameter error diff --git a/doku/5-lan.txt b/doku/5-lan.txt new file mode 100644 index 0000000..bfb2066 --- /dev/null +++ b/doku/5-lan.txt @@ -0,0 +1,192 @@ +#################### +# TriOS R56 Netzwerk +#################### + +Einleitung +========== + +Dies ist eine Implementierung von Netzwerk-Funktionen in die aktuelle Version +von TriOS (R56). Als erste Anwendungen sind enthalten: + - Ein FTP-Client, welcher Dateien von einem FTP-Server downloaden und in der + RAM-Disk im eRAM oder auf SD-Card abspeichern kann. + - Ein vollstndiger IRC-Client +Zuknftige Erweiterungen, wie die Integration in Regime und direktes Starten +von Programmen aus dem Netzwerk sind geplant. + + +Implementierung +=============== + +Es wurde ein neuer Administra-Code erstellt, welcher direkt geflasht werden +kann oder zur Laufzeit geladen wird. Grundlage ist das originale admflash.spin. +Aus diesem wurden aus Platzgrnden alle Soundfunktionen entfernt und dafr +die unvernderten Netzwerk-Treiber von Harrison Pham integriert. + +Fr die Kommunikation ber den Hive-Bus wurden die wesentlichen Funktionen +des Netzwerk-Treibers zur Verfgung gestellt. Die Implementierung weiterer +Funktionen des Original-Treibers ist bei Bedarf mglich. + +Die IP-Konfiguration des Hive wird im NVRAM des RTC gespeichert. Das hat +den Vorteil, da der Hive zuknftig auch ganz ohne SD-Card arbeiten kann, +also quasi aus dem Netzwerk bootet. Ist kein RTC vorhanden (wird automatisch +erkannt), erfolgt das Speichern der Konfiguration auf der SD-Card unter +/system/nvram.sav. + + +Installation +============ + +Binr: +------ + +Voraussetzung ist die Installation eines aktuellen TriOS im Flash von +Administra, Bellatrix und Regnatix sowie auf der zugehrigen SD-Card. In das +Verzeichnis "/system" auf der SD-Card werden die Dateien des Verzeichnisses +"system" des vorliegenden Installations-Archives kopiert: + + admnet.adm: Administra mit Netzwerk-Funktionen, ohne Sound + ipconfig.bin: IP-Konfigurationsprogramm + ftp.bin: FTP-Client + irc.bin: IRC-Client + +Quellen: +-------- + +Das Verzeichniss "src" des vorliegenden Archives wird in die vorhandene TriOS- +Struktur (R56) kopiert. Damit werden die folgenden Dateien durch genderte +Versionen ersetzt: + + lib/glob-con.spin + lib/reg-ios.spin + +Wer dort eigene nderungen vorgenommen hat, sollte sich die nderungen in den +beiliegenden Patches (glob-con.spin.diff und reg-ios.spin.diff) ansehen und +selbst einpflegen. + +Folgende SPIN-Dateien knnen dann mittels BST bersetzt werden: + + system/administra/admnet/admnet.spin + system/regnatix/ipconfig.spin + system/regnatix/ftp.spin + system/regnatix/irc.spin + +Das bersetzte admnet.spin kann direkt in Administra geflasht oder als +"system/admnet.adm" auf die SD-Card kopiert werden. ipconfig.bin und ftp.bin +gehren dann ebenfalls auf die SD-Card ins system-Verzeichnis. + +Wer die make.bat benutzt: Damit sollte ipconfig.spin, ftp.spin und irc.spin +automatisch mit bersetzt werden, admnet.spin mte man noch ergnzen. + +TriOS-R56-Network-src.tar.bz2 enthlt die zur Entwicklung genutzten kompletten +Sourcen. Hier wurden alle SPIN-Dateien nach UTF-8 gewandelt und auf Linux- +Zeilenumbruch (LF) konvertiert. Auerdem ist ein Build-Script (make.sh) fr +Linux enthalten. In diesem knnen #defines fr Debugging-Ausgaben und +alternative Locales (z.Z. Englisch) gesetzt werden. + + +Nutzung +======= + +Allgemeines +----------- + +Der Netzwerk-Stack in Administra wird erst gestartet, wenn er bentigt wird. +Auch danach sollte man sich nicht wundern, da der Hive nicht per Ping +angesprochen werden kann: Aus Platzgrnden enthlt der Netzwerk-Stack keinen +ICMP-Code. Dieser knnte auf Wunsch aber recht einfach hinzugefgt werden. + + +Administra +---------- + +Voraussetzung ist, da Administra mit dem Netzwerk-Code luft. Das geschieht +entweder durch direktes Flashen von admnet.spin oder durch Eingabe von +"admnet" am Regime-Prompt. + + +IP-Konfiguration +---------------- + +Mittels "ipconfig" wird die IP-Konfiguration im NVRAM oder als Datei abgelegt. +Folgende Parameter kennt ipconfig: + + /? : Hilfe + /l : Konfiguration anzeigen + /a : IP-Adresse setzen + /m : Netzwerk-Maske setzen + /g : Gateway setzen + /d : DNS-Server setzen + /b : Boot-Server setzen + /i : Hive-Id setzen + +Aus der Hive-Id wird eine eindeutige Mac-Adresse erzeugt. +DNS-Abfragen werden noch nicht untersttzt, deswegen mu man den DNS-Server +nicht konfigurieren. Der Boot-Server wird derzeit vom FTP-Client als Default- +Server genutzt (s.u.). + + +FTP-Client +---------- + +Der FTP-Client ist aktuell eine sehr einfache Implementierung und dient primr +zum Testen der Funktion des Netzwerk-Stacks. + +Der Download funktioniert nur, wenn der FTP-Server das Kommando "SIZE" +versteht. Obwohl das kein Standard-Kommando ist, wird es von den meisten +FTP-Servern untersttzt. Auerdem wird nur passives FTP verwendet. + +Folgende Parameter kennt der FTP-Client: + + /h : FTP-Server-Adresse (Host) + (default: mit ipconfig gesetzter Boot-Server) + /d : in entferntes Verzeichnis wechseln + (default: /hive/sdcard/system) + /f : Download + /u : Benutzername am FTP-Server + (default: anonymous) + /p : Pawort am FTP-Server + (default: anonymous@hive) + /s : Datei auf SD-Card speichern + +Dabei ist zu beachten, da auf Grund der fehlenden Namensauflsung die IP- +Adresse und nicht der Host-Name des Servers angegeben wird. Weitere +Einschrnkungen ergeben sich durch die maximale Parameter-Lnge von 64 +Zeichen in Regime und maximal 12 Zeichen lange Dateinamen in der RAM-Disk. + +Ein Beispiel: +Zum Download von ftp://1.2.3.4/verzeichnis/unterverzeichnis/datei.txt +verwendet man folgende Befehlszeile: + + ftp /h 1.2.3.4 /d /verzeichnis/unterverzeichnis /f datei.txt + +Dabei erfolgt die Anmeldung wegen der fehlenden Parameter /u und /p als +"anonymous" mit dem Pawort "anonymous@hivexxx" (xxx: mit ipconfig gesetzte +Hive-Id). Die Datei wird in der RAM-Disk gespeichert (s. Kommando "xdir") +und knnte mittels "xsave" auf SD-Card gespeichert werden. + +Mit Nutzung aller Default-Werte gengt die Eingabe des folgenden Befehls: + + ftp /s /f ipconfig.bin + +Damit wird die Datei "ipconfig.bin" vom FTP-Server mit der IP-Adresse +des mittels "ipconfig" konfigurierten Boot-Servers aus dem Verzeichnis +"/hive/sdcard/system" geladen und im aktuellen Verzeichnis auf der SD-Card +abgespeichert. Von dort knnte sie direkt gestartet werden. + +Getestet wurde mit einer lokalen Installation von "pure-ftpd" und den FTP- +Servern der TU Chemnitz sowie des GnuPG-Projektes. + +IRC-Client +---------- + +siehe IRC.README.txt + + +Schlubemerkung +=============== + +Fragen knnen im Hive-Forum (http://hive-project.de/board/) gestellt werden +oder direkt an joergd@bitquell.de + + +Viel Spa - Jrg diff --git a/doku/6-irc-client.txt b/doku/6-irc-client.txt new file mode 100644 index 0000000..a078b11 --- /dev/null +++ b/doku/6-irc-client.txt @@ -0,0 +1,149 @@ + + IRC + + IRC-Client fr den Hive + + Author: Jrg Deckert (joergd@bitquell.de) + +=============================================================================== + + +Einleitung +========== + +Dies ist ein IRC-Client fr den Hive (http://hive-project.de). Er sollte auf +jedem Hive mit bestcktem Netzwerk-Interface funktionieren. + +Die Idee des IRC-Clients stammt von PropIRC, einem Projekt von Harrison Pham, +welches aus einer Propeller-basierten Hardware ausschlielich fr diesen Zweck +besteht (http://classic.parallax.com/tabid/701/Default.aspx). Der Administra- +Netzwerk-Stack nutzt darber hinaus die Treiber von Harrison Pham. + +Der vorliegende IRC-Client hat mit PropIRC ansonsten nicht viel gemein, sondern +stellt einen ausgewachsenen IRC-Client mit den meisten der blichen +Funktionalitten dar. + + +Installation +============ + +Der Hive IRC-Client ist Bestandteil des TriOS Netzwerk-Paketes. Die aktuellste +Version steht immer im ersten Beitrag des zugehrigen Forum-Threads unter +http://hive-project.de/board/viewtopic.php?f=7&t=968 zur Verfgung. + +Die Installation ist wie im Download-Archiv beschrieben vorzunehmen. Dabei wird +auch der IRC-Client in das System-Verzeichnis der TriOS SD-Card kopiert und +kann von dort gestartet werden. + + +Testserver +========== + +Fr erste Versuche mit IRC steht ein eigener Server zur Verfgung. Dieser kann +wie folgt erreicht werden: + + IRC-Server (IP-Adresse:Port): 88.198.147.76:6667 + nutzbarer Channel: #hive + + +Nutzung +======= + +Start +----- + +Der IRC-Client bentigt den Netzwerk-Code in Administra. Dieser kann direkt in +Administra geflasht oder durch Eingabe von "admnet" geladen werden. Beim Start +prft der IRC-Client das Vorhandensein der Netzwerk-Funktionalitten. Sind +diese nicht vorhanden, wird automatisch versucht, "/system/admnet.adm" von der +SD-Card zu laden. + +Auerdem mu der Hive natrlich an ein Netzwerk mit Internet-Verbindung +angeschlossen sein und mittels "ipconfig" entsprechend konfiguriert werden. + +Der Start erfolgt dann einfach durch Eingabe von "irc" am Regime-Prompt. Beim +ersten Start wird automatisch die Konfiguration aufgerufen. Nach Eingabe der +erforderlichen Parameter (s.u.) werden diese gespeichert. Nun kann mittels +Drcken von "F3" die Verbindung zum Server aufgebaut werden. + + +Bedienung +--------- + +Der IRC-Client besteht aus 3 Fenstern. Im groen oberen werden die Chat- +Mitteilungen ausgegeben. Im mittleren erscheinen verschiedene Statusmeldungen. +Im untersten Fenster werden die Mitteilungen und Befehle eingegeben. + +Das aktive Fenster wird jeweils hervorgehoben und kann mittels Tabulator-Taste +umgeschalten werden. Im aktiven Fenster kann mittels Cursor hoch/runter +gescrollt werden (auer im Eingabefenster). + +Die Bedienung erfolgt durch Bettigung der Funktionstasten oder die Eingabe +von Befehlen im EingabeFenster (s.u.). Alle Befehle beginnen mit einem +Schrgstrich (/). + +Beim Erscheinen einer neuen Mitteilung im aktuellen Kanal blinkt die Regnatix- +LED so lange, bis eine beliebige Taste gedrckt wird. Auerdem wird ein Sound +abgespielt. + + +Befehlsbersicht +---------------- + + Funktionstaste Eingabe + --------------+-------+------------------------------------------------- + F1 Hilfe + F2 /set Alle Einstellungen bearbeiten und abspeichern + F3 Mit Server verbinden, anmelden und Kanal betreten + F4 /join Kanal betreten (/join #) + F5 /part Aktuellen Kanal verlassen (/part ) + F6 /nick Nicknamen ndern (/nick ) + F7 /user Username ndern + F8 /pass Pawort ndern + F9 /quit Verbindung zu Server trennen + F10 Programm beenden + /msg Private Mitteilung (/msg ) + /srv Mit Server verbinden und anmelden (srv ) + /save Einstellungen speichern + Tab Fenster umschalten, Scrollen mit Cursor hoch/runter + +Alle anderen mit '/' beginnenden Eingaben sind Befehle an den Server. Alle +Eingaben, welche nicht mit '/' beginnen, sind eine ffentliche Mitteilung an +den aktuellen Kanal. + + +Einstellungen +------------- + +Durch Drcken von "F2" oder Eingabe von "/set" werden alle notwendigen +Einstellungen (Server, Pawort, Nickname, Username, Channel) abgefragt und +gespeichert. Zur Erstkonfiguration sollten in jedem Fall alle Parameter +mittels "F2" oder "/set" gesetzt werden. + +Die Einstellungen sind auch einzeln ber die in der Befehls-bersicht +angegebenen Funktionstasten bzw. Befehle erreichbar. Mittel Eingabe +ber Befehle kann die gewnschte Einstellung meist auch als Parameter +mitgegeben werden. Im Gegensatz zu "F2" bzw. "/set" werden hier teilweise +auch gleich online die entsprechenden nderungen vorgenommen ("F6" bzw. "/nick" +ndert z.B. sofort den aktuellen Nicknamen). + +Da der Hive derzeit keine Namensauflsung untersttzt, mu der Server mit IP- +Adresse und Port angegeben werden. Die IP-Adresse kann an einem PC mittels +Ping oder NSLookup ermittelt werden, der Port ist meist 6667. + +Der Nickname ist der Name, unter welchem man aktuell seine Mitteilungen +schreibt. Dieser kann jederzeit gendert werden. Demgegenber ist der Username +der Name, mit welchem man sich beim Server anmeldet. Dessen nderung wirkt sich +nur bei einer erneuten Anmeldung aus. Nickname und Username knnen auch +identisch sein. + +Bei der Anmeldung am Server wird auch ein vollstndiger Name bertragen. Da es +unblich ist, hier seinen richtigen Namen anzugeben, wird stattdessen ein Name +in der Form "Hive #" generiert. ist der mittels "ipconfig /i" +definierte Wert. + +TODO +==== + +- offene Eingabefenster blockieren nicht den IRC-Empfang +- Support fr mehrere gleichzeitige Channel diff --git a/doku/FemtoBasic Manual.rtf b/doku/FemtoBasic Manual.rtf deleted file mode 100644 index 5f43836..0000000 --- a/doku/FemtoBasic Manual.rtf +++ /dev/null @@ -1,797 +0,0 @@ -{\rtf1\ansi\ansicpg1252\cocoartf949 -{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Verdana;} -{\colortbl;\red255\green255\blue255;\red0\green5\blue50;\red238\green238\blue238;} -\margl1440\margr1440\vieww12580\viewh18760\viewkind0 -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural - -\f0\b\fs24 \cf0 \ul \ulc0 FemtoBasic Manual - Version 3.006 -\b0 \ulnone \ -\ -Program lines consist of a line number from 1 to 65535, then a space,\ -then one or more statements separated by a colon (":"). Most statements\ -can be given without a line number and will be executed immediately if so.\ -\ -If a line is entered with the same line number as that of an existing line in\ -the current program, the existing line is deleted and the new line is stored.\ -\ -A line number by itself may be entered. Any existing line in the current\ -program with the same line number will be deleted. No new line will be\ -stored.\ -\ -When FemtoBasic is first started after a Propeller reset, if an SD card is\ -provided and it has a file "autoexec.bas" in its root directory, then the\ -line 'LOAD "autoexec.bas" : RUN' is automatically executed.\ -\ -The ESC key is a "break key". If it is entered, the running program will\ -stop after the current statement finishes executing. PAUSE and IRBRECV\ -are handled specially so the "break key" can interrupt their execution.\ -\ -Pre-compiled binaries are provided for both a VGA display and a TV\ -display and for either the Propeller Demo Board, Propeller Proto Board,\ -or a Hydra. The Hydra version cannot use an SD card with a VGA\ -display because the SD card interface uses the same I/O pins as the\ -VGA display. The names of the binary files indicate which display and\ -board they are intended for.\ -\ -The basic SD card wiring is shown below. "Pull-up" refers to a 20K\ -pull up resistor from the pin indicated to +3.3V. For the Demo Board\ -version, the pins are as indicated below. For the Proto Board version,\ -P0 = I/O pin 8, P1 = I/O pin 9, P2 = I/O pin 10, and P3 = I/O pin 11. For\ -the Hydra version, P0 = I/O pin 16, P1 = I/O pin 17, P2 = I/O pin 18, and\ -P3 = I/O pin 19.\ -\ -\pard\pardeftab720\ql\qnatural - -\f1 \cf2 \cb3 SD CARD Socket Pin-out:\ -\'a0\ -PIN\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 SD CARD\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 Propeller\ ------------------------------------------------------\ -\'a01\'a0(NC)\ -\'a02\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-9) DAT2\'a0\'a0\'a0 Pull-up\ -\'a03\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0(PIN-1) CS\'a0\'a0\'a0\'a0\'a0 Pull-up\'a0\'a0\'a0 P3\ -\'a04\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-2) DI\'a0\'a0\'a0\'a0\'a0 Pull-up\'a0\'a0\'a0\'a0 P2\ -\'a05\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-3) GND\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 GND\ -\'a06\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-4) +3.3\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 VCC\ -\'a07\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-5) CLK\'a0\'a0\'a0\'a0 Pull-up\'a0\'a0\'a0\'a0 P1\ -\'a08\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-6) GND\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 GND\'a0\'a0\'a0\'a0\'a0 \ -\'a09\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-7) DO\'a0\'a0\'a0\'a0\'a0 Pull-up\'a0\'a0\'a0\'a0 P0\ -10\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0 (PIN-8) DAT1\'a0\'a0 Pull-up\ -11\'a0(CD SW)\ - -\f0 \cf0 \cb1 \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural - -\b \cf0 \ul Expressions\ - -\b0 \ulnone \ -Expressions consist of variables, constants, and "pseudo-variables"\ -that function like variables, but may have complex actions like FILE or\ -EEPROM[5]. Constants may be decimal, hexadecimal (prefixed with "$"),\ -or binary (prefixed with "%"). All expressions use 32-bit integer values.\ -\ -\ -\ -There are 26 variables designated by the letters A through Z.\ -Upper and lower case letters are equivalent.\ -\ -INA [ \{.. \} ]\ -\ -This has the value of the specified input pin or pins. If two pin values are\ -given, the first is the most significant bit number and the second is the\ -least significant bit number of the value. The pin or pins specified are\ -changed to input mode (the default).\ -\ -BYTE [ ]\ -\ -This has the value of the main memory byte at the address provided.\ -\ -WORD [ ]\ -\ -This has the value of the main memory word at the address provided.\ -The least significant bit of the address is ignored.\ -\ -LONG [ ]\ -\ -This has the value of the main memory long word at the address provided.\ -The least significant two bits of the address are ignored.\ -\ -EEPROM [ \{, \} ]\ -\ -This has the value of the byte in the EEPROM attached to the boot I2C bus\ -(on pins 28-29) at the address specified. If two expressions are provided,\ -the first gives the pin number of the SCL line of the EEPROM while the\ -second expression is the address. The address may be any value from\ -zero to $7FFFF and the upper 3 bits are used to form the device select code.\ -\ -FILE\ -\ -This has the value of the next byte in the currently open SD card file or -1\ -at the end of the file. The file must be open for reading.\ -\ -MEM\ -\ -This has the value of the amount of space available for program storage.\ -\ -CNT\ -\ -The current system clock value.\ -\ -PHSA\ -\ -The cog counter phase register A value.\ -\ -PHSB\ -\ -The cog counter phase register B value.\ -\ -FRQA\ -\ -The cog counter frequency register A value.\ -\ -FRQB\ -\ -The cog counter frequency register B value.\ -\ -CTRA\ -\ -The cog counter control register A value.\ -\ -CTRB\ -\ -The cog counter control register B value.\ -\ -KEYCODE\ -\ -The value of the next keyboard key value or zero if the keyboard buffer\ -is empty.\ -\ -RND \ -\ -The value is a pseudo-random number in the range zero to one less than\ -that of the expression given.\ -\ -- \ -! \ -\ -"-" is negate. "!" is bit-wise logical not.\ -\ -<9> SHL <9>\ -<9> SHR <9>\ -<9> ROL <9>\ -<9> ROR <9>\ -<9> SAR <9>\ -<9> REV <9>\ -\ -"SHL" is logical shift left. "SHR" is logical shift right. "ROL" is rotate left.\ -"ROR" is rotate right. "SAR" is arithmetic shift right. "REV" is bit reverse.\ -In all cases, the value to be shifted is the left operand and the shift count\ -is the right operand. "REV" reverses the order of the specified number of\ -least significant bits with the most significant bits set to zero.\ -\ -<8> & <8>\ -\ -"&" is bit-wise logical and.\ -\ -<7> | <7>\ -\ -"|" is bit-wise logical or\ -\ -<6> *<6>\ -<6> / <6>\ -<6> // <6>\ -\ -"*" is a 32 bit unsigned multiplication. "/" is the quotient of a 32 bit unsigned\ -division. "//" is the remainder of a 32 bit unsigned division.\ -\ -<5> + <5>\ -<5> - <5>\ -\ -"+" is a 32 bit addition. "-" is a 32 bit subtraction\ -\ -<4> = <4>\ -<4> < <4>\ -<4> > <4>\ -<4> <= <4>\ -<4> >= <4>\ -<4> <> <4>\ -\ -"=" is equal to. "<" is less than. ">" is greater than.\ -"<=" is less than or equal to. ">=" is greater or equal to.\ -"<>" is not equal to.\ -\ -NOT <3>\ -\ -"NOT" is logical not.\ -\ -<2> AND <2>\ -\ -"AND" is logical and.\ -\ -<1> OR <1>\ -\ -"OR" is logical or.\ -\ -Note that the numbers in the brackets () are used to\ -indicate the operator precedence.\ -\ - -\b \ul Statements -\b0 \ulnone \ -\ -Note that multiple statements may be given on a line separated by\ -a colon (":"). There are some restrictions on what can be combined on\ -a line. These are described in the individual statements' descriptions.\ -\ -\{LET\} = \ -\ -Set the variable to the value of the expression .\ -\ -INPUT \{ "";\} \{,\}\ -\ -If given, the is displayed and an input line may be entered.\ -For each variable given, an expression is evaluated from the input line.\ -The expressions may be separated by commas (",") or, if unambiguous,\ -by spaces. These expressions may contain variable names, operators,\ -or "pseudo-variables". If more expressions are given than variables,\ -the excess are ignored. An error is treated as if it occurred on the line\ -where the INPUT statement is given.\ -\ -PRINT \{\{"" | \} \{, | ;\}\}\ -\ -A series of expressions or string constants are given, separated by\ -commas (",") or semicolons (";"). If a comma is used, enough spaces\ -are inserted to display the next item at the next display column divisible\ -by 8. If a semicolon is used, the next item begins at the next column.\ -If the statement ends with a comma or semicolon, an end of line is not\ -inserted. A PRINT statement by itself causes an end of line to be displayed\ -\ -GOTO \ -\ -Go to the label whose value is equal to the expression\ -\ -GOSUB \ -\ -Call (as a subroutine) the label whose value is equal to the expression.\ -Note that a GOSUB must be the only or last statement on a line.\ -\ -RETURN\ -\ -Return from a GOSUB call\ -\ -REM \ -\ -The rest of the line in the program is considered part of the comment and\ -is otherwise ignored.\ -\ -NEW\ -\ -Erase the current program and clear all the variables.\ -\ -LIST \{ \{,\}\}\ -\ -List the current program. If no expressions are given, the whole program\ -is listed. If one expression is given, that line is listed. If two expressions\ -are given, all lines between those two values are listed.\ -\ -RUN\ -\ -Clear all the variables (to zero) and start executing the current program\ -from the first line.\ -\ -OPEN "", \{R | W | A \}\ -\ -Open the specified file on the SD card in the mode requested (R - read,\ -W - write, A - append). If a file is already open, it is closed first. Only one\ -file may be open at a time.\ -\ -READ \{,\}\ -\ -Read a line from the currently opened SD card file and set the variables\ -specified to the expressions supplied on that line. The expressions may\ -be separated by commas or, if unambiguous, may be separated by spaces.\ -These expressions may be any expression including operators, variables,\ -pseudo-variables (like CNT). Effectively, this is as if " = " were\ -executed for each variable given and each expression in the SD card file.\ -\ -WRITE \{\{"" | \} \{, | ;\}\}\ -\ -This works just like the PRINT statement except that the characters produced\ -are written to the currently opened SD card file. An end of line is written as\ -a carriage return / line feed pair (ASCII CR/LF ... 13, 10).\ -\ -CLOSE\ -\ -Close the currently opened SD card file, if any.\ -\ -DELETE ""\ -\ -Delete the specified SD card file. Any opened SD card file will be closed.\ -\ -RENAME "", ""\ -\ -Rename the specified SD card file. Any opened SD card file will be closed.\ -This is not currently implemented and will produce an error message.\ -\ -FILES\ -\ -List all files on the SD card (at the root level). Neither subdirectories nor the files\ -within them are included in this listing. Any opened SD card file will be closed.\ -\ -SAVE\ -\ -Save the current program to an otherwise unused area in the boot EEPROM.\ -Note that downloading a program to the EEPROM using the Propeller Tool or\ -an equivalent downloading program will erase any saved program.\ -\ -SAVE [ \{, \} ]\ -\ -This saves the current program in the EEPROM attached to the boot I2C bus\ -(on pins 28-29) at the address specified. If two expressions are provided,\ -the first gives the pin number of the SCL line of the EEPROM while the\ -second expression is the address. The address may be any value from\ -zero to $7FFFF and the upper 3 bits are used to form the device select code.\ -The address is adjusted to 2 bytes below the next 64 byte boundary and the\ -total program length is stored in those two bytes followed by the program itself.\ -If the address is adjusted upwards, only the last two bytes of that 64 byte block\ -are changed.\ -\ -SAVE ""\ -\ -Save the current program to the specified file on a SD card. Any existing file\ -by that name will be overwritten with the program which will be saved in text\ -file format, as if they were displayed with the LIST statement.\ -\ -LOAD\ -\ -Erase the current program and load in a program previously saved with the\ -SAVE statement.\ -\ -LOAD [ \{, \} ]\ -\ -Erase the current program and load in a program previously saved with the\ -SAVE [ \{, \} ] statement.\ -\ -LOAD ""\ -\ -Erase the current program and load in a program from an SD card file. This\ -program must be in text format, just as if it were to be typed in. All lines must\ -be numbered (with a line number) except lines that are completely blank.\ -\ -FOR = TO \{STEP \}\ -\ -This sets up a standard Basic FOR/NEXT loop. The variable is set to the value\ -of the first expression and tested against the limit given by the value of the\ -second expression (which is evaluated only once). The optional step size\ -may be positive or negative. If negative, the limit test is appropriately changed.\ -The FOR statement must be the last statement on a multi-statement line and\ -improperly nested FOR/NEXT statement pairs may cause incorrect execution\ -without an error message. Default STEP value is +1.\ -\ -NEXT \ -\ -This terminates a standard Basic FOR/NEXT loop. The STEP value is added\ -to the variable and the result is tested against the limit value. If still within the\ -limit, program execution continues with the statement after the matching FOR\ -statement. If not, execution continues with the next statement.\ -\ -OUTA [ \{.. \} ] = \ -\ -This sets the specified output pin or pins to the expression to the right of the\ -assignment. If one pin value is given, that is the pin to be changed. If two\ -pin values are given, the first is the most significant bit number and the\ -second is the least significant bit number of the value. The pin or pins\ -specified are changed to output mode.\ -\ -PAUSE \{, \}\ -\ -The program is paused for the number of milliseconds given by the first\ -(or only) value given. If two values are given, the first is in milliseconds\ -while the second is in microseconds and they're added together for the\ -total pause time. The minimum pause time is 50us. If the pause time is\ -more than 10ms, The pause statement is interrupted after 10ms and\ -reexecuted with a 10ms shorter pause time. This is to allow for the\ -interruption of the program using a "break key". The PAUSE statement\ -must be the first or only statement on a line.\ -\ -BYTE [ ] = \ -\ -This sets the value of the main memory byte at the address provided to\ -the expression on the right side of the assignment.\ -\ -WORD [ ] = \ -\ -This sets the value of the main memory word at the address provided to\ -the expression on the right side of the assignment. The least significant\ -bit of the address is ignored.\ -\ -LONG [ ] = \ -\ -This sets the value of the main memory long word at the address provided\ -to the expression on the right side of the assignment. The least significant\ -two bits of the address are ignored.\ -\ -PHSA = \ -\ -Set the cog counter phase register A to the expression.\ -\ -PHSB = \ -\ -Set the cog counter phase register B to the expression.\ -\ -FRQA = \ -\ -Set the cog counter frequency register A to the expression.\ -\ -FRQB = \ -\ -Set the cog counter frequency register B to the expression.\ -\ -CTRA = \ -\ -Set the cog counter control register A to the expression.\ -\ -CTRB = \ -\ -Set the cog counter control register B to the expression.\ -\ -DISPLAY \{, \}\ -\ -Send the specified byte values to the display driver. The specific control\ -codes, their parameters, and their meaning depend on the display driver.\ -See the display driver documentation for descriptions.\ -\ -STOP\ -\ -Stop execution of the program.\ -\ -END\ -\ -Stop execution of the program (works like STOP).\ -\ -EEPROM [ \{, \} ] = \ -\ -This sets the value of the byte in the EEPROM attached to the boot I2C bus\ -(on pins 28-29) at the address specified. If two expressions are provided,\ -the first gives the pin number of the SCL line of the EEPROM while the\ -second expression is the address. The address may be any value from\ -zero to $7FFFF and the upper 3 bits are used to form the device select code.\ -\ -FILE = \ -\ -This sets the value of the next byte in the currently open SD card file.\ -The file must be open for writing or appending.\ -\ -SPIN [ \{, \} ]\ -\ -This causes a Spin program to be loaded into the Propeller's main memory\ -from a 32K EEPROM "page". If only one expression is provided, it is the\ -starting address in a 512K byte address space made up of one or more\ -EEPROMs attached to the I2C bus on Propeller pins 28 (SCL) and 29 (SDA).\ -The boot EEPROM is the first 32K of this address space. The lower order\ -15 bits of the address are ignored so the loading process always begins on\ -a 32K byte boundary. If two expressions are provided, the first gives the\ -pin number of the SCL line of the EEPROM while the second expression\ -gives the starting address. The address may be any value from zero to\ -$7FFFF and the upper 3 bits are used to form the device select code.\ -Once the Spin program has been successfully loaded, it begins execution.\ -The loaded Spin program completely replaces the running FemtoBasic.\ -\ -SPIN ""\ -\ -This causes a Spin program to be loaded into the Propeller's main memory\ -from a specified file on an attached SD card. This file should be a copy of\ -the binary form of a Spin program as saved from the Propeller Tool.\ -Once the Spin program has been successfully loaded, it begins execution.\ -The loaded Spin program completely replaces the running FemtoBasic.\ -\ -DUMP , \ -\ -This displays a portion of the Propeller's main memory. The first expression\ -gives the starting address and the second expression gives the number\ -of bytes to be displayed. The information is formatted 8 bytes per line with\ -both hexadecimal and ASCII displayed.\ -\ -DUMP [ \{, \} ] , \ -\ -This displays a portion of the EEPROM. The last expression gives the number\ -of bytes to be displayed. The first portion describes a starting address in EEPROM.\ -See the SPIN statement for a description of the values.\ -\ -COPY [ \{, \} ] , [ \{, \}]\ -\ -This copies a Spin program from the first 32K byte EEPROM "page" specified\ -to the second. As with the SPIN statement, if only one expression is supplied,\ -it provides the starting EEPROM address. If two are supplied, the first is the\ -pin number of the SCL line while the seconds is the EEPROM address.\ -The amount of data copied is taken from the beginning of the Spin program\ -binary file.\ -\ -COPY "" , [ \{, \}]\ -\ -This copies a Spin program from an SD card file to a 32K byte EEPROM "page".\ -\ -COPY [ \{, \} ] , ""\ -\ -This copies a Spin program from a 32K byte EEPROM "page" to an SD card file.\ -\ - -\b \ul BOE-BOT Extensions -\b0 \ulnone \ -\ -The BOE-BOT version of FemtoBasic is similar to the regular version\ -except that it uses a full duplex serial port for its keyboard input and\ -display output and several "pseudo-variables" and statements have\ -been added to control servos, a PING distance sensor, IR distance\ -sensors, and an HM55B compass connected via a PCA9554 I2C\ -I/O Expander. A Propeller Proto Board or equivalent is assumed.\ -\ -The left servo is connected to I/O pin 0, the right servo to pin 1, and the\ -PING bracket servo to pin 2. An IR detector is connected to pin 3 and\ -an IR LED is connected to pin 4. The PING control signal is connected\ -to pin 5. The "console" receive line is pin 6 and the transmit line is pin 7.\ -This "console" is implemented using a configured xBee transceiver.\ -A PCA9554 I2C I/O Expander is connected to the boot EEPROM bus\ -using I/O pins 28 (SCL) and 29 (SDA).\ -\ -The HM55B Ena pin is connected to PCA9554 I/O pin 0. The Clk pin\ -is connected to pin1. DI is connected to pin 2 and DO to pin 3.\ -\ -Two different binary versions are provided. One uses the programming\ -serial port for the "console" (BoeBotBasicUS.binary) and the other uses\ -pins 6 and 7 for wireless operation via an xBee transceiver\ -(BoeBotBasicXB.binary).\ -\ - -\b \ul Expressions -\b0 \ulnone \ -\ -PING\ -\ -This value is the distance in mm of the last PING reading (one-way). It\ -will be zero if a new reading has been initiated, but a value isn't ready yet.\ -\ -IRZONE [ , , ]\ -\ -The first expression is the center frequency (in Hz). The second expression\ -is the number of zones. The third expression is the width of a zone (in Hz).\ -The IR emitter frequency is swept from the last zone to the center frequency\ -with about 200 cycles of each frequency emitted per zone. This value is the\ -number of the first zone where a response is detected (#zones-1 to 0) or -1\ -to indicate that no response was detected.\ -\ -EXPAND [ ]\ -\ -This is the value of the PCA9554 I2C I/O Expander's register whose address\ -is supplied.\ -\ -COMPASS\ -\ -This value is the compass heading in brads (0 to 359 degrees is the same\ -as 0-255).\ -\ - -\b \ul Statements -\b0 \ulnone \ -\ -SRVLEFT \{[ ]\} = \ -SRVRIGHT \{[ ]\} = \ -SRVPING \{[ ]\} = \ -\ -Send a pulse stream to the specified servo with a width (in us) given by the\ -expression on the right side of the assignment. If a square bracketed\ -expression is provided, this is the number of pulses to send (at 20ms intervals).\ -If no pulse count is provided, the pulse train continues indefinitely. If either the\ -pulse count is zero or the pulse width is zero, the pulse train will stop. The\ -pulse width must lie between 500us and 2500us.\ -\ -PING\ -\ -Initiates a new PING cycle. The one-way path length will be zero until the new\ -reading is complete.\ -\ -COMPASS , \ -\ -Reads the raw x and y values of the HM55B compass and assign them to the\ -first and second variables specified respectively.\ -\ -EXPAND [ ] = \ -\ -The PCA9554 I2C I/O Expander's register whose address is supplied is set\ -to the value on the right side of the assignment.\ -\ - -\b \ul IR Buddy Extensions -\b0 \ulnone \ -\ -The IR Buddy version of FemtoBasic is identical to the regular version\ -except that statements have been added to control one or more IR Buddy\ -devices. These may be connected to any otherwise available I/O pin.\ -\ - -\b \ul Statements -\b0 \ulnone \ -\ -IRBSEND \ -\ -The expression is the I/O pin number to be used. This resets the IR Buddy.\ -\ -IRBSEND , \{, \}\ -\ -The first expression is the I/O pin to be used. The remaining expressions\ -are byte values to be sent to the IR Buddy (at 9600 Baud).\ -\ -IRBRECV , , \{, \}\ -\ -The first expression is the I/O pin to be used. The second expression is\ -an initial timeout (in ms) to use. Subsequent timeouts are 10ms. The\ -number of bytes specified are received, one in each variable. If a timeout\ -occurs, that variable and all subsequent ones are set to -1.\ -\ - -\b \ul uOLED-96-Prop Extensions -\b0 \ulnone \ -\ -UOLED SETUP\ -\ -Initialize the uOLED-96-Prop. This must be done before any other operations are done.\ -\ -UOLED START\ -\ -Power up the screen electronics and display any data previously written to graphics RAM.\ -\ -UOLED STOP\ -\ -Power down the screen electronics without disturbing any data in graphics RAM.\ -\ -UOLED LEVEL \ -\ -Set the master contrast setting (range 0-15).\ -\ -UOLED COLOR , , \ -\ -Set the individual color contrast values (range 0-255).\ -\ -UOLED DIM , , , \ -\ -Dim a designated screen window given the coordinates of the left upper corner and the\ -right lower corner.\ -\ -UOLED PIXEL , , , , \ -\ -Writes 2 bytes of color data to the pixel at the coordinate specified. The color information\ -range is 0-255.\ -\ -UOLED SCROLL SETUP , ,
, <# Lines> , \ -\ -X is he number of columns of horizontal offset. Y is the number of lines of vertical offset.\ -Address is the starting line address. # Lines is the number of lines to be scrolled\ -horizontally. Interval is the time interval between scroll steps. 0 = 6 frames, 1 = 10 frames,\ -2 = 100 frames, and 3 = 200 frames.\ -\ -UOLED SCROLL START\ -\ -Activate the scrolling function as set up previously\ -\ -UOLED SCROLL STOP\ -\ -Deactivate the scrolling function\ -\ -UOLED LINE , , , , , , \ -\ -Display a line from the specified left upper corner to the specified right lower corner in the color\ -specified.\ -\ -UOLED RECT , , , , , , \{, , , \}\ -\ -Display a rectangle from the specified left upper corner to the specified right lower corner of the\ -display. The first set of color values is used for the outline color. If the second set of color values\ -is given, it's used for the fill color. If not, the outline color is used for the fill color as well.\ -\ -UOLED COPY , , , , , \ -\ -Copy one area of the display screen to another. The left upper corner and the right lower corner\ -of the source area is supplied followed by the left upper corner of the destination area.\ -\ -UOLED TEXT , , , , , " ... "\ -UOLED TEXT , , , , , \ -\ -Display text using the current font starting at the coordinates provided. These are in terms of character\ -positions, not pixels (range X: 0-11/15, Y: 0-7). Wraparound occurs at the right and bottom of the display.\ -The first form displays the contents of the string while the second form displays the decimally\ -formatted value of the expression given with a leading minus sign if negative. With the 5x7 font, there\ -are 16 characters per line. With the 8x8 font, there are 12 characters per line.\ -\ -UOLED TEXT , , \ -\ -Set the default background color for text. It's set to black during the initialization of FemtoBasic.\ -\ -UOLED TEXT \ -\ -Set the current font. 0 - 5x7 font. 1 - 8x8 font (default).\ -\ -UOLED ERASE\ -\ -Erase the screen (to black).\ -\ -UOLED RESET\ -\ -Resets the display. You must do a UOLED SETUP afterwards.\ -\ -UOLED CIRCLE , , , , , \ -\ -Display a circle whose center is at X,Y and whose radius is Rad using the color specified. If Rad\ -is negative, the circle is filled with the color specified and the radius is the absolute value of Rad.\ -\ -UOLED CIRCLE , , , , , , \ -\ -Display a one eighth circle arc whose center is at X,Y and whose radius is Rad using the color\ -specified. If Rad is negative, the one eighth circle pie slice is filled with the color specified and\ -the radius is the absolute value of Rad. Arc indicates which one eighth circle is to be displayed.\ -1 - 0 to 45 degrees, 2 - 45 to 90 degrees, 3 - 90 to 135 degrees, 4 - 135 to 180 degrees.\ -\ - -\b \ul HC-OSD Extensions -\b0 \ulnone \ -\ -The Hitt Consulting's Overlay Screen Display version uses the PS/2 keyboard for input and the\ -overlay screen driver for output. None of the commands that use SD card files are present.\ -\ - -\b \ul Expressions -\b0 \ulnone \ -\ -SERIAL [ ]\ -\ -The parameter is a timeout in milliseconds. This returns the character received from the 19.2Kbps\ -serial interface or a -1 if the timeout occurs.\ -\ -SERCHK [ ]\ -\ -The parameter is a character. This searches the entire buffered serial input stream for the speciied\ -character and returns true (-1) if the character is present and false (0) otherwise. The serial buffer\ -is not changed.\ -\ -TIME [ ]\ -\ -If the value is between 0 and 6, this returns the binary value of the most recently read time unit\ -(0 - Seconds, 1 - Minutes, 2 - Hours, 3 - Day of Week, 4 - Day, 5 - Month, 6 - Year). If the value\ -is 7, this returns the control register value read from the DS1307. For values from 8 to 63, this\ -returns the value stored in the DS1307's RAM at that address.\ -\ -GPS [ ]\ -\ -If the value is negative, this returns the next character from the GPS serial buffer with the absolute\ -value of the expression used as a timeout in milliseconds. It returns a -1 if the timeout is exceeded.\ -If the value is positive, this returns a character from the saved GPS phrase whose index is the\ -value provided. It returns a -1 if the value is out of range or if there's no saved GPS phrase.\ -\ - -\b \ul Statements -\b0 \ulnone \ -\ -TIME\ -\ -This reads the current time from the DS1307 into an internal buffer used by TIME [ ].\ -\ -TIME [
] = \ -\ -This writes the expression on the right side of the "=" into the control register or RAM whose address\ -is given. Addresses less than 7 or greater than 63 are not allowed.\ -\ -TIME , , , , , , \ -\ -This writes the time / date indicated to the appropriate locations in the DS1307 clock. The values are\ -given in binary and are translated to BCD. The BCD values are also stored in the internal buffer\ -used by TIME [ ]. The BCD values are written to the DS1307 in a single operation.\ -\ -GPS\ -\ -This starts up a background routine (in a cog) that discards any buffered GPS phrase, then begins\ -discarding any buffered serial input up to the first "$" character which begins the next GPS phrase.\ -Characters are then stored in the internal GPS phrase buffer (used by GPS [ ]) until a "*" is\ -seen. The next two characters must be hexadecimal values which are used as a checksum for the\ -phrase. If the checksum is invalid, the phrase is discarded and the routine begins searching for the\ -next phrase. If this background routine is already active, it is stopped and any saved information\ -is discarded before starting it again. Once this background routine successfully finds a complete\ -GPS phrase, it stops itself.\ -} \ No newline at end of file diff --git a/doku/Thumbs.db b/doku/Thumbs.db index 7444299..651471d 100644 Binary files a/doku/Thumbs.db and b/doku/Thumbs.db differ diff --git a/doku/TriOS - Logo 1.jpg b/doku/TriOS - Logo 1.jpg deleted file mode 100644 index 82b891e..0000000 Binary files a/doku/TriOS - Logo 1.jpg and /dev/null differ diff --git a/doku/TriOS-1.jpg b/doku/TriOS-1.jpg deleted file mode 100644 index aa72063..0000000 Binary files a/doku/TriOS-1.jpg and /dev/null differ diff --git a/doku/TriOS.ods b/doku/TriOS.ods deleted file mode 100644 index 325c006..0000000 Binary files a/doku/TriOS.ods and /dev/null differ diff --git a/doku/bellatrix-steuercodes.ods b/doku/bellatrix-steuercodes.ods deleted file mode 100644 index 7ba7eeb..0000000 Binary files a/doku/bellatrix-steuercodes.ods and /dev/null differ diff --git a/doku/TriOS - Logo 2.jpg b/doku/trios-logo.jpg similarity index 100% rename from doku/TriOS - Logo 2.jpg rename to doku/trios-logo.jpg diff --git a/logbuch.txt b/doku/x-logbuch.txt similarity index 91% rename from logbuch.txt rename to doku/x-logbuch.txt index 25556a8..ac39ea1 100644 --- a/logbuch.txt +++ b/doku/x-logbuch.txt @@ -1,3 +1,49 @@ +r57 + +admflash +- plexbusroutinen eingefgt +- sd_del - heartbeat-sound angepasst + +belflash +- per compilerflag whlbare monitorsettings eingefgt (57/60hz) + +basic.mod (propforth) +- bei der installation von trios mit forth muss basic.mod nur noch eingefgt werden, damit wird automatisch geflasht und neu gestartet + +lib: +- adm-enc28j60 eingefgt, treiber netzwerkchip +- adm-socket eingefgt, netzwerksocket +- adm-plx code ausgebaut +- bel-vga monitorsettings +- glob-con plexbus/lan-konstanten eingefgt +- glob-led-engine neue lib fr hbeat-led-pwm +- gui-dlbox - redraw beschleunigt +- gui-wbox - warnbox ist jetzt auch mit tab & esc bedienbar +- m-glob-con - konstanten fr sound und plexbus eingefgt + +reg-ios: +- testfunktion fr rtc +- lan funktionen eingefgt +- plexbus funktionen eingefgt +- printblk - stringausgabe mit lngenangabe + +system/administra: +- admnet eingefgt + +system/regnatix: +- fm - optimierungen und detailverbesserungen +- perplex - plexbus tool zugefgt +- regime - sysinfo zeigt jetzt auch devices am plexbus an +- man - systemklnge angepasst, damit nicht stndig der heartbeat beim lesen luft +- ramtest - anpassungen maske/farben + +dokumentation: +- neustrukturierung der texte + + + + + r56 - 11-05-2013-dr235 und weiter gehts mit dem frhjahresputz: diff --git a/lizenz.txt b/doku/y-lizenz.txt similarity index 93% rename from lizenz.txt rename to doku/y-lizenz.txt index c661b7f..636dd0d 100644 --- a/lizenz.txt +++ b/doku/y-lizenz.txt @@ -17,7 +17,6 @@ Informationen zum Projekt ------------------------------------------------------------------------- http://hive-project.de - Urheberrechtsangabe ------------------------------------------------------------------------- -Copyright (c) 2009 Ingo Kripahle \ No newline at end of file +Copyright (c) 2009 Ingo Kripahle diff --git a/flash/administra/admflash.spin b/flash/administra/admflash.spin index 175bc47..6388b2a 100644 Binary files a/flash/administra/admflash.spin and b/flash/administra/admflash.spin differ diff --git a/flash/bellatrix/belflash.spin b/flash/bellatrix/belflash.spin index da428b3..e2cc80d 100644 Binary files a/flash/bellatrix/belflash.spin and b/flash/bellatrix/belflash.spin differ diff --git a/flash/regnatix/regflash.spin b/flash/regnatix/regflash.spin index 24089db..8d4c0c4 100644 Binary files a/flash/regnatix/regflash.spin and b/flash/regnatix/regflash.spin differ diff --git a/forth/basics.mod b/forth/basics.mod index aa7be0a..463403a 100644 --- a/forth/basics.mod +++ b/forth/basics.mod @@ -481,5 +481,9 @@ wvariable lcog \ nummer interaktiven cog : _ob onboot ; : onboot _ob start ; +saveforth + +reboot + diff --git a/installation.txt b/installation.txt deleted file mode 100644 index e627eec..0000000 --- a/installation.txt +++ /dev/null @@ -1,275 +0,0 @@ - -1. Installation des Grundsystems -2. Regime im Überblick -3. Forth im Überblick - - - - -1. Installation des Grundsystems: -================================= - -TriOS kann in zwei Versionen installiert werden: Mit oder ohne Forth als integrierte Programmiersprache. Als Standard wird das System ohne Forth installiert. Die Installation ist so für den Einsteiger einfacher. Möchte man auch PropForth installieren, muß nur eine Konfiguration geändert werden und ein Basiswortschatz im Forth selbst kompiliert werden. - -WICHTIG: Das System kann nur mit Brat's Spin Tool - kurz BST - compiliert werden. In den Einstellungen des Compilers (Tools/Compiler Preferences/Search Paths) muss das lib-Verzeichnis eingetragen werden. - -Downloadlink BST: http://www.fnarfbargle.com/bst.html - - - -Installation ohne Forth (Standard): ------------------------------------ - -1. Mikrocontroller flashen: - -\flash\administra\admflash.spin --> Administra -\flash\bellatrix\belflash.spin --> Bellatrix -\flash\regnatix\regflash.spin --> Regnatix - - -Installation mit Forth: ------------------------ - -1. Mikrocontroller flashen: - -\flash\administra\admflash.spin --> Administra -\flash\bellatrix\belflash.spin --> Bellatrix -\flash\regnatix\regflash.spin --> Regnatix - -2. Der Schalter bleibt ab jetzt auf Regnatix stehen. Ein Terminalprogramm (ich verwende Tera Term) starten und 57600 Baud auf die Schnittstelle vom Hive (DIP steht auf Regnatix!) einstellen. Nach einem Reset meldet sich das Propforth im Terminalprogramm auf dem Hostcomputer. Datei "forth\basics.mod" in einem Editor öffnen, alles markieren, kopieren und im Terminal einfügen. Der Quelltext wird jetzt im Forth compiliert. - -3. Im Terminalfenster, also im Forth, dass Kommendo "saveforth" eingeben. Damit wird das gesamte Forthsystem mit der gerade neu compilierten Erweiterungen wieder im EEPROM als Image gespeichert. - -Nach einem Reset sollte sich das Forth jetzt komplett mit seinem Prompt sowohl auf dem angeschlossenen VGA-Monitor, als auch im Terminal melden. Im Prinzip benötigen wir nun das Terminalprogramm nicht mehr und können direkt am Hive arbeiten. Später, wenn man in Forth programmiert, ist die vorhandene Terminalschnittstelle aber manchmal sehr nützlich. - - - -Erstellen der SDCard: ---------------------- - -Im Prinzip kann jede normale FAT16/32 Karte verwendet werden. Lange Dateinamen werden nicht verwendet, Unterverzeichnisse sind kein Problem. Es ist sinnvoll, alle Dateien aus dem Verzeichnis "bin\sd-card\" auf die SD-Karte zu kopieren. - -Das Verzeichnis "system" hat eine besondere Bedeutung: Hier sollten sich die Tools, Erweiterungen und Bibliotheken befinden. Im PropForth: Mit dem Kommando "sys name.f" kann aus jedem anderen Verzeichnis ohne Wechsel eine Datei name.f im Verzeichnis System geladen und compiliert werden. - - - -Systemstart: ------------- - -Beim Systemstart wird immer das Forth aus dem EEPROM gestartet. So kann, wie mit den klassischen Homecomputern, sofort unkompliziert programmiert werden. Neben dem Forth gibt es im TriOS noch ein in Spin programmiertes Betriebssystem, welches sich dem Benutzer durch den Kommandointerpreter Regime präsentiert. Aus dem Forth kann diese mit dem Kommando "regime" gestartet werden. Im Gegenzug kann im laufenden Regime mit dem Kommando "forth" wieder zur integrierten Programmiersprache gewechselt werden. - -Wurde TriOS ohne Forth installiert, wird der Loader aus dem EEPROM gestartet und sofort die Kommandozeile "Regime" aus der Datei reg.sys gestartet. - - - - -3. Regime im Überblick -====================== - -Da wir ja drei verschiedene Teilsystem in unserem Computer haben, muss Regime wissen, für welchen Chip eine ausführbare Datei bestimmt ist. Den Typ ausführbarer Dateien kann Regime automatisch anhand der Dateinamenserweiterung unterscheiden: - -*.bin Regnatix-Code -*.bel Bellatrix-Code -*.adm Administra-Code - -Dabei genügt es, den Namen ohne Erweiterung einzugeben. Dennoch kann es vorkommen, das man eine normale Spin-Datei mit einer beliebigen Erweiterung gespeichert hat. Diese Datei kann man dann mit den Kommandos rload, aload oder bload ganz gezielt in einen Chip laden. - - - bin/adm/bel-datei wird gestartet -mount - SD-aufwerk mounten -unmount - SD-Laufwerk freigeben -dir wh - Verzeichnis anzeigen -type - Anzeige einer Textdatei -aload - Administra-Code laden -bload - Bellatrix-Code laden -rload - Regnatix-Code laden -del - Datei löschen -cls - Bildschirm löschen -free - Anzeige des freien Speichers auf SD-Card -attrib ashr - Dateiattribute ändern -cd - Verzeichnis wechseln -mkdir - Verzeichnis erstellen -rename - datei/verzeichnis umbenennen -format - SD-Laufwerk formatieren -reboot - Hive neu starten -sysinfo - Systeminformationen -color <0..7> - Farbe wählen -cogs - Belegung der COG's anzeigen -dmlist - Anzeige der Verzeichnis-Marker -dm - Marker-Verzeichnis wechseln -dmset - Marker setzen -dmclr - Marker löschen -forth - Forth starten - -Marker: -r - Marker für Root-Verzeichnis -s - Marker für System-Verzeichnis -u - Marker für User-Verzeichnis -a/b/c - Benutzerdefinierte Verzeichnismarker - -Die r, s, u-Marker werden vom System automatisch gesetzt und intern verwendet. - -RAMDISK: - -xload - Datei von SD-Laufwerk in RAM laden -xsave - Datei aus RAM auf SD-Laufwerk speichern -xdir - Verzeichnis im RAM anzeigen -xrename - Datei im RAM umbenennen -xdel - Datei im RAM löschen -xtype - Textdatei im RAM anzeigen - - - -EXTERNE KOMMANDOS: ------------------- - -Die meisten Kommandozeilentools zeigen mit dem Parameter /? eine Liste der Optionen an. - -sysconf - Systemeinstellungen -hplay - HSS-Player -wplay - WAV-Player -splay - SID-Player -yplay - Yamaha-Soundchip-Player -sfxtool - HSS-Soundeffekte erstellen - -vga.bin - VGA 1024 x 768 Pixel, 64 x 24 Zeichen -htext.bin - VGA 1024 x 768 Pixel, 128 x 48 Zeichen -tv.bin - TV-Textmodus 40 x 13 Zeichen - - - - -2. Forth im Überblick: -====================== - -Einige nützliche Kommandos befinden sich in dem Modul tools.mod. In den meisten Fällen ist es sinnvoll dieses Modul mit der Befehlssequenz "sys tools.mod saveforth" fest im Forth einzubinden. - - - -Wichtige Tastencodes: ---------------------- - -[ESC]-1 Screen 1, COG 1 -[ESC]-2 Screen 2, COG 2 -[ESC]-3 Screen 3, COG 3 -[ESC]-b Break, Reset der aktuellen COG -[ESC]-r Reset, Neustart Regnatix - - - -Wichtige Kommandos: -------------------- - -load - Datei laden und comilieren, Ausgabe Screen 3 -dload - wie load, aber Ausgabe aktueller Screen -sys - Datei aus sys-Verzeichnis laden und compilieren -ls - Dateiliste -lsl - Dateiliste- Long-Format -cd - in Verzeichniss wechseln -mount - SD-Card einbinden -unmount - SD-Card freigeben -words - Anzeige Wöterbuch -mod? - (tools.mod) Anzeige compilierter Erweiterungen -lib? - (tools.mod) Anzeige compilierter Bibliotheken -cog? - (tools.mod) Anzeige COG-Liste -cat - (tools.mod) Ausgabe einer Textdatei -less - (tools.mod) Zeilenweise Textausgabe -dm? - (tools.mod) Anzeige der Systemverzeichnisse -regime - CLI starten -aload - Adminsitra-Code laden -bload - Bellatrix-Code laden -spin - Spin-Programm starten - - - -Wichtige Dateien: ------------------ - -Die Dateien *.mod und *.lib enthalten ganz normale Forth-Quelltexte. Damit hat man schnell eine Übersicht über die grobe Funktion dieser Quellen: Lib's sind halt reine Sammlungen von Worten zu einer bestimmten Funktionsgruppe und MOD's sind mehr oder weniger fertige und abgeschlossene Programme. Ein Beispiel: - -Die Datei hss.lib enthält Worte um die HSS-Funktionen von Administra anzusprechen. Mit diesen Funktionen kann man nun ein Modul (Programm) wie einen HSS-Soundplayer schreiben. - -Im Gegensatz dazu die Datei splay.mod: Mit diesem Modul wird ein HSS-Soundplayer ins System eingefügt, welcher Funktionen aus der hss.lib verwendet. - -Die Datei benötigt man aber mehr oder weniger nur zur Entwicklung, ein fertiges Modul wie splay.mod enthält dann schon die die entsprechenden HSS-Worte die benötigt werden. - -Die ifnot: ... Anweisung sorgt dabei dafür, dass keine Funktionen doppelt in das Wörterbuch compiliert werden. Das ist quasi ein verteiltes und fein granuliertes Konzept analog zu einer DLL. Die Forth-Version funktioniert dabei aber im Gegensatz zu DLL's nicht auf Bibliotheks-, sondern auf Funktionsebene. - -*.mod Module, Forth-Erweiterungen für das System -*.lib Bibliotheken, grundlegende Wortsammlungen -*.adm Administra-Code (z.Bsp. admsid.adm für SIDCog-Code) -*.bel Bellatrix-Code -*.bin Spin-Code, im Normalfall zur Ausführung in Regnatix - -basics.f - (mod:basics) Hive-Core für PropForth -ari.lib - (lib:ari) Zusätzliche arithmetische Funktionen -cog.lib - (lib:cog) Zusätzliche COG-Funktionen -adm.lib - (lib:adm) Administra-Chipmanagment-Funktionen -hss.lib - (lib:hss) Bibliothek für Hydra-Sound-System -sfx.lib - (lib:sfx) Soundeffekt-Bibliothek -wav.lib - (lib:wav) Wave-Soundbibliothek - -bel.lib - (lib:bel) Bellatrix-Chipmanagment-Funktionen -key.lib - (lib:key) Tastatur-Bibliothek -scr.lib - (lib:scr) Screen-Bibliothek -sd0.lib - (lib:sd0) SD-Card-Bibliothek - -debug.f - Nützliche Worte zur Fehlersuche und Entwicklung -rom.f - EEPROM-Dateisystem -tools.f - Nützliche Tools (cat, less, dm?...) -hplay.f - HSS-Player -wplay.f - WAV-Player -splay.f - SID-Player - -Administra-Codedateien im SYS-Verzeichnis: - -admled.adm Testprogramm - HBeat-LED blinken lassen -admsid.adm SidCog-Version (wird von splay benötigt) -admsys.adm Standardcode für ADM mit SD/HSS/WAV -admym.adm Yamaha-Soundchip-Version -aterm96.adm Mini-OS für Administra (Testzwecke) - - - -Reset-Fehlercodes: ------------------- - -0011FFFF - stack overflow -0012FFFF - return stack overflow -0021FFFF - stack underflow -0022FFFF - return stack underflow -8100FFFF - no free cogs -8200FFFF - no free main memory -8400FFFF - fl no free main memory -8500FFFF - no free cog memory -8800FFFF - eeprom write error -9000FFFF - eeprom read error - - - -.err-Fehlercodes: ------------------ - -0 no error -1 fsys unmounted -2 fsys corrupted -3 fsys unsupported -4 not found -5 file not found -6 dir not found -7 file read only -8 end of file -9 end of directory -10 end of root -11 dir is full -12 dir is not empty -13 checksum error -14 reboot error -15 bpb corrupt -16 fsi corrupt -17 dir already exist -18 file already exist -19 out of disk free space -20 disk io error -21 command not found -22 timeout -23 parameter error diff --git a/lib/adm-enc28j60.spin b/lib/adm-enc28j60.spin new file mode 100644 index 0000000..c1c1eb0 --- /dev/null +++ b/lib/adm-enc28j60.spin @@ -0,0 +1,1042 @@ +{{ + ENC28J60 Ethernet MAC / PHY Driver + ---------------------------------- + + Copyright (c) 2006-2009 Harrison Pham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + The latest version of this software can be obtained from + http://hdpham.com/PropTCP and http://obex.parallax.com/ + + Constant Names / Code Logic based on code from + Microchip Technology, Inc.'s enc28j60.c / enc28j60.h source files +}} + +CON + version = 6 ' major version + release = 0 ' minor version + +CON +' *************************************** +' ** ENC28J60 SRAM Defines ** +' *************************************** + ' ENC28J60 Frequency + enc_freq = 25_000_000 + + ' ENC28J60 SRAM Usage Constants + MAXFRAME = 1518 ' 6 (src addr) + 6 (dst addr) + 2 (type) + 1500 (data) + 4 (FCS CRC) = 1518 bytes + TX_BUFFER_SIZE = 1518 + + TXSTART = 8192 - (TX_BUFFER_SIZE + 8) + TXEND = TXSTART + (TX_BUFFER_SIZE + 8) + RXSTART = $0000 + RXSTOP = (TXSTART - 2) | $0001 ' must be odd (B5 Errata) + RXSIZE = (RXSTOP - RXSTART + 1) + +DAT +' *************************************** +' ** MAC Address Vars / Defaults ** +' *************************************** + ' ** This is the default MAC address used by this driver. The parent object + ' can override this by passing a pointer to a new MAC address in the public + ' start() method. It is recommend that this is done to provide a level of + ' abstraction and makes tcp stack design easier. + ' ** This is the ethernet MAC address, it is critical that you change this + ' if you have more than one device using this code on a local network. + ' ** If you plan on commercial deployment, you must purchase MAC address + ' groups from IEEE or some other standards organization. + eth_mac byte $02, $00, $00, $00, $00, $01 + +' *************************************** +' ** Global Variables ** +' *************************************** + rxlen word 0 + tx_end word 0 + + packetheader byte 0[6] + + 'packet byte 0[MAXFRAME] + +PUB start(_cs, _sck, _si, _so, xtalout, macptr) +'' Starts the driver (uses 1 cog for spi engine) + + ' Since some people don't have 25mhz crystals, we use the cog counters + ' to generate a 25mhz frequency for the ENC28J60 (I love the Propeller) + ' Note: This requires a main crystal that is a multiple of 25mhz (5mhz works). + spi_start(_cs, _sck, _so, _si, xtalout) + + ' If a MAC address pointer is provided (addr > -1) then copy it into + ' the MAC address array (this kind of wastes space, but simplifies usage). + if macptr > -1 + bytemove(@eth_mac, macptr, 6) + + delay_ms(50) + init_ENC28J60 + + ' return the chip silicon version + banksel(EREVID) + return rd_cntlreg(EREVID) + +PUB stop +'' Stops the driver, frees 1 cog + + spi_stop + +PUB rd_macreg(address) : data +'' Read MAC Control Register + + spi_out_cs(cRCR | address) + spi_out_cs(0) ' transmit dummy byte + data := spi_in ' get actual data + +PUB rd_cntlreg(address) : data +'' Read ETH Control Register + + spi_out_cs(cRCR | address) + data := spi_in + +PUB wr_reg(address, data) +'' Write MAC and ETH Control Register + + spi_out_cs(cWCR | address) + spi_out(data) + +PUB bfc_reg(address, data) +'' Clear Control Register Bits + + spi_out_cs(cBFC | address) + spi_out(data) + +PUB bfs_reg(address, data) +'' Set Control Register Bits + + spi_out_cs(cBFS | address) + spi_out(data) + +PUB soft_reset +'' Soft Reset ENC28J60 + + spi_out(cSC) + +PUB banksel(register) +'' Select Control Register Bank + + bfc_reg(ECON1, %0000_0011) + bfs_reg(ECON1, register >> 8) ' high byte + +PUB rd_phy(register) | low, high +'' Read ENC28J60 PHY Register + + banksel(MIREGADR) + wr_reg(MIREGADR, register) + wr_reg(MICMD, MICMD_MIIRD) + banksel(MISTAT) + repeat while ((rd_macreg(MISTAT) & MISTAT_BUSY) > 0) + banksel(MIREGADR) + wr_reg(MICMD, $00) + low := rd_macreg(MIRDL) + high := rd_macreg(MIRDH) + return (high << 8) + low + +PUB wr_phy(register, data) +'' Write ENC28J60 PHY Register + + banksel(MIREGADR) + wr_reg(MIREGADR, register) + wr_reg(MIWRL, data) + wr_reg(MIWRH, data >> 8) + banksel(MISTAT) + repeat while ((rd_macreg(MISTAT) & MISTAT_BUSY) > 0) + +PUB rd_sram : data +'' Read ENC28J60 8k Buffer Memory + + spi_out_cs(cRBM) + data := spi_in + +PUB wr_sram(data) +'' Write ENC28J60 8k Buffer Memory + + spi_out_cs(cWBM) + spi_out(data) + +PUB init_ENC28J60 | i +'' Init ENC28J60 Chip + + repeat + i := rd_cntlreg(ESTAT) + while (i & $08) OR (!i & ESTAT_CLKRDY) + + soft_reset + delay_ms(5) ' reset delay + + bfc_reg(ECON1, ECON1_RXEN) ' stop send / recv + bfc_reg(ECON1, ECON1_TXRTS) + + bfs_reg(ECON2, ECON2_AUTOINC) ' enable auto increment of sram pointers (already default) + + packetheader[nextpacket_low] := RXSTART + packetheader[nextpacket_high] := constant(RXSTART >> 8) + + banksel(ERDPTL) + wr_reg(ERDPTL, RXSTART) + wr_reg(ERDPTH, constant(RXSTART >> 8)) + + banksel(ERXSTL) + wr_reg(ERXSTL, RXSTART) + wr_reg(ERXSTH, constant(RXSTART >> 8)) + wr_reg(ERXRDPTL, RXSTOP) + wr_reg(ERXRDPTH, constant(RXSTOP >> 8)) + wr_reg(ERXNDL, RXSTOP) + wr_reg(ERXNDH, constant(RXSTOP >> 8)) + wr_reg(ETXSTL, TXSTART) + wr_reg(ETXSTH, constant(TXSTART >> 8)) + + banksel(MACON1) + wr_reg(MACON1, constant(MACON1_TXPAUS | MACON1_RXPAUS | MACON1_MARXEN)) + wr_reg(MACON3, constant(MACON3_TXCRCEN | MACON3_PADCFG0 | MACON3_FRMLNEN)) + + ' don't timeout transmissions on saturated media + wr_reg(MACON4, MACON4_DEFER) + ' collisions occur at 63rd byte + wr_reg(MACLCON2, 63) + + wr_reg(MAIPGL, $12) + wr_reg(MAIPGH, $0C) + wr_reg(MAMXFLL, MAXFRAME) + wr_reg(MAMXFLH, constant(MAXFRAME >> 8)) + + ' back-to-back inter-packet gap time + ' full duplex = 0x15 (9.6us) + ' half duplex = 0x12 (9.6us) + wr_reg(MABBIPG, $12) + wr_reg(MAIPGL, $12) + wr_reg(MAIPGH, $0C) + + ' write mac address to the chip + banksel(MAADR1) + wr_reg(MAADR1, eth_mac[0]) + wr_reg(MAADR2, eth_mac[1]) + wr_reg(MAADR3, eth_mac[2]) + wr_reg(MAADR4, eth_mac[3]) + wr_reg(MAADR5, eth_mac[4]) + wr_reg(MAADR6, eth_mac[5]) + + ' half duplex + wr_phy(PHCON2, PHCON2_HDLDIS) + wr_phy(PHCON1, $0000) + + ' set LED options + wr_phy(PHLCON, $0742) ' $0472 => ledA = link, ledB = tx/rx + ' $0742 => ledA = tx/rx, ledB = link + + ' enable packet reception + bfs_reg(ECON1, ECON1_RXEN) + +PUB get_frame(pktptr) | packet_addr, new_rdptr +'' Get Ethernet Frame from Buffer + + banksel(ERDPTL) + wr_reg(ERDPTL, packetheader[nextpacket_low]) + wr_reg(ERDPTH, packetheader[nextpacket_high]) + + repeat packet_addr from 0 to 5 + packetheader[packet_addr] := rd_sram + + rxlen := (packetheader[rec_bytecnt_high] << 8) + packetheader[rec_bytecnt_low] + + 'bytefill(@packet, 0, MAXFRAME) ' Uncomment this if you want to clean out the buffer first + ' otherwise, leave commented since it's faster to just leave stuff + ' in the buffer + + ' protect from oversized packet + if rxlen =< MAXFRAME + rd_block(pktptr, rxlen) + {repeat packet_addr from 0 to rxlen - 1 + BYTE[@packet][packet_addr] := rd_sram} + + new_rdptr := (packetheader[nextpacket_high] << 8) + packetheader[nextpacket_low] + + ' handle errata read pointer start (must be odd) + --new_rdptr + + if (new_rdptr < RXSTART) OR (new_rdptr > RXSTOP) + new_rdptr := RXSTOP + + bfs_reg(ECON2, ECON2_PKTDEC) + + banksel(ERXRDPTL) + wr_reg(ERXRDPTL, new_rdptr) + wr_reg(ERXRDPTH, new_rdptr >> 8) + +PUB start_frame +'' Start frame - Inits the NIC and sets stuff + + banksel(EWRPTL) + wr_reg(EWRPTL, TXSTART) + wr_reg(EWRPTH, constant(TXSTART >> 8)) + + tx_end := constant(TXSTART - 1) ' start location is really address 0, so we are sending a count of - 1 + + wr_frame(cTXCONTROL) + +PUB wr_frame(data) +'' Write frame data + + wr_sram(data) + ++tx_end + +PUB wr_block(startaddr, count) + blockwrite(startaddr, count) + tx_end += count + +PUB rd_block(startaddr, count) + blockread(startaddr, count) + +PUB send_frame +'' Sends frame +'' Will retry on send failure up to 15 times with a 1ms delay in between repeats + + repeat 15 + if p_send_frame ' send packet, if successful then quit retry loop + quit + delay_ms(1) + +PRI p_send_frame | i, eirval +' Sends the frame + banksel(ETXSTL) + wr_reg(ETXSTL, TXSTART) + wr_reg(ETXSTH, constant(TXSTART >> 8)) + + banksel(ETXNDL) + wr_reg(ETXNDL, tx_end) + wr_reg(ETXNDH, tx_end >> 8) + + ' B5 Errata #10 - Reset transmit logic before send + bfs_reg(ECON1, ECON1_TXRST) + bfc_reg(ECON1, ECON1_TXRST) + + ' B5 Errata #10 & #13: Reset interrupt error flags + bfc_reg(EIR, constant(EIR_TXERIF | EIR_TXIF)) + + ' trigger send + bfs_reg(ECON1, ECON1_TXRTS) + + ' fix for transmit stalls (derived from errata B5 #13), watches TXIF and TXERIF bits + ' also implements a ~3.75ms (15 * 250us) timeout if send fails (occurs on random packet collisions) + ' btw: this took over 10 hours to fix due to the elusive undocumented bug + i := 0 + repeat + eirval := rd_cntlreg(EIR) + if ((eirval & constant(EIR_TXERIF | EIR_TXIF)) > 0) + quit + if (++i => 15) + eirval := EIR_TXERIF + quit + delay_us(250) + + ' B5 Errata #13 - Reset TXRTS if failed send then reset logic + bfc_reg(ECON1, ECON1_TXRTS) + + if ((eirval & EIR_TXERIF) == 0) + return true ' successful send (no error interrupt) + else + return false ' failed send (error interrupt) + +PUB get_mac_pointer +'' Gets mac address pointer + return @eth_mac + +PUB get_rxlen +'' Gets received packet length + return rxlen - 4 ' knock off the 4 byte Frame Check Sequence CRC, not used anywhere outside of this driver (pg 31 datasheet) + +PRI delay_us(Duration) + waitcnt(((clkfreq / 1_000_000 * Duration - 3928)) + cnt) + +PRI delay_ms(Duration) + waitcnt(((clkfreq / 1_000 * Duration - 3932)) + cnt) + +' *************************************** +' ** ASM SPI Engine ** +' *************************************** +DAT + cog long 0 + command long 0 + +CON + SPIOUT = %0000_0001 + SPIIN = %0000_0010 + SRAMWRITE = %0000_0100 + SRAMREAD = %0000_1000 + CSON = %0001_0000 + CSOFF = %0010_0000 + CKSUM = %0100_0000 + + SPIBITS = 8 + +PRI spi_out(value) + setcommand(constant(SPIOUT | CSON | CSOFF), @value) + +PRI spi_out_cs(value) + setcommand(constant(SPIOUT | CSON), @value) + +PRI spi_in : value + setcommand(constant(SPIIN | CSON | CSOFF), @value) + +PRI spi_in_cs : value + setcommand(constant(SPIIN | CSON), @value) + +PRI blockwrite(startaddr, count) + setcommand(SRAMWRITE, @startaddr) + +PRI blockread(startaddr, count) + setcommand(SRAMREAD, @startaddr) + +PUB chksum_add(startaddr, count) + setcommand(CKSUM, @startaddr) + return startaddr + +PRI spi_start(_cs, _sck, _di, _do, _freqpin) + spi_stop + + cspin := |< _cs + dipin := |< _di + dopin := |< _do + clkpin := |< _sck + + ctramode := %0_00100_00_0000_0000_0000_0000_0000_0000 + _sck + ctrbmode := %0_00100_00_0000_0000_0000_0000_0000_0000 + _do + + spi_setupfreqsynth(_freqpin) + + cog := cognew(@init, @command) + 1 + +PRI spi_stop + if cog + cogstop(cog~ - 1) + ctra := 0 + command~ + +PRI setcommand(cmd, argptr) + command := cmd << 16 + argptr 'write command and pointer + repeat while command 'wait for command to be cleared, signifying receipt + +PRI spi_setupfreqsynth(pin) + + if pin < 0 + ' pin num was negative -> disable freq synth + return + + dira[pin] := 1 + + ctra := constant(%00010 << 26) '..set PLL mode + ctra |= constant((>|((enc_freq - 1) / 1_000_000)) << 23) 'set PLLDIV + + frqa := spi_fraction(enc_freq, CLKFREQ, constant(4 - (>|((enc_freq - 1) / 1_000_000)))) 'Compute FRQA/FRQB value + ctra |= pin 'set PINA to complete CTRA/CTRB value + +PRI spi_fraction(a, b, shift) : f + + if shift > 0 'if shift, pre-shift a or b left + a <<= shift 'to maintain significant bits while + if shift < 0 'insuring proper result + b <<= -shift + + repeat 32 'perform long division of a/b + f <<= 1 + if a => b + a -= b + f++ + a <<= 1 + +DAT + org +init or dira, cspin 'pin directions + andn dira, dipin + or dira, dopin + or dira, clkpin + + or outa, cspin 'turn off cs (bring it high) + + mov frqb, #0 'disable ctrb increment + mov ctrb, ctrbmode + + +loop wrlong zero,par 'zero command (tell spin we are done processing) +:subloop rdlong t1,par wz 'wait for command + if_z jmp #:subloop + + mov addr, t1 'used for holding return addr to spin vars + + rdlong arg0, t1 'arg0 + add t1, #4 + rdlong arg1, t1 'arg1 + + mov lkup, addr 'get the command var from spin + shr lkup, #16 'extract the cmd from the command var + + test lkup, #CSON wz 'turn on cs + if_nz andn outa, cspin + + test lkup, #SPIOUT wz 'spi out + if_nz call #spi_out_ + test lkup, #SPIIN wz 'spi in + if_nz call #xspi_in_ + test lkup, #SRAMWRITE wz 'sram block write + if_nz jmp #sram_write_ + test lkup, #SRAMREAD wz 'sram block read + if_nz jmp #sram_read_ + + test lkup, #CSOFF wz 'cs off + if_nz or outa, cspin + + test lkup, #CKSUM wz 'perform checksum + if_nz call #csum16 + + jmp #loop ' no cmd found + + +spi_out_ andn outa, clkpin + shl arg0, #24 + mov phsb, arg0 ' data to write + mov frqa, freqw ' 20MHz write frequency + mov phsa, #0 ' start at clocking at 0 + + mov ctra, ctramode ' send data @ 20MHz + rol phsb, #1 + rol phsb, #1 + rol phsb, #1 + rol phsb, #1 + rol phsb, #1 + rol phsb, #1 + rol phsb, #1 + mov ctra, #0 ' disable + andn outa, clkpin + +spi_out__ret ret + + +spi_in_ andn outa, clkpin + mov phsa, phsr ' start phs for clock + mov frqa, freqr ' 10MHz read frequency + nop + + mov ctra, ctramode ' start clocking + test dipin, ina wc + rcl arg0, #1 + test dipin, ina wc + rcl arg0, #1 + test dipin, ina wc + rcl arg0, #1 + test dipin, ina wc + rcl arg0, #1 + test dipin, ina wc + rcl arg0, #1 + test dipin, ina wc + rcl arg0, #1 + test dipin, ina wc + rcl arg0, #1 + test dipin, ina wc + mov ctra, #0 ' stop clocking + rcl arg0, #1 + andn outa, clkpin + +spi_in__ret ret + +xspi_in_ call #spi_in_ + wrbyte arg0, addr ' write byte back to spin result var +xspi_in__ret ret + +' SRAM Block Read/Write +sram_write_ ' block write (arg0=hub addr, arg1=count) + mov t1, arg0 + mov t2, arg1 + + andn outa, cspin + mov arg0, #cWBM + call #spi_out_ +:loop rdbyte arg0, t1 + call #spi_out_ + add t1, #1 + djnz t2, #:loop + or outa, cspin + + jmp #loop + +sram_read_ ' block read (arg0=hub addr, arg1=count) + mov t1, arg0 + mov t2, arg1 + + andn outa, cspin + mov arg0, #cRBM + call #spi_out_ +:loop call #spi_in_ + wrbyte arg0, t1 + add t1, #1 + djnz t2, #:loop + or outa, cspin + + jmp #loop + +csum16 ' performs checksum 16bit additions on the data + ' arg0=hub addr, arg1=length, writes sum to first arg + mov t1, #0 ' clear sum +:loop rdbyte t2, arg0 ' read two bytes (16 bits) + add arg0, #1 + rdbyte t3, arg0 + add arg0, #1 + shl t2, #8 ' build the word + add t2, t3 + add t1, t2 ' add numbers + mov t2, t1 ' add lower and upper words together + shr t2, #16 + and t1, hffff + add t1, t2 + sub arg1, #2 + cmp arg1, #1 wz, wc + if_nc_and_nz jmp #:loop + if_z rdbyte t2, arg0 ' add last byte (odd) + if_z shl t2, #8 + if_z add t1, t2 + wrlong t1, addr ' return result back to SPIN +csum16_ret ret + +zero long 0 'constants + + 'values filled by spin code before launching +cspin long 0 ' chip select pin +dipin long 0 ' data in pin (enc28j60 -> prop) +dopin long 0 ' data out pin (prop -> enc28j60) +clkpin long 0 ' clock pin (prop -> enc28j60) +ctramode long 0 ' ctr mode for CLK +ctrbmode long 0 ' ctr mode for SPI Out + +hffff long $FFFF + +freqr long $2000_0000 'frequency of SCK /8 for receive +freqw long $4000_0000 'frequency of SCK /4 for send +phsr long $6000_0000 + + 'temp variables +t1 res 1 ' loop and cog shutdown +t2 res 1 ' loop and cog shutdown +t3 res 1 ' Used to hold DataValue SHIFTIN/SHIFTOUT +t4 res 1 ' Used to hold # of Bits +t5 res 1 ' Used for temporary data mask + +addr res 1 ' Used to hold return address of first Argument passed +lkup res 1 ' Used to hold command lookup + + 'arguments passed to/from high-level Spin +arg0 res 1 ' bits / start address +arg1 res 1 ' value / count + +CON +' *************************************** +' ** ENC28J60 Control Constants ** +' *************************************** + ' ENC28J60 opcodes (OR with 5bit address) + cWCR = %010 << 5 ' write control register command + cBFS = %100 << 5 ' bit field set command + cBFC = %101 << 5 ' bit field clear command + cRCR = %000 << 5 ' read control register command + cRBM = (%001 << 5) | $1A ' read buffer memory command + cWBM = (%011 << 5) | $1A ' write buffer memory command + cSC = (%111 << 5) | $1F ' system command + + ' This is used to trigger TX in the ENC28J60, it shouldn't change, but you never know... + cTXCONTROL = $0E + + ' Packet header format (tail of the receive packet in the ENC28J60 SRAM) + #0,nextpacket_low,nextpacket_high,rec_bytecnt_low,rec_bytecnt_high,rec_status_low,rec_status_high + +' *************************************** +' ** ENC28J60 Register Defines ** +' *************************************** + ' Bank 0 registers -------- + ERDPTL = $00 + ERDPTH = $01 + EWRPTL = $02 + EWRPTH = $03 + ETXSTL = $04 + ETXSTH = $05 + ETXNDL = $06 + ETXNDH = $07 + ERXSTL = $08 + ERXSTH = $09 + ERXNDL = $0A + ERXNDH = $0B + ERXRDPTL = $0C + ERXRDPTH = $0D + ERXWRPTL = $0E + ERXWRPTH = $0F + EDMASTL = $10 + EDMASTH = $11 + EDMANDL = $12 + EDMANDH = $13 + EDMADSTL = $14 + EDMADSTH = $15 + EDMACSL = $16 + EDMACSH = $17 + ' = $18 + ' = $19 + ' r = $1A + EIE = $1B + EIR = $1C + ESTAT = $1D + ECON2 = $1E + ECON1 = $1F + + ' Bank 1 registers ----- + EHT0 = $100 + EHT1 = $101 + EHT2 = $102 + EHT3 = $103 + EHT4 = $104 + EHT5 = $105 + EHT6 = $106 + EHT7 = $107 + EPMM0 = $108 + EPMM1 = $109 + EPMM2 = $10A + EPMM3 = $10B + EPMM4 = $10C + EPMM5 = $10D + EPMM6 = $10E + EPMM7 = $10F + EPMCSL = $110 + EPMCSH = $111 + ' = $112 + ' = $113 + EPMOL = $114 + EPMOH = $115 + EWOLIE = $116 + EWOLIR = $117 + ERXFCON = $118 + EPKTCNT = $119 + ' r = $11A + ' EIE = $11B + ' EIR = $11C + ' ESTAT = $11D + ' ECON2 = $11E + ' ECON1 = $11F + + ' Bank 2 registers ----- + MACON1 = $200 + MACON2 = $201 + MACON3 = $202 + MACON4 = $203 + MABBIPG = $204 + ' = $205 + MAIPGL = $206 + MAIPGH = $207 + MACLCON1 = $208 + MACLCON2 = $209 + MAMXFLL = $20A + MAMXFLH = $20B + ' r = $20C + MAPHSUP = $20D + ' r = $20E + ' = $20F + ' r = $210 + MICON = $211 + MICMD = $212 + ' = $213 + MIREGADR = $214 + ' r = $215 + MIWRL = $216 + MIWRH = $217 + MIRDL = $218 + MIRDH = $219 + ' r = $21A + ' EIE = $21B + ' EIR = $21C + ' ESTAT = $21D + ' ECON2 = $21E + ' ECON1 = $21F + + ' Bank 3 registers ----- + + MAADR5 = $300 + MAADR6 = $301 + MAADR3 = $302 + MAADR4 = $303 + MAADR1 = $304 + MAADR2 = $305 + + {MAADR1 = $300 + MAADR0 = $301 + MAADR3 = $302 + MAADR2 = $303 + MAADR5 = $304 + MAADR4 = $305} + + EBSTSD = $306 + EBSTCON = $307 + EBSTCSL = $308 + EBSTCSH = $309 + MISTAT = $30A + ' = $30B + ' = $30C + ' = $30D + ' = $30E + ' = $30F + ' = $310 + ' = $311 + EREVID = $312 + ' = $313 + ' = $314 + ECOCON = $315 + ' EPHTST $316 + EFLOCON = $317 + EPAUSL = $318 + EPAUSH = $319 + ' r = $31A + ' EIE = $31B + ' EIR = $31C + ' ESTAT = $31D + ' ECON2 = $31E + ' ECON1 = $31F + + {****************************************************************************** + * PH Register Locations + ******************************************************************************} + PHCON1 = $00 + PHSTAT1 = $01 + PHID1 = $02 + PHID2 = $03 + PHCON2 = $10 + PHSTAT2 = $11 + PHIE = $12 + PHIR = $13 + PHLCON = $14 + + {****************************************************************************** + * Individual Register Bits + ******************************************************************************} + ' ETH/MAC/MII bits + + ' EIE bits ---------- + EIE_INTIE = (1<<7) + EIE_PKTIE = (1<<6) + EIE_DMAIE = (1<<5) + EIE_LINKIE = (1<<4) + EIE_TXIE = (1<<3) + EIE_WOLIE = (1<<2) + EIE_TXERIE = (1<<1) + EIE_RXERIE = (1) + + ' EIR bits ---------- + EIR_PKTIF = (1<<6) + EIR_DMAIF = (1<<5) + EIR_LINKIF = (1<<4) + EIR_TXIF = (1<<3) + EIR_WOLIF = (1<<2) + EIR_TXERIF = (1<<1) + EIR_RXERIF = (1) + + ' ESTAT bits --------- + ESTAT_INT = (1<<7) + ESTAT_LATECOL = (1<<4) + ESTAT_RXBUSY = (1<<2) + ESTAT_TXABRT = (1<<1) + ESTAT_CLKRDY = (1) + + ' ECON2 bits -------- + ECON2_AUTOINC = (1<<7) + ECON2_PKTDEC = (1<<6) + ECON2_PWRSV = (1<<5) + ECON2_VRTP = (1<<4) + ECON2_VRPS = (1<<3) + + ' ECON1 bits -------- + ECON1_TXRST = (1<<7) + ECON1_RXRST = (1<<6) + ECON1_DMAST = (1<<5) + ECON1_CSUMEN = (1<<4) + ECON1_TXRTS = (1<<3) + ECON1_RXEN = (1<<2) + ECON1_BSEL1 = (1<<1) + ECON1_BSEL0 = (1) + + ' EWOLIE bits ------- + EWOLIE_UCWOLIE = (1<<7) + EWOLIE_AWOLIE = (1<<6) + EWOLIE_PMWOLIE = (1<<4) + EWOLIE_MPWOLIE = (1<<3) + EWOLIE_HTWOLIE = (1<<2) + EWOLIE_MCWOLIE = (1<<1) + EWOLIE_BCWOLIE = (1) + + ' EWOLIR bits ------- + EWOLIR_UCWOLIF = (1<<7) + EWOLIR_AWOLIF = (1<<6) + EWOLIR_PMWOLIF = (1<<4) + EWOLIR_MPWOLIF = (1<<3) + EWOLIR_HTWOLIF = (1<<2) + EWOLIR_MCWOLIF = (1<<1) + EWOLIR_BCWOLIF = (1) + + ' ERXFCON bits ------ + ERXFCON_UCEN = (1<<7) + ERXFCON_ANDOR = (1<<6) + ERXFCON_CRCEN = (1<<5) + ERXFCON_PMEN = (1<<4) + ERXFCON_MPEN = (1<<3) + ERXFCON_HTEN = (1<<2) + ERXFCON_MCEN = (1<<1) + ERXFCON_BCEN = (1) + + ' MACON1 bits -------- + MACON1_LOOPBK = (1<<4) + MACON1_TXPAUS = (1<<3) + MACON1_RXPAUS = (1<<2) + MACON1_PASSALL = (1<<1) + MACON1_MARXEN = (1) + + ' MACON2 bits -------- + MACON2_MARST = (1<<7) + MACON2_RNDRST = (1<<6) + MACON2_MARXRST = (1<<3) + MACON2_RFUNRST = (1<<2) + MACON2_MATXRST = (1<<1) + MACON2_TFUNRST = (1) + + ' MACON3 bits -------- + MACON3_PADCFG2 = (1<<7) + MACON3_PADCFG1 = (1<<6) + MACON3_PADCFG0 = (1<<5) + MACON3_TXCRCEN = (1<<4) + MACON3_PHDRLEN = (1<<3) + MACON3_HFRMEN = (1<<2) + MACON3_FRMLNEN = (1<<1) + MACON3_FULDPX = (1) + + ' MACON4 bits -------- + MACON4_DEFER = (1<<6) + MACON4_BPEN = (1<<5) + MACON4_NOBKOFF = (1<<4) + MACON4_LONGPRE = (1<<1) + MACON4_PUREPRE = (1) + + ' MAPHSUP bits ---- + MAPHSUP_RSTRMII = (1<<3) + + ' MICON bits -------- + MICON_RSTMII = (1<<7) + + ' MICMD bits --------- + MICMD_MIISCAN = (1<<1) + MICMD_MIIRD = (1) + + ' EBSTCON bits ----- + EBSTCON_PSV2 = (1<<7) + EBSTCON_PSV1 = (1<<6) + EBSTCON_PSV0 = (1<<5) + EBSTCON_PSEL = (1<<4) + EBSTCON_TMSEL1 = (1<<3) + EBSTCON_TMSEL0 = (1<<2) + EBSTCON_TME = (1<<1) + EBSTCON_BISTST = (1) + + ' MISTAT bits -------- + MISTAT_NVALID = (1<<2) + MISTAT_SCAN = (1<<1) + MISTAT_BUSY = (1) + + ' ECOCON bits ------- + ECOCON_COCON2 = (1<<2) + ECOCON_COCON1 = (1<<1) + ECOCON_COCON0 = (1) + + ' EFLOCON bits ----- + EFLOCON_FULDPXS = (1<<2) + EFLOCON_FCEN1 = (1<<1) + EFLOCON_FCEN0 = (1) + + + + ' PHY bits + + ' PHCON1 bits ---------- + PHCON1_PRST = (1<<15) + PHCON1_PLOOPBK = (1<<14) + PHCON1_PPWRSV = (1<<11) + PHCON1_PDPXMD = (1<<8) + + ' PHSTAT1 bits -------- + PHSTAT1_PFDPX = (1<<12) + PHSTAT1_PHDPX = (1<<11) + PHSTAT1_LLSTAT = (1<<2) + PHSTAT1_JBSTAT = (1<<1) + + ' PHID2 bits -------- + PHID2_PID24 = (1<<15) + PHID2_PID23 = (1<<14) + PHID2_PID22 = (1<<13) + PHID2_PID21 = (1<<12) + PHID2_PID20 = (1<<11) + PHID2_PID19 = (1<<10) + PHID2_PPN5 = (1<<9) + PHID2_PPN4 = (1<<8) + PHID2_PPN3 = (1<<7) + PHID2_PPN2 = (1<<6) + PHID2_PPN1 = (1<<5) + PHID2_PPN0 = (1<<4) + PHID2_PREV3 = (1<<3) + PHID2_PREV2 = (1<<2) + PHID2_PREV1 = (1<<1) + PHID2_PREV0 = (1) + + ' PHCON2 bits ---------- + PHCON2_FRCLNK = (1<<14) + PHCON2_TXDIS = (1<<13) + PHCON2_JABBER = (1<<10) + PHCON2_HDLDIS = (1<<8) + + ' PHSTAT2 bits -------- + PHSTAT2_TXSTAT = (1<<13) + PHSTAT2_RXSTAT = (1<<12) + PHSTAT2_COLSTAT = (1<<11) + PHSTAT2_LSTAT = (1<<10) + PHSTAT2_DPXSTAT = (1<<9) + PHSTAT2_PLRITY = (1<<5) + + ' PHIE bits ----------- + PHIE_PLNKIE = (1<<4) + PHIE_PGEIE = (1<<1) + + ' PHIR bits ----------- + PHIR_PLNKIF = (1<<4) + PHIR_PGIF = (1<<2) + + ' PHLCON bits ------- + PHLCON_LACFG3 = (1<<11) + PHLCON_LACFG2 = (1<<10) + PHLCON_LACFG1 = (1<<9) + PHLCON_LACFG0 = (1<<8) + PHLCON_LBCFG3 = (1<<7) + PHLCON_LBCFG2 = (1<<6) + PHLCON_LBCFG1 = (1<<5) + PHLCON_LBCFG0 = (1<<4) + PHLCON_LFRQ1 = (1<<3) + PHLCON_LFRQ0 = (1<<2) + PHLCON_STRCH = (1<<1) \ No newline at end of file diff --git a/lib/adm-plx.spin b/lib/adm-plx.spin index 6917a14..9e7bb54 100644 Binary files a/lib/adm-plx.spin and b/lib/adm-plx.spin differ diff --git a/lib/adm-socket.spin b/lib/adm-socket.spin new file mode 100644 index 0000000..6ecf2e0 --- /dev/null +++ b/lib/adm-socket.spin @@ -0,0 +1,1221 @@ +{{ + Ethernet TCP/IP Socket Layer Driver (IPv4) + ------------------------------------------ + + Copyright (c) 2006-2009 Harrison Pham + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + The latest version of this software can be obtained from + http://hdpham.com/PropTCP and http://obex.parallax.com/ +}} + +'' NOTICE: All buffer sizes must be a power of 2! + +CON +' *************************************** +' ** Versioning Information ** +' *************************************** + version = 5 ' major version + release = 2 ' minor version + apiversion = 8 ' api compatibility version + +' *************************************** +' ** User Definable Settings ** +' *************************************** + sNumSockets = 4 ' max number of concurrent registered sockets (max of 255) + +' *** End of user definable settings, don't edit anything below this line!!! +' *** All IP/MAC settings are defined by calling the start(...) method + +CON +' *************************************** +' ** Return Codes / Errors ** +' *************************************** + + RETBUFFEREMPTY = -1 ' no data available + RETBUFFERFULL = -1 ' buffer full + + ERRGENERIC = -1 ' generic errors + + ERR = -100 ' error codes start at -100 + ERRBADHANDLE = ERR - 1 ' bad socket handle + ERROUTOFSOCKETS = ERR - 2 ' no free sockets available + ERRSOCKETCLOSED = ERR - 3 ' socket closed, could not perform operation + +OBJ + nic : "adm-enc28j60" + + 'ser : "SerialMirror" + 'stk : "Stack Length" + +CON +' *************************************** +' ** Socket Constants and Offsets ** +' *************************************** + +' Socket states (user should never touch these) + SCLOSED = 0 ' closed, handle not used + SLISTEN = 1 ' listening, in server mode + SSYNSENT = 2 ' SYN sent, server mode, waits for ACK + SSYNSENTCL = 3 ' SYN sent, client mode, waits for SYN+ACK + SESTABLISHED = 4 ' established connection (either SYN+ACK, or ACK+Data) + SCLOSING = 5 ' connection is being forced closed by code + SCLOSING2 = 6 ' closing, we are waiting for a fin now + SFORCECLOSE = 7 ' force connection close (just RSTs, no waiting for FIN or anything) + SCONNECTINGARP1 = 8 ' connecting, next step: send arp request + SCONNECTINGARP2 = 9 ' connecting, next step: arp request sent, waiting for response + SCONNECTINGARP2G = 10 ' connecting, next step: arp request sent, waiting for response [GATEWAY REQUEST] + SCONNECTING = 11 ' connecting, next step: got mac address, send SYN + +' *************************************** +' ** TCP State Management Constants ** +' *************************************** + TIMEOUTMS = 500 ' (milliseconds) timeout before a retransmit occurs + RSTTIMEOUTMS = 2000 ' (milliseconds) timeout before a RST is sent to close the connection + WINDOWUPDATEMS = 25 ' (milliseconds) window advertisement frequency + + MAXUNACKS = 6 ' max number of unacknowledged retransmits before the stack auto closes the socket + ' timeout = TIMEOUTMS * MAXUNACKS (default: 500ms * 5 = 3000ms) + + EPHPORTSTART = 49152 ' ephemeral port start + EPHPORTEND = 65535 ' end + + MAXPAYLOAD = 1200 ' maximum TCP payload (data) in bytes, this only applies when your txbuffer_length > payload size + +DAT +' *************************************** +' ** Global Variables ** +' *************************************** + cog long 0 ' cog index (for stopping / starting) + stack long 0[128] ' stack for new cog (currently ~74 longs, using 128 for expansion) + + mac_ptr long 0 ' mac address pointer + + pkt_id long 0 ' packet fragmentation id + pkt_isn long 0 ' packet initial sequence number + + ip_ephport word 0 ' packet ephemeral port number (49152 to 65535) + + pkt_count byte 0 ' packet count + + lock_id byte 0 ' socket handle lock + + packet byte 0[nic#MAXFRAME] ' the ethernet frame + +' *************************************** +' ** IP Address Defaults ** +' *************************************** + ' NOTE: All of the MAC/IP variables here contain default values that will + ' be used if override values are not provided as parameters in start(). + long ' long alignment for addresses + ip_addr byte 10, 10, 1, 4 ' device's ip address + ip_subnet byte 255, 255, 255, 0 ' network subnet + ip_gateway byte 10, 10, 1, 254 ' network gateway (router) + ip_dns byte 10, 10, 1, 254 ' network dns + +' *************************************** +' ** Socket Data Arrays ** +' *************************************** + + long + SocketArrayStart + lMySeqNum long 0[sNumSockets] + lMyAckNum long 0[sNumSockets] + lSrcIp long 0[sNumSockets] + lTime long 0[sNumSockets] + + word + wSrcPort word 0[sNumSockets] + wDstPort word 0[sNumSockets] + wLastWin word 0[sNumSockets] + wLastTxLen word 0[sNumSockets] + wNotAcked word 0[sNumSockets] + + byte + bSrcMac byte 0[sNumSockets * 6] + bConState byte 0[sNumSockets] + SocketArrayEnd + +' *************************************** +' ** Circular Buffer Arrays ** +' *************************************** + word + FifoDataStart + rx_head word 0[sNumSockets] ' rx head array + rx_tail word 0[sNumSockets] ' rx tail array + tx_head word 0[sNumSockets] ' tx head array + tx_tail word 0[sNumSockets] ' tx tail array + + tx_tailnew word 0[sNumSockets] ' the new tx_tail value (unacked data) + + rxbuffer_length word 0[sNumSockets] ' each socket's buffer sizes + txbuffer_length word 0[sNumSockets] + + rxbuffer_mask word 0[sNumSockets] ' each socket's buffer masks for capping buffer sizes + txbuffer_mask word 0[sNumSockets] + + long + tx_bufferptr long 0[sNumSockets] ' pointer addresses to each socket's buffer spaces + rx_bufferptr long 0[sNumSockets] + FifoDataEnd + +PUB start(cs, sck, si, so, xtalout, macptr, ipconfigptr) +'' Start the TCP/IP Stack (requires 2 cogs) +'' Only call this once, otherwise you will get conflicts +'' macptr = HUB memory pointer (address) to 6 contiguous mac address bytes +'' ipconfigptr = HUB memory pointer (address) to ip configuration block (16 bytes) +'' Must be in order: ip_addr, ip_subnet, ip_gateway, ip_dns + + stop + 'stk.Init(@stack, 128) + + ' zero socket data arrays (clean up any dead stuff from previous instance) + bytefill(@SocketArrayStart, 0, @SocketArrayEnd - @SocketArrayStart) + + ' reset buffer pointers, zeros a contigous set of bytes, starting at rx_head + bytefill(@FifoDataStart, 0, @FifoDataEnd - @FifoDataStart) + + ' start new cog with tcp stack + cog := cognew(engine(cs, sck, si, so, xtalout, macptr, ipconfigptr), @stack) + 1 + +PUB stop +'' Stop the driver + + if cog + cogstop(cog~ - 1) ' stop the tcp engine + nic.stop ' stop nic driver (kills spi engine) + lockclr(lock_id) ' clear lock before returning it to the pool + lockret(lock_id) ' return the lock to the lock pool + +PRI engine(cs, sck, si, so, xtalout, macptr, ipconfigptr) | i + + lock_id := locknew ' checkout a lock from the HUB + lockclr(lock_id) ' clear the lock, just in case it was in a bad state + + ' Start the ENC28J60 driver in a new cog + nic.start(cs, sck, si, so, xtalout, macptr) ' init the nic + + if ipconfigptr > -1 ' init ip configuration + bytemove(@ip_addr, ipconfigptr, 16) + + mac_ptr := nic.get_mac_pointer ' get the local mac address pointer + + ip_ephport := EPHPORTSTART ' set initial ephemeral port number (might want to random seed this later) + + i := 0 + nic.banksel(nic#EPKTCNT) ' select packet count bank + repeat + pkt_count := nic.rd_cntlreg(nic#EPKTCNT) + if pkt_count > 0 + service_packet ' handle packet + nic.banksel(nic#EPKTCNT) ' re-select the packet count bank + + ++i + if i > 10 ' perform send tick + repeat while lockset(lock_id) + tick_tcpsend ' occurs every 10 cycles, since incoming packets more important + lockclr(lock_id) + + i := 0 + nic.banksel(nic#EPKTCNT) ' re-select the packet count bank + +PRI service_packet + + ' lets process this frame + nic.get_frame(@packet) + + ' check for arp packet type (highest priority obviously) + if packet[enetpacketType0] == $08 AND packet[enetpacketType1] == $06 + if packet[constant(arp_hwtype + 1)] == $01 AND packet[arp_prtype] == $08 AND packet[constant(arp_prtype + 1)] == $00 AND packet[arp_hwlen] == $06 AND packet[arp_prlen] == $04 + if packet[arp_tipaddr] == ip_addr[0] AND packet[constant(arp_tipaddr + 1)] == ip_addr[1] AND packet[constant(arp_tipaddr + 2)] == ip_addr[2] AND packet[constant(arp_tipaddr + 3)] == ip_addr[3] + case packet[constant(arp_op + 1)] + $01 : handle_arp + $02 : repeat while lockset(lock_id) + handle_arpreply + lockclr(lock_id) + '++count_arp + else + if packet[enetpacketType0] == $08 AND packet[enetpacketType1] == $00 + if packet[ip_destaddr] == ip_addr[0] AND packet[constant(ip_destaddr + 1)] == ip_addr[1] AND packet[constant(ip_destaddr + 2)] == ip_addr[2] AND packet[constant(ip_destaddr + 3)] == ip_addr[3] + case packet[ip_proto] + 'PROT_ICMP : 'handle_ping + 'ser.str(stk.GetLength(0, 0)) + 'stk.GetLength(30, 19200) + '++count_ping + PROT_TCP : repeat while lockset(lock_id) + \handle_tcp ' handles abort out of tcp handlers (no socket found) + lockclr(lock_id) + '++count_tcp + 'PROT_UDP : ++count_udp + +' ******************************* +' ** Protocol Receive Handlers ** +' ******************************* +PRI handle_arp | i + nic.start_frame + + ' destination mac address + repeat i from 0 to 5 + nic.wr_frame(packet[enetpacketSrc0 + i]) + + ' source mac address + repeat i from 0 to 5 + nic.wr_frame(BYTE[mac_ptr][i]) + + nic.wr_frame($08) ' arp packet + nic.wr_frame($06) + + nic.wr_frame($00) ' 10mb ethernet + nic.wr_frame($01) + + nic.wr_frame($08) ' ip proto + nic.wr_frame($00) + + nic.wr_frame($06) ' mac addr len + nic.wr_frame($04) ' proto addr len + + nic.wr_frame($00) ' arp reply + nic.wr_frame($02) + + ' write ethernet module mac address + repeat i from 0 to 5 + nic.wr_frame(BYTE[mac_ptr][i]) + + ' write ethernet module ip address + repeat i from 0 to 3 + nic.wr_frame(ip_addr[i]) + + ' write remote mac address + repeat i from 0 to 5 + nic.wr_frame(packet[enetpacketSrc0 + i]) + + ' write remote ip address + repeat i from 0 to 3 + nic.wr_frame(packet[arp_sipaddr + i]) + + return nic.send_frame + +PRI handle_arpreply | handle, ip, found + ' Gets arp reply if it is a response to an ip we have + + ip := (packet[constant(arp_sipaddr + 3)] << 24) + (packet[constant(arp_sipaddr + 2)] << 16) + (packet[constant(arp_sipaddr + 1)] << 8) + (packet[arp_sipaddr]) + + found := false + if ip == LONG[@ip_gateway] + ' find a handle that wants gateway mac + repeat handle from 0 to constant(sNumSockets - 1) + if bConState[handle] == SCONNECTINGARP2G + found := true + quit + else + ' find the one that wants this arp + repeat handle from 0 to constant(sNumSockets - 1) + if bConState[handle] == SCONNECTINGARP2 + if lSrcIp[handle] == ip + found := true + quit + + if found + bytemove(@bSrcMac[handle * 6], @packet + arp_shaddr, 6) + bConState[handle] := SCONNECTING + +'PRI handle_ping + ' Not implemented yet (save on space!) + +PRI handle_tcp | i, ptr, handle, srcip, dstport, srcport, datain_len + ' Handles incoming TCP packets + + srcip := packet[ip_srcaddr] << 24 + packet[constant(ip_srcaddr + 1)] << 16 + packet[constant(ip_srcaddr + 2)] << 8 + packet[constant(ip_srcaddr + 3)] + dstport := packet[TCP_destport] << 8 + packet[constant(TCP_destport + 1)] + srcport := packet[TCP_srcport] << 8 + packet[constant(TCP_srcport + 1)] + + handle := find_socket(srcip, dstport, srcport) ' if no sockets avail, it will abort out of this function + + ' at this point we assume we have an active socket, or a socket available to be used + datain_len := ((packet[ip_pktlen] << 8) + packet[constant(ip_pktlen + 1)]) - ((packet[ip_vers_len] & $0F) * 4) - (((packet[TCP_hdrlen] & $F0) >> 4) * 4) + + if (bConState[handle] == SSYNSENT OR bConState[handle] == SESTABLISHED) AND (packet[TCP_hdrflags] & TCP_ACK) AND datain_len > 0 + ' ACK, without SYN, with data + + ' set socket state, established session + bConState[handle] := SESTABLISHED + + i := packet[constant(TCP_seqnum + 3)] << 24 + packet[constant(TCP_seqnum + 2)] << 16 + packet[constant(TCP_seqnum + 1)] << 8 + packet[TCP_seqnum] + if lMyAckNum[handle] == i + if datain_len =< (rxbuffer_mask[handle] - ((rx_head[handle] - rx_tail[handle]) & rxbuffer_mask[handle])) + ' we have buffer space + ptr := rx_bufferptr[handle] + if (datain_len + rx_head[handle]) > rxbuffer_length[handle] + bytemove(ptr + rx_head[handle], @packet[TCP_data], rxbuffer_length[handle] - rx_head[handle]) + bytemove(ptr, @packet[TCP_data] + (rxbuffer_length[handle] - rx_head[handle]), datain_len - (rxbuffer_length[handle] - rx_head[handle])) + else + bytemove(ptr + rx_head[handle], @packet[TCP_data], datain_len) + rx_head[handle] := (rx_head[handle] + datain_len) & rxbuffer_mask[handle] + else + datain_len := 0 + + else + ' we had a bad ack number, meaning lost or out of order packet + ' we have to wait for the remote host to retransmit in order + datain_len := 0 + + ' recalculate ack number + lMyAckNum[handle] := conv_endianlong(conv_endianlong(lMyAckNum[handle]) + datain_len) + + ' ACK response + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, TCP_ACK) + send_tcpfinal(handle, 0) + + elseif (bConState[handle] == SSYNSENTCL) AND (packet[TCP_hdrflags] & TCP_SYN) AND (packet[TCP_hdrflags] & TCP_ACK) + ' We got a server response, so we ACK it + + bytemove(@lMySeqNum[handle], @packet + TCP_acknum, 4) + bytemove(@lMyAckNum[handle], @packet + TCP_seqnum, 4) + + lMyAckNum[handle] := conv_endianlong(conv_endianlong(lMyAckNum[handle]) + 1) + + ' ACK response + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, TCP_ACK) + send_tcpfinal(handle, 0) + + ' set socket state, established session + bConState[handle] := SESTABLISHED + + elseif (bConState[handle] == SLISTEN) AND (packet[TCP_hdrflags] & TCP_SYN) + ' Reply to SYN with SYN + ACK + + ' copy mac address so we don't have to keep an ARP table + bytemove(@bSrcMac[handle * 6], @packet + enetpacketSrc0, 6) + + ' copy ip, port data + bytemove(@lSrcIp[handle], @packet + ip_srcaddr, 4) + bytemove(@wSrcPort[handle], @packet + TCP_srcport, 2) + bytemove(@wDstPort[handle], @packet + TCP_destport, 2) + + ' get updated ack numbers + bytemove(@lMyAckNum[handle], @packet + TCP_seqnum, 4) + + lMyAckNum[handle] := conv_endianlong(conv_endianlong(lMyAckNum[handle]) + 1) + lMySeqNum[handle] := conv_endianlong(++pkt_isn) ' Initial seq num (random) + + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, constant(TCP_SYN | TCP_ACK)) + send_tcpfinal(handle, 0) + + ' incremement the sequence number for the next packet (it will be for an established connection) + lMySeqNum[handle] := conv_endianlong(conv_endianlong(lMySeqNum[handle]) + 1) + + ' set socket state, waiting for establish + bConState[handle] := SSYNSENT + + elseif (bConState[handle] == SESTABLISHED OR bConState[handle] == SCLOSING2) AND (packet[TCP_hdrflags] & TCP_FIN) + ' Reply to FIN with RST + + ' get updated sequence and ack numbers (gaurantee we have correct ones to kill connection with) + bytemove(@lMySeqNum[handle], @packet + TCP_acknum, 4) + bytemove(@lMyAckNum[handle], @packet + TCP_seqnum, 4) + + 'LONG[handle_addr + sMyAckNum] := conv_endianlong(conv_endianlong(LONG[handle_addr + sMyAckNum]) + 1) + + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, TCP_RST) + send_tcpfinal(handle, 0) + + ' set socket state, now free + bConState[handle] := SCLOSED + return + + elseif (bConState[handle] == SSYNSENT) AND (packet[TCP_hdrflags] & TCP_ACK) + ' if just an ack, and we sent a syn before, then it's established + ' this just gives us the ability to send on connect + bConState[handle] := SESTABLISHED + + elseif (packet[TCP_hdrflags] & TCP_RST) + ' Reset, reset states + bConState[handle] := SCLOSED + return + + if (bConState[handle] == SESTABLISHED OR bConState[handle] == SCLOSING) AND (packet[TCP_hdrflags] & TCP_ACK) + wNotAcked[handle] := 0 ' reset retransmit counter + ' check to see if our last sent data has been ack'd + i := packet[TCP_acknum] << 24 + packet[constant(TCP_acknum + 1)] << 16 + packet[constant(TCP_acknum + 2)] << 8 + packet[constant(TCP_acknum + 3)] + if i == (conv_endianlong(lMySeqNum[handle]) + wLastTxLen[handle]) + ' we received an ack for our last sent packet, so we update our sequence number and buffer pointers + lMySeqNum[handle] := conv_endianlong(conv_endianlong(lMySeqNum[handle]) + wLastTxLen[handle]) + tx_tail[handle] := tx_tailnew[handle] + wLastTxLen[handle] := 0 + + tcpsend(handle) ' send data + +PRI build_ipheaderskeleton(handle) | hdrlen, hdr_chksum + + bytemove(@packet + ip_destaddr, @lSrcIp[handle], 4) ' Set destination address + + bytemove(@packet + ip_srcaddr, @ip_addr, 4) ' Set source address + + bytemove(@packet + enetpacketDest0, @bSrcMac[handle * 6], 6) ' Set destination mac address + + bytemove(@packet + enetpacketSrc0, mac_ptr, 6) ' Set source mac address + + packet[enetpacketType0] := $08 + packet[constant(enetpacketType0 + 1)] := $00 + + packet[ip_vers_len] := $45 + packet[ip_tos] := $00 + + ++pkt_id + + packet[ip_id] := pkt_id >> 8 ' Used for fragmentation + packet[constant(ip_id + 1)] := pkt_id + + packet[ip_frag_offset] := $40 ' Don't fragment + packet[constant(ip_frag_offset + 1)] := 0 + + packet[ip_ttl] := $80 ' TTL = 128 + + packet[ip_proto] := $06 ' TCP protocol + +PRI build_tcpskeleton(handle, flags) | size + + bytemove(@packet + TCP_srcport, @wDstPort[handle], 2) ' Source port + bytemove(@packet + TCP_destport, @wSrcPort[handle], 2) ' Destination port + + bytemove(@packet + TCP_seqnum, @lMySeqNum[handle], 4) ' Seq Num + bytemove(@packet + TCP_acknum, @lMyAckNum[handle], 4) ' Ack Num + + packet[TCP_hdrlen] := $50 ' Header length + + packet[TCP_hdrflags] := flags ' TCP state flags + + ' we have to recalculate the window size often otherwise our stack + ' might explode from too much data :( + size := (rxbuffer_mask[handle] - ((rx_head[handle] - rx_tail[handle]) & rxbuffer_mask[handle])) + wLastWin[handle] := size + + packet[TCP_window] := (size & $FF00) >> 8 + packet[constant(TCP_window + 1)] := size & $FF + +PRI send_tcpfinal(handle, datalen) | i, tcplen, hdrlen, hdr_chksum + + tcplen := 40 + datalen ' real length = data + headers + + packet[ip_pktlen] := tcplen >> 8 + packet[constant(ip_pktlen + 1)] := tcplen + + ' calc ip header checksum + packet[ip_hdr_cksum] := $00 + packet[constant(ip_hdr_cksum + 1)] := $00 + hdrlen := (packet[ip_vers_len] & $0F) * 4 + hdr_chksum := calc_chksum(@packet[ip_vers_len], hdrlen) + packet[ip_hdr_cksum] := hdr_chksum >> 8 + packet[constant(ip_hdr_cksum + 1)] := hdr_chksum + + ' calc checksum + packet[TCP_cksum] := $00 + packet[constant(TCP_cksum + 1)] := $00 + hdr_chksum := nic.chksum_add(@packet[ip_srcaddr], 8) + hdr_chksum += packet[ip_proto] + i := tcplen - ((packet[ip_vers_len] & $0F) * 4) + hdr_chksum += i + hdr_chksum += nic.chksum_add(@packet[TCP_srcport], i) + hdr_chksum := calc_chksumfinal(hdr_chksum) + packet[TCP_cksum] := hdr_chksum >> 8 + packet[constant(TCP_cksum + 1)] := hdr_chksum + + tcplen += 14 + if tcplen < 60 + tcplen := 60 + + ' protect from buffer overrun + if tcplen => nic#TX_BUFFER_SIZE + return + + ' send the packet + nic.start_frame + nic.wr_block(@packet, tcplen) + nic.send_frame + + lTime[handle] := cnt ' update last sent time (for timeout detection) + +PRI find_socket(srcip, dstport, srcport) | handle, free_handle, listen_handle + ' Search for socket, matches ip address, port states + ' Returns handle address (start memory location of socket) + ' If no matches, will abort with -1 + ' If supplied with srcip = 0 then will return free unused handle, aborts with -1 if none avail + + free_handle := -1 + listen_handle := -1 + repeat handle from 0 to constant(sNumSockets - 1) + if bConState[handle] <> SCLOSED + if (lSrcIp[handle] == 0) OR (lSrcIp[handle] == conv_endianlong(srcip)) + ' ip match, ip socket srcip = 0, then will try to match dst port (find listening socket) + if (wDstPort[handle] == conv_endianword(dstport)) {AND (WORD[handle_addr + sSrcPort] == 0 OR WORD[handle_addr + sSrcPort] == conv_endianword(srcport))} + if wSrcPort[handle] == conv_endianword(srcport) + ' found exact socket match (established socket) + return handle + elseif wSrcPort[handle] == 0 + ' found a partial match (listening socket with no peer) + listen_handle := handle + elseif srcip == 0 + ' found a closed (unallocated) socket, save this as a free handle if we are searching for a free handle + free_handle := handle ' we found a free handle, may need this later + + if srcip <> 0 + ' return the listening handle we found + if listen_handle <> -1 + return listen_handle + else + ' searched for a free handle + if free_handle <> -1 + return free_handle + + ' could not find a matching socket / free socket... + abort -1 + +' ****************************** +' ** Transmit Buffer Handlers ** +' ****************************** +PRI tcpsend(handle) | ptr, len + ' Check buffers for data to send (called in main loop) + + if tx_tail[handle] == tx_head[handle] + ' no data in buffer, so just quit + return + + ' we have data to send, so send it + ptr := tx_bufferptr[handle] + len := ((tx_head[handle] - tx_tail[handle]) & txbuffer_mask[handle]) <# MAXPAYLOAD + if (len + tx_tail[handle]) > txbuffer_length[handle] + bytemove(@packet[TCP_data], ptr + tx_tail[handle], txbuffer_length[handle] - tx_tail[handle]) + bytemove(@packet[TCP_data] + (txbuffer_length[handle] - tx_tail[handle]), ptr, len - (txbuffer_length[handle] - tx_tail[handle])) + else + bytemove(@packet[TCP_data], ptr + tx_tail[handle], len) + tx_tailnew[handle] := (tx_tail[handle] + len) & txbuffer_mask[handle] + + wLastTxLen[handle] := len + + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, TCP_ACK {constant(TCP_ACK | TCP_PSH)}) + send_tcpfinal(handle, len) ' send actual data + + send_tcpfinal(handle, 0) ' send an empty packet to force the other side to ACK (hack to get around delayed acks) + + wNotAcked[handle]++ ' increment unacked packet counter + +PRI tick_tcpsend | handle, state, len + + repeat handle from 0 to constant(sNumSockets - 1) + state := bConState[handle] + + if state == SESTABLISHED OR state == SCLOSING + len := (rxbuffer_mask[handle] - ((rx_head[handle] - rx_tail[handle]) & rxbuffer_mask[handle])) + if wLastWin[handle] <> len AND len => (rxbuffer_length[handle] / 2) AND ((cnt - lTime[handle]) / (clkfreq / 1000) > WINDOWUPDATEMS) + ' update window size + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, TCP_ACK) + send_tcpfinal(handle, 0) + + if ((cnt - lTime[handle]) / (clkfreq / 1000) > TIMEOUTMS) OR wLastTxLen[handle] == 0 + ' send new data OR retransmit our last packet since the other side seems to have lost it + ' the remote host will respond with another dup ack, and we will get back on track (hopefully) + tcpsend(handle) + + if (state == SCLOSING) + + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, constant(TCP_ACK | TCP_FIN)) + send_tcpfinal(handle, 0) + + ' we now wait for the other side to terminate + bConState[handle] := SCLOSING2 + + elseif state == SCONNECTINGARP1 + ' We need to send an arp request + + arp_request_checkgateway(handle) + + elseif state == SCONNECTING + ' Yea! We got an arp response previously, so now we can send the SYN + + lMySeqNum[handle] := conv_endianlong(++pkt_isn) + lMyAckNum[handle] := 0 + + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, TCP_SYN) + send_tcpfinal(handle, 0) + + bConState[handle] := SSYNSENTCL + + elseif (state == SFORCECLOSE) OR (state == SESTABLISHED AND wNotAcked[handle] => MAXUNACKS) OR (lookdown(state: SCLOSING2, SSYNSENT, SSYNSENTCL, SCONNECTINGARP2, SCONNECTINGARP2G) {(state == SCLOSING2 OR state == SSYNSENT)} AND ((cnt - lTime[handle]) / (clkfreq / 1000) > RSTTIMEOUTMS)) + ' Force close (send RST, and say the socket is closed!) + + ' This is triggered when any of the following happens: + ' 1 - we don't get a response to our SSYNSENT state + ' 2 - we exceeded MAXUNACKS tcp retransmits (remote host lost) + ' 3 - we get stuck in the SSCLOSING2 state + ' 4 - we don't get a response to our client SYNSENTCL state + ' 5 - we don't get an ARP response state SCONNECTINGARP2 or SCONNECTINGARP2G + + build_ipheaderskeleton(handle) + build_tcpskeleton(handle, TCP_RST) + send_tcpfinal(handle, 0) + + bConState[handle] := SCLOSED + +PRI arp_request_checkgateway(handle) | ip_ptr + + ip_ptr := @lSrcIp[handle] + + if (BYTE[ip_ptr] & ip_subnet[0]) == (ip_addr[0] & ip_subnet[0]) AND (BYTE[ip_ptr + 1] & ip_subnet[1]) == (ip_addr[1] & ip_subnet[1]) AND (BYTE[ip_ptr + 2] & ip_subnet[2]) == (ip_addr[2] & ip_subnet[2]) AND (BYTE[ip_ptr + 3] & ip_subnet[3]) == (ip_addr[3] & ip_subnet[3]) + arp_request(conv_endianlong(LONG[ip_ptr])) + bConState[handle] := SCONNECTINGARP2 + else + arp_request(conv_endianlong(LONG[@ip_gateway])) + bConState[handle] := SCONNECTINGARP2G + + lTime[handle] := cnt + +PRI arp_request(ip) | i + nic.start_frame + + ' destination mac address (broadcast mac) + repeat i from 0 to 5 + nic.wr_frame($FF) + + ' source mac address (this device) + repeat i from 0 to 5 + nic.wr_frame(BYTE[mac_ptr][i]) + + nic.wr_frame($08) ' arp packet + nic.wr_frame($06) + + nic.wr_frame($00) ' 10mb ethernet + nic.wr_frame($01) + + nic.wr_frame($08) ' ip proto + nic.wr_frame($00) + + nic.wr_frame($06) ' mac addr len + nic.wr_frame($04) ' proto addr len + + nic.wr_frame($00) ' arp request + nic.wr_frame($01) + + ' source mac address (this device) + repeat i from 0 to 5 + nic.wr_frame(BYTE[mac_ptr][i]) + + ' source ip address (this device) + repeat i from 0 to 3 + nic.wr_frame(ip_addr[i]) + + ' unknown mac address area + repeat i from 0 to 5 + nic.wr_frame($00) + + ' figure out if we need router arp request or host arp request + ' this means some subnet masking + + ' dest ip address + repeat i from 3 to 0 + nic.wr_frame(ip.byte[i]) + + ' send the request + return nic.send_frame + +' ******************************* +' ** IP Packet Helpers (Calcs) ** +' ******************************* +PRI calc_chksum(ptr, hdrlen) : chksum + ' Calculates IP checksums + ' packet = pointer to IP packet + ' returns: chksum + ' http://www.geocities.com/SiliconValley/2072/bit33.txt + 'chksum := calc_chksumhalf(packet, hdrlen) + chksum := nic.chksum_add(ptr, hdrlen) + chksum := calc_chksumfinal(chksum) + +PRI calc_chksumfinal(chksumin) : chksum + ' Performs the final part of checksums + chksum := (chksumin >> 16) + (chksumin & $FFFF) + chksum := (!chksum) & $FFFF + +{PRI calc_chksumhalf(packet, hdrlen) : chksum + ' Calculates checksum without doing the final stage of calculations + chksum := 0 + repeat while hdrlen > 1 + chksum += (BYTE[packet++] << 8) + BYTE[packet++] + chksum := (chksum >> 16) + (chksum & $FFFF) + hdrlen -= 2 + if hdrlen > 0 + chksum += BYTE[packet] << 8} + +' *************************** +' ** Memory Access Helpers ** +' *************************** +PRI conv_endianlong(in) + 'return (in << 24) + ((in & $FF00) << 8) + ((in & $FF0000) >> 8) + (in >> 24) ' we can sometimes get away with shifting without masking, since shifts kill extra bits anyways + return (in.byte[0] << 24) + (in.byte[1] << 16) + (in.byte[2] << 8) + (in.byte[3]) + +PRI conv_endianword(in) + 'return ((in & $FF) << 8) + ((in & $FF00) >> 8) + return (in.byte[0] << 8) + (in.byte[1]) + +PRI _handleConvert(userHandle, ptrHandle) | handle +' Checks to see if a handle index is valid +' Aborts if the handle is invalid + + handle := userHandle.byte[0] ' extract the handle index from the lower 8 bits + + if handle < 0 OR handle > constant(sNumSockets - 1) ' check the handle index to make sure we don't go out of bounds + abort ERRBADHANDLE + + ' check handle to make sure it's the one we want (rid ourselves of bad user handles) + ' the current check method is as follows: + ' - compare sDstPort + + if wDstPort[handle] <> ((userHandle.byte[2] << 8) + userHandle.byte[1]) + abort ERRBADHANDLE + + ' if we got here without aborting then we can assume the handle is good + LONG[ptrHandle] := handle + +' ************************************ +' ** Public Accessors (Thread Safe) ** +' ************************************ +PUB listen(port, _ptrrxbuff, _rxlen, _ptrtxbuff, _txlen) | handle +'' Sets up a socket for listening on a port +'' port = port number to listen on +'' ptrrxbuff = pointer to the rxbuffer array +'' rxlen = length of the rxbuffer array (must be power of 2) +'' ptrtxbuff = pointer to the txbuffer array +'' txlen = length of the txbuffer array (must be power of 2) +'' Returns handle if available, ERROUTOFSOCKETS if none available +'' Nonblocking + + repeat while lockset(lock_id) + + ' just find any avail closed socket + handle := \find_socket(0, 0, 0) + + if handle < 0 + lockclr(lock_id) + abort ERROUTOFSOCKETS + + rx_bufferptr[handle] := _ptrrxbuff + tx_bufferptr[handle] := _ptrtxbuff + rxbuffer_length[handle] := _rxlen + txbuffer_length[handle] := _txlen + rxbuffer_mask[handle] := _rxlen - 1 + txbuffer_mask[handle] := _txlen - 1 + + lMySeqNum[handle] := 0 + lMyAckNum[handle] := 0 + lSrcIp[handle] := 0 + lTime[handle] := 0 + wLastTxLen[handle] := 0 + wNotAcked[handle] := 0 + bytefill(@bSrcMac[handle * 6], 0, 6) + + wSrcPort[handle] := 0 ' no source port yet + wDstPort[handle] := conv_endianword(port) ' we do have a dest port though + + wLastWin[handle] := rxbuffer_length[handle] + + tx_head[handle] := 0 + tx_tail[handle] := 0 + tx_tailnew[handle] := 0 + rx_head[handle] := 0 + rx_tail[handle] := 0 + + ' it's now listening + bConState[handle] := SLISTEN + + lockclr(lock_id) + + return ((port.byte[0] << 16) + (port.byte[1] << 8)) + handle + +PUB connect(ipaddr, remoteport, _ptrrxbuff, _rxlen, _ptrtxbuff, _txlen) | handle, user_handle +'' Connect to remote host +'' ipaddr = ipv4 address packed into a long (ie: 1.2.3.4 => $01_02_03_04) +'' remoteport = port number to connect to +'' ptrrxbuff = pointer to the rxbuffer array +'' rxlen = length of the rxbuffer array (must be power of 2) +'' ptrtxbuff = pointer to the txbuffer array +'' txlen = length of the txbuffer array (must be power of 2) +'' Returns handle to new socket, ERROUTOFSOCKETS if no socket available +'' Nonblocking + + repeat while lockset(lock_id) + + ' just find any avail closed socket + handle := \find_socket(0, 0, 0) + + if handle < 0 + lockclr(lock_id) + abort ERROUTOFSOCKETS + + rx_bufferptr[handle] := _ptrrxbuff + tx_bufferptr[handle] := _ptrtxbuff + rxbuffer_length[handle] := _rxlen + txbuffer_length[handle] := _txlen + rxbuffer_mask[handle] := _rxlen - 1 + txbuffer_mask[handle] := _txlen - 1 + + lMySeqNum[handle] := 0 + lMyAckNum[handle] := 0 + lTime[handle] := 0 + wLastTxLen[handle] := 0 + wNotAcked[handle] := 0 + bytefill(@bSrcMac[handle * 6], 0, 6) + + if(ip_ephport => EPHPORTEND) ' constrain ephport to specified range + ip_ephport := EPHPORTSTART + + user_handle := ((ip_ephport.byte[0] << 16) + (ip_ephport.byte[1] << 8)) + handle + + ' copy in ip, port data (with respect to the remote host, since we use same code as server) + lSrcIp[handle] := conv_endianlong(ipaddr) + wSrcPort[handle] := conv_endianword(remoteport) + wDstPort[handle] := conv_endianword(ip_ephport++) + + wLastWin[handle] := rxbuffer_length[handle] + + tx_head[handle] := 0 + tx_tail[handle] := 0 + tx_tailnew[handle] := 0 + rx_head[handle] := 0 + rx_tail[handle] := 0 + + bConState[handle] := SCONNECTINGARP1 + + lockclr(lock_id) + + return user_handle + +PUB close(user_handle) | handle, state +'' Closes a connection + + _handleConvert(user_handle, @handle) + + repeat while lockset(lock_id) + + state := bConState[handle] + + if state == SESTABLISHED + ' try to gracefully close the connection + bConState[handle] := SCLOSING + elseif state <> SCLOSING AND state <> SCLOSING2 + ' we only do an ungraceful close if we are not in ESTABLISHED, CLOSING, or CLOSING2 + bConState[handle] := SCLOSED + + lockclr(lock_id) + + ' wait for the socket to close, this is very important to prevent the client app from reusing the buffers + repeat until (bConState[handle] == SCLOSING2) or (bConState[handle] == SCLOSED) + +PUB isConnected(user_handle) | handle +'' Returns true if the socket is connected, false otherwise + + if \_handleConvert(user_handle, @handle) <> 0 + return false + + return (bConState[handle] == SESTABLISHED) + +PUB isValidHandle(user_handle) | handle +'' Checks to see if the handle is valid, handles will become invalid once they are used +'' In other words, a closed listening socket is now invalid, etc + + {if handle < 0 OR handle > constant(sNumSockets - 1) + ' obviously the handle index is out of range, so it's not valid! + return false} + + if \_handleConvert(user_handle, @handle) < 0 + return false + + return (bConState[handle] <> SCLOSED) + +PUB readDataNonBlocking(user_handle, ptr, maxlen) | handle, len, rxptr +'' Reads bytes from the socket +'' Returns number of read bytes +'' Not blocking (returns RETBUFFEREMPTY if no data) + + _handleConvert(user_handle, @handle) + + if rx_tail[handle] == rx_head[handle] + return RETBUFFEREMPTY + + len := (rx_head[handle] - rx_tail[handle]) & rxbuffer_mask[handle] + if maxlen < len + len := maxlen + + rxptr := rx_bufferptr[handle] + + if (len + rx_tail[handle]) > rxbuffer_length[handle] + bytemove(ptr, rxptr + rx_tail[handle], rxbuffer_length[handle] - rx_tail[handle]) + bytemove(ptr + (rxbuffer_length[handle] - rx_tail[handle]), rxptr, len - (rxbuffer_length[handle] - rx_tail[handle])) + else + bytemove(ptr, rxptr + rx_tail[handle], len) + + rx_tail[handle] := (rx_tail[handle] + len) & rxbuffer_mask[handle] + + return len + +PUB readData(user_handle, ptr, maxlen) : len | handle +'' Reads bytes from the socket +'' Returns the number of read bytes +'' Will block until data is received + + _handleConvert(user_handle, @handle) + + repeat while (len := readDataNonBlocking(user_handle, ptr, maxlen)) < 0 + ifnot isConnected(user_handle) + abort ERRSOCKETCLOSED + +PUB readByteNonBlocking(user_handle) : rxbyte | handle, ptr +'' Read a byte from the specified socket +'' Will not block (returns RETBUFFEREMPTY if no byte avail) + + _handleConvert(user_handle, @handle) + + rxbyte := RETBUFFEREMPTY + if rx_tail[handle] <> rx_head[handle] + ptr := rx_bufferptr[handle] + rxbyte := BYTE[ptr][rx_tail[handle]] + rx_tail[handle] := (rx_tail[handle] + 1) & rxbuffer_mask[handle] + +PUB readByte(user_handle) : rxbyte | handle, ptr +'' Read a byte from the specified socket +'' Will block until a byte is received + + _handleConvert(user_handle, @handle) + + repeat while (rxbyte := readByteNonBlocking(user_handle)) < 0 + ifnot isConnected(user_handle) + abort ERRSOCKETCLOSED + +PUB writeDataNonBlocking(user_handle, ptr, len) | handle, txptr +'' Writes bytes to the socket +'' Will not write anything unless your data fits in the buffer +'' Non blocking (returns RETBUFFERFULL if can't fit data) + + _handleConvert(user_handle, @handle) + + if (txbuffer_mask[handle] - ((tx_head[handle] - tx_tail[handle]) & txbuffer_mask[handle])) < len + return RETBUFFERFULL + + txptr := tx_bufferptr[handle] + + if (len + tx_head[handle]) > txbuffer_length[handle] + bytemove(txptr + tx_head[handle], ptr, txbuffer_length[handle] - tx_head[handle]) + bytemove(txptr, ptr + (txbuffer_length[handle] - tx_head[handle]), len - (txbuffer_length[handle] - tx_head[handle])) + else + bytemove(txptr + tx_head[handle], ptr, len) + + tx_head[handle] := (tx_head[handle] + len) & txbuffer_mask[handle] + + return len + +PUB writeData(user_handle, ptr, len) | handle +'' Writes data to the specified socket +'' Will block until all data is queued to be sent + + _handleConvert(user_handle, @handle) + + repeat while len > txbuffer_mask[handle] + repeat while writeDataNonBlocking(user_handle, ptr, txbuffer_mask[handle]) < 0 + ifnot isConnected(user_handle) + abort ERRSOCKETCLOSED + len -= txbuffer_mask[handle] + ptr += txbuffer_mask[handle] + + repeat while writeDataNonBlocking(user_handle, ptr, len) < 0 + ifnot isConnected(user_handle) + abort ERRSOCKETCLOSED + +PUB writeByteNonBlocking(user_handle, txbyte) | handle, ptr +'' Writes a byte to the specified socket +'' Will not block (returns RETBUFFERFULL if no buffer space available) + + _handleConvert(user_handle, @handle) + + ifnot (tx_tail[handle] <> (tx_head[handle] + 1) & txbuffer_mask[handle]) + return RETBUFFERFULL + + ptr := tx_bufferptr[handle] + BYTE[ptr][tx_head[handle]] := txbyte + tx_head[handle] := (tx_head[handle] + 1) & txbuffer_mask[handle] + + return txbyte + +PUB writeByte(user_handle, txbyte) | handle +'' Write a byte to the specified socket +'' Will block until space is available for byte to be sent + + _handleConvert(user_handle, @handle) + + repeat while writeByteNonBlocking(user_handle, txbyte) < 0 + ifnot isConnected(user_handle) + abort ERRSOCKETCLOSED + +PUB resetBuffers(user_handle) | handle +'' Resets send/receive buffers for the specified socket + + _handleConvert(user_handle, @handle) + + rx_tail[handle] := rx_head[handle] + tx_head[handle] := tx_tail[handle] + +PUB flush(user_handle) | handle +'' Flushes the send buffer (waits till the buffer is empty) +'' Will block until all tx data is sent + + _handleConvert(user_handle, @handle) + + repeat while isConnected(user_handle) AND tx_tail[handle] <> tx_head[handle] + +PUB getSocketState(user_handle) | handle +'' Gets the socket state (internal state numbers) +'' You can include driver_socket in any object and use the S... state constants for comparison + + _handleConvert(user_handle, @handle) + + return bConState[handle] + +PUB getReceiveBufferCount(user_handle) | handle +'' Returns the number of bytes in the receive buffer + + _handleConvert(user_handle, @handle) + + return (rx_head[handle] - rx_tail[handle]) & rxbuffer_mask[handle] + +CON + '****************************************************************** + '* TCP Flags + '****************************************************************** + TCP_FIN = 1 + TCP_SYN = 2 + TCP_RST = 4 + TCP_PSH = 8 + TCP_ACK = 16 + TCP_URG = 32 + TCP_ECE = 64 + TCP_CWR = 128 + '****************************************************************** + '* Ethernet Header Layout + '****************************************************************** + enetpacketDest0 = $00 'destination mac address + enetpacketDest1 = $01 + enetpacketDest2 = $02 + enetpacketDest3 = $03 + enetpacketDest4 = $04 + enetpacketDest5 = $05 + enetpacketSrc0 = $06 'source mac address + enetpacketSrc1 = $07 + enetpacketSrc2 = $08 + enetpacketSrc3 = $09 + enetpacketSrc4 = $0A + enetpacketSrc5 = $0B + enetpacketType0 = $0C 'type/length field + enetpacketType1 = $0D + enetpacketData = $0E 'IP data area begins here + '****************************************************************** + '* ARP Layout + '****************************************************************** + arp_hwtype = $0E + arp_prtype = $10 + arp_hwlen = $12 + arp_prlen = $13 + arp_op = $14 + arp_shaddr = $16 'arp source mac address + arp_sipaddr = $1C 'arp source ip address + arp_thaddr = $20 'arp target mac address + arp_tipaddr = $26 'arp target ip address + '****************************************************************** + '* IP Header Layout + '****************************************************************** + ip_vers_len = $0E 'IP version and header length 1a19 + ip_tos = $0F 'IP type of service + ip_pktlen = $10 'packet length + ip_id = $12 'datagram id + ip_frag_offset = $14 'fragment offset + ip_ttl = $16 'time to live + ip_proto = $17 'protocol (ICMP=1, TCP=6, UDP=11) + ip_hdr_cksum = $18 'header checksum 1a23 + ip_srcaddr = $1A 'IP address of source + ip_destaddr = $1E 'IP addess of destination + ip_data = $22 'IP data area + '****************************************************************** + '* TCP Header Layout + '****************************************************************** + TCP_srcport = $22 'TCP source port + TCP_destport = $24 'TCP destination port + TCP_seqnum = $26 'sequence number + TCP_acknum = $2A 'acknowledgement number + TCP_hdrlen = $2E '4-bit header len (upper 4 bits) + TCP_hdrflags = $2F 'TCP flags + TCP_window = $30 'window size + TCP_cksum = $32 'TCP checksum + TCP_urgentptr = $34 'urgent pointer + TCP_data = $36 'option/data + '****************************************************************** + '* IP Protocol Types + '****************************************************************** + PROT_ICMP = $01 + PROT_TCP = $06 + PROT_UDP = $11 + '****************************************************************** + '* ICMP Header + '****************************************************************** + ICMP_type = ip_data + ICMP_code = ICMP_type+1 + ICMP_cksum = ICMP_code+1 + ICMP_id = ICMP_cksum+2 + ICMP_seqnum = ICMP_id+2 + ICMP_data = ICMP_seqnum+2 + '****************************************************************** + '* UDP Header + '****************************************************************** + UDP_srcport = ip_data + UDP_destport = UDP_srcport+2 + UDP_len = UDP_destport+2 + UDP_cksum = UDP_len+2 + UDP_data = UDP_cksum+2 + '****************************************************************** + '* DHCP Message + '****************************************************************** + DHCP_op = UDP_data + DHCP_htype = DHCP_op+1 + DHCP_hlen = DHCP_htype+1 + DHCP_hops = DHCP_hlen+1 + DHCP_xid = DHCP_hops+1 + DHCP_secs = DHCP_xid+4 + DHCP_flags = DHCP_secs+2 + DHCP_ciaddr = DHCP_flags+2 + DHCP_yiaddr = DHCP_ciaddr+4 + DHCP_siaddr = DHCP_yiaddr+4 + DHCP_giaddr = DHCP_siaddr+4 + DHCP_chaddr = DHCP_giaddr+4 + DHCP_sname = DHCP_chaddr+16 + DHCP_file = DHCP_sname+64 + DHCP_options = DHCP_file+128 + DHCP_message_end = DHCP_options+312 diff --git a/lib/bel-vga.spin b/lib/bel-vga.spin index bd9321d..8beec4d 100644 Binary files a/lib/bel-vga.spin and b/lib/bel-vga.spin differ diff --git a/lib/fm-con.spin b/lib/fm-con.spin index 440d4b0..06f31b0 100644 --- a/lib/fm-con.spin +++ b/lib/fm-con.spin @@ -52,9 +52,6 @@ FL_SEL = %0000_0001 'eintrag ist selektiert FL_FOCUS = %0000_0001 'box ist selektiert -DR_SD = 0 -DR_RAM = 1 -DR_BLK = 2 PUB dummy diff --git a/lib/glob-con.spin b/lib/glob-con.spin index d8116e9..054c660 100644 Binary files a/lib/glob-con.spin and b/lib/glob-con.spin differ diff --git a/lib/glob-led-engine.spin b/lib/glob-led-engine.spin new file mode 100644 index 0000000..b93a494 --- /dev/null +++ b/lib/glob-led-engine.spin @@ -0,0 +1,100 @@ +{{ +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// E555 Light Emitting Diode Engine +// +// Author: Kwabena W. Agyeman +// Updated: 7/27/2010 +// Designed For: P8X32A +// Version: 1.1 +// +// Copyright (c) 2010 Kwabena W. Agyeman +// See end of file for terms of use. +// +// Update History: +// +// v1.0 - Original release - 1/26/2010. +// v1.1 - Added support for variable pin assignments - 7/27/2010. +// +// For each included copy of this object only one spin interpreter should access it at a time. +// +// Nyamekye, +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// LED Circuit: +// +// LEDPinNumber --- LED Driver (Active High). +// +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +}} + +PUB LEDFrequency(newFrequency, LEDPinNumber) '' 11 Stack Longs + +'' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +'' // Changes the light emitting diode frequency using the SPIN interpreter's counters. Brightness will be set to zero. +'' // +'' // NewFrequency - The new frequency. Between 0 Hz and 80MHz @ 80MHz. -1 to reset the pin and counter modules. +'' // LEDPinNumber - Pin to use to drive the LED circuit. Between 0 and 31. +'' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + LEDSetup((newFrequency <> -1), LEDPinNumber, true) + + newFrequency := ((newFrequency <# clkfreq) #> 0) + + result := 1 + repeat 32 + + newFrequency <<= 1 + result <-= 1 + if(newFrequency => clkfreq) + newFrequency -= clkfreq + result += 1 + + frqa := result~ + +PUB LEDBrightness(newBrightness, LEDPinNumber) '' 11 Stack Longs + +'' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +'' // Changes the light emitting diode brightness using the SPIN interpreter's counters. Frequency will be set to zero. +'' // +'' // NewBrightness - The new brightness. Between 0% and 100%. -1 to reset the pin and counter modules. +'' // LEDPinNumber - Pin to use to drive the LED circuit. Between 0 and 31. +'' //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + LEDSetup((newBrightness <> -1), LEDPinNumber, false) + + frqb := (((newBrightness <# 100) #> 0) * constant(posx / 50)) + +PRI LEDSetup(activeOrInactive, LEDPinNumber, frequencyOrBrightness) ' 6 Stack Longs + + LEDPinNumber := ((LEDPinNumber <# 31) #> 0) + + dira[LEDPinNumber] := activeOrInactive + outa[LEDPinNumber] := false + + ctra := (((constant(%0_0100 << 26) + LEDPinNumber) & activeOrInactive) & frequencyOrBrightness) + ctrb := (((constant(%0_0110 << 26) + LEDPinNumber) & activeOrInactive) & (not(frequencyOrBrightness))) + + spr[2 - frequencyOrBrightness] := 0 + spr[10 - frequencyOrBrightness] := 0 + spr[12 - frequencyOrBrightness] := 0 + +{{ + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// TERMS OF USE: MIT License +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, +// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the +// Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +}} \ No newline at end of file diff --git a/lib/gui-dlbox.spin b/lib/gui-dlbox.spin index b1da091..d837cef 100644 Binary files a/lib/gui-dlbox.spin and b/lib/gui-dlbox.spin differ diff --git a/lib/gui-input.spin b/lib/gui-input.spin index 6833922..1a3941c 100644 Binary files a/lib/gui-input.spin and b/lib/gui-input.spin differ diff --git a/lib/gui-pbar.spin b/lib/gui-pbar.spin index fd55f07..5773ea1 100644 Binary files a/lib/gui-pbar.spin and b/lib/gui-pbar.spin differ diff --git a/lib/gui-wbox.spin b/lib/gui-wbox.spin index 3eeb167..9c46e3e 100644 Binary files a/lib/gui-wbox.spin and b/lib/gui-wbox.spin differ diff --git a/lib/m-glob-con.spin b/lib/m-glob-con.spin index 2092455..6c54049 100644 Binary files a/lib/m-glob-con.spin and b/lib/m-glob-con.spin differ diff --git a/lib/reg-ios.spin b/lib/reg-ios.spin index eaa424d..f797535 100644 Binary files a/lib/reg-ios.spin and b/lib/reg-ios.spin differ diff --git a/make.bat b/make.bat index 0d0f944..10b48ee 100644 --- a/make.bat +++ b/make.bat @@ -54,6 +54,7 @@ REM htxt, g0key %BSTC% -L %libpath% -b -O a .\system\administra\admsid\admsid.spin %BSTC% -L %libpath% -b -O a .\system\administra\admay\admay.spin +%BSTC% -L %libpath% -b -O a .\system\administra\admnet\admnet.spin rename *.binary *.adm %BSTC% -L %libpath% -b -O a .\system\bellatrix\bel-htext\htext.spin diff --git a/make.log b/make.log index 8b1c461..bc36ba2 100644 --- a/make.log +++ b/make.log @@ -1,9 +1,9 @@ H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>date /T -10.05.2013 +21.06.2014 H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>time /T -20:53 +18:38 H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>REM Pfade @@ -43,10 +43,11 @@ Loading Object adm-hss Loading Object adm-wav Loading Object adm-rtc Loading Object adm-com +Loading Object adm-plx Loading Object glob-con -Program size is 13400 longs +Program size is 14352 longs 2 Constants folded -Compiled 2950 Lines of Code in 0,275 Seconds +Compiled 3179 Lines of Code in 1,759 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>copy admflash.binary ".\bin\flash" 1 Datei(en) kopiert. @@ -67,7 +68,7 @@ Loading Object bel-bus Loading Object glob-con Program size is 7620 longs 25 Constants folded -Compiled 1589 Lines of Code in 0,153 Seconds +Compiled 1625 Lines of Code in 0,679 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>copy belflash.binary ".\bin\flash" 1 Datei(en) kopiert. @@ -88,7 +89,7 @@ Loading Object bel-bus Loading Object glob-con Program size is 7660 longs 27 Constants folded -Compiled 1644 Lines of Code in 0,124 Seconds +Compiled 1680 Lines of Code in 0,669 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>rename belflash.binary tv.bel @@ -100,7 +101,7 @@ Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object regflash Program size is 32580 longs -Compiled 694 Lines of Code in 0,174 Seconds +Compiled 693 Lines of Code in 0,179 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>move regflash.binary ".\bin\flash" 1 Datei(en) verschoben. @@ -120,9 +121,9 @@ Loading Object regime Loading Object reg-ios Loading Object glob-con Loading Object glob-string -Program size is 9736 longs +Program size is 9868 longs 2 Constants folded -Compiled 2694 Lines of Code in 0,152 Seconds +Compiled 2868 Lines of Code in 0,739 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>rename regime.binary reg.sys @@ -146,7 +147,7 @@ Loading Object adm-rtc.spin Loading Object adm-sid Loading Object glob-con Program size is 12112 longs -Compiled 2486 Lines of Code in 0,19 Seconds +Compiled 2522 Lines of Code in 1,519 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\administra\admay\admay.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -157,7 +158,24 @@ Loading Object adm-rtc.spin Loading Object adm-ay Loading Object glob-con Program size is 8344 longs -Compiled 1975 Lines of Code in 0,129 Seconds +Compiled 2011 Lines of Code in 0,82 Seconds + +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\administra\admnet\admnet.spin +Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved +Compiled for i386 Win32 at 08:17:48 on 2009/07/20 +Loading Object admnet +Loading Object adm-fat +Loading Object adm-rtc.spin +Loading Object adm-hss +Loading Object adm-rtc +Loading Object adm-com +Loading Object adm-socket +Loading Object adm-enc28j60 +Loading Object glob-con +Loading Object glob-numbers +Program size is 21952 longs +4 Constants folded +Compiled 4722 Lines of Code in 1,789 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>rename *.binary *.adm @@ -169,7 +187,7 @@ Loading Object bel-htext Loading Object bel-keyb Program size is 6656 longs 12 Constants folded -Compiled 958 Lines of Code in 0,098 Seconds +Compiled 958 Lines of Code in 0,119 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\bellatrix\bel-g0\g0key.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -179,14 +197,15 @@ Loading Object bel-tv Loading Object glob-con Program size is 7156 longs 1 Constants folded -Compiled 2130 Lines of Code in 0,105 Seconds +Compiled 2166 Lines of Code in 0,529 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>rename *.binary *.bel H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>move *.adm ".\bin\sdcard\system" H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\admay.adm +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\admnet.adm H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\admsid.adm - 2 Datei(en) verschoben. + 3 Datei(en) verschoben. H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>move *.bel ".\bin\sdcard\system" H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\g0key.bel @@ -212,9 +231,9 @@ Loading Object admtest Loading Object reg-ios Loading Object glob-con Loading Object glob-string -Program size is 8204 longs -1 Constants folded -Compiled 2504 Lines of Code in 0,119 Seconds +Program size is 8616 longs +2 Constants folded +Compiled 2666 Lines of Code in 0,139 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\beltest.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -223,9 +242,9 @@ Loading Object beltest Loading Object reg-ios Loading Object glob-con Loading Object glob-string -Program size is 6380 longs -5 Constants folded -Compiled 2384 Lines of Code in 0,105 Seconds +Program size is 6792 longs +6 Constants folded +Compiled 2546 Lines of Code in 0,74 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\charmap.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -233,9 +252,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object charmap Loading Object reg-ios Loading Object glob-con -Program size is 2252 longs -1 Constants folded -Compiled 1813 Lines of Code in 0,061 Seconds +Program size is 2664 longs +2 Constants folded +Compiled 1975 Lines of Code in 0,5 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\eram.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -244,9 +263,9 @@ Loading Object eram Loading Object glob-numbers Loading Object reg-ios Loading Object glob-con -Program size is 7348 longs +Program size is 7364 longs 2 Constants folded -Compiled 2775 Lines of Code in 0,129 Seconds +Compiled 2937 Lines of Code in 0,23 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\flash.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -256,9 +275,9 @@ Loading Object reg-ios Loading Object glob-con Loading Object glob-sdspi Loading Object glob-numbers -Program size is 7144 longs -7 Constants folded -Compiled 3188 Lines of Code in 0,131 Seconds +Program size is 7556 longs +8 Constants folded +Compiled 3350 Lines of Code in 0,889 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\fm.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -272,9 +291,9 @@ Loading Object gui-pbar Loading Object gui-wbox Loading Object gui-input Loading Object glob-string -Program size is 7640 longs -19 Constants folded -Compiled 2612 Lines of Code in 0,177 Seconds +Program size is 8276 longs +22 Constants folded +Compiled 2833 Lines of Code in 0,79 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\fterm.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -283,9 +302,21 @@ Loading Object fterm Loading Object reg-ios Loading Object glob-con Loading Object glob-fds -Program size is 2656 longs -1 Constants folded -Compiled 1993 Lines of Code in 0,08 Seconds +Program size is 3068 longs +2 Constants folded +Compiled 2155 Lines of Code in 0,719 Seconds + +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\ftp.spin +Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved +Compiled for i386 Win32 at 08:17:48 on 2009/07/20 +Loading Object ftp +Loading Object reg-ios +Loading Object glob-con +Loading Object glob-string +Loading Object glob-numbers +Program size is 7444 longs +8 Constants folded +Compiled 2900 Lines of Code in 0,839 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\g0test.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -293,9 +324,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object g0test Loading Object reg-ios Loading Object glob-con -Program size is 5984 longs -39 Constants folded -Compiled 2302 Lines of Code in 0,091 Seconds +Program size is 6396 longs +40 Constants folded +Compiled 2464 Lines of Code in 0,32 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\hplay.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -303,9 +334,34 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object hplay Loading Object reg-ios Loading Object glob-con -Program size is 3992 longs -9 Constants folded -Compiled 2054 Lines of Code in 0,08 Seconds +Program size is 4404 longs +10 Constants folded +Compiled 2216 Lines of Code in 0,44 Seconds + +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\ipconfig.spin +Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved +Compiled for i386 Win32 at 08:17:48 on 2009/07/20 +Loading Object ipconfig +Loading Object reg-ios +Loading Object glob-con +Loading Object glob-string +Loading Object glob-numbers +Program size is 4992 longs +8 Constants folded +Compiled 2742 Lines of Code in 0,86 Seconds + +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\irc.spin +Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved +Compiled for i386 Win32 at 08:17:48 on 2009/07/20 +Loading Object irc +Loading Object reg-ios +Loading Object glob-con +Loading Object glob-string +Loading Object glob-numbers +Loading Object glob-led-engine +Program size is 13840 longs +14 Constants folded +Compiled 3777 Lines of Code in 1,02 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\keycode.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -313,9 +369,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object keycode Loading Object reg-ios Loading Object glob-con -Program size is 2180 longs -1 Constants folded -Compiled 1816 Lines of Code in 0,062 Seconds +Program size is 2592 longs +2 Constants folded +Compiled 1978 Lines of Code in 0,52 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\m.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -324,9 +380,9 @@ Loading Object m Loading Object reg-ios Loading Object glob-con Loading Object m-glob-con -Program size is 3360 longs -1 Constants folded -Compiled 2133 Lines of Code in 0,089 Seconds +Program size is 3772 longs +2 Constants folded +Compiled 2311 Lines of Code in 0,109 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\man.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -335,9 +391,20 @@ Loading Object man Loading Object reg-ios Loading Object glob-con Loading Object glob-string -Program size is 2716 longs -1 Constants folded -Compiled 1997 Lines of Code in 0,078 Seconds +Program size is 3152 longs +2 Constants folded +Compiled 2161 Lines of Code in 0,73 Seconds + +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\perplex.spin +Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved +Compiled for i386 Win32 at 08:17:48 on 2009/07/20 +Loading Object perplex +Loading Object reg-ios +Loading Object glob-con +Loading Object glob-numbers +Program size is 6160 longs +3 Constants folded +Compiled 2771 Lines of Code in 0,809 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\ramtest.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -345,9 +412,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object ramtest Loading Object reg-ios Loading Object glob-con -Program size is 4272 longs -35 Constants folded -Compiled 2069 Lines of Code in 0,08 Seconds +Program size is 4664 longs +36 Constants folded +Compiled 2230 Lines of Code in 0,52 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\regime.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -356,9 +423,9 @@ Loading Object regime Loading Object reg-ios Loading Object glob-con Loading Object glob-string -Program size is 9736 longs +Program size is 9868 longs 2 Constants folded -Compiled 2694 Lines of Code in 0,122 Seconds +Compiled 2868 Lines of Code in 0,579 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\rom.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -367,9 +434,9 @@ Loading Object rom Loading Object reg-ios Loading Object glob-con Loading Object glob-sdspi -Program size is 4364 longs -4 Constants folded -Compiled 2429 Lines of Code in 0,088 Seconds +Program size is 4776 longs +5 Constants folded +Compiled 2591 Lines of Code in 0,5 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\sfxtool.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -379,9 +446,9 @@ Loading Object reg-ios Loading Object glob-con Loading Object glob-numbers Loading Object glob-string -Program size is 6644 longs -1 Constants folded -Compiled 2756 Lines of Code in 0,119 Seconds +Program size is 7056 longs +2 Constants folded +Compiled 2918 Lines of Code in 0,809 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\splay.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -389,9 +456,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object splay Loading Object reg-ios Loading Object glob-con -Program size is 3064 longs -1 Constants folded -Compiled 1925 Lines of Code in 0,071 Seconds +Program size is 3476 longs +2 Constants folded +Compiled 2087 Lines of Code in 0,529 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\sysconf.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -399,9 +466,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object sysconf Loading Object reg-ios Loading Object glob-con -Program size is 4228 longs -2 Constants folded -Compiled 2046 Lines of Code in 0,078 Seconds +Program size is 4640 longs +3 Constants folded +Compiled 2208 Lines of Code in 0,17 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\tapecut.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -411,9 +478,9 @@ Loading Object reg-ios Loading Object glob-con Loading Object glob-numbers Loading Object m-glob-con -Program size is 3560 longs -1 Constants folded -Compiled 2516 Lines of Code in 0,096 Seconds +Program size is 3972 longs +2 Constants folded +Compiled 2694 Lines of Code in 0,8 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\time.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -423,9 +490,9 @@ Loading Object reg-ios Loading Object glob-con Loading Object glob-string Loading Object glob-numbers -Program size is 5804 longs -1 Constants folded -Compiled 2591 Lines of Code in 0,112 Seconds +Program size is 6216 longs +2 Constants folded +Compiled 2753 Lines of Code in 0,639 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\wplay.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -433,9 +500,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object wplay Loading Object reg-ios Loading Object glob-con -Program size is 3348 longs -1 Constants folded -Compiled 1947 Lines of Code in 0,074 Seconds +Program size is 3760 longs +2 Constants folded +Compiled 2109 Lines of Code in 0,52 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>bstc.exe -L ".\lib" -b -O a .\system\regnatix\yplay.spin Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved @@ -443,9 +510,9 @@ Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object yplay Loading Object reg-ios Loading Object glob-con -Program size is 3348 longs -1 Constants folded -Compiled 1995 Lines of Code in 0,082 Seconds +Program size is 3760 longs +2 Constants folded +Compiled 2157 Lines of Code in 0,52 Seconds H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>rename *.binary *.bin @@ -457,11 +524,15 @@ H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\eram.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\flash.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\fm.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\fterm.bin +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\ftp.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\g0test.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\hplay.bin +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\ipconfig.bin +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\irc.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\keycode.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\m.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\man.bin +H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\perplex.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\ramtest.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\regime.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\rom.bin @@ -472,7 +543,7 @@ H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\tapecut.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\time.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\wplay.bin H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios\yplay.bin - 22 Datei(en) verschoben. + 26 Datei(en) verschoben. H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>copy .\forth\*.* ".\bin\sdcard\system" .\forth\adm.lib @@ -509,6 +580,7 @@ H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>copy .\system\son .\system\sonstiges\error.man .\system\sonstiges\flash.man .\system\sonstiges\fm.man +.\system\sonstiges\ftp.man .\system\sonstiges\GREEN.COL .\system\sonstiges\hplay.man .\system\sonstiges\PAR.COL @@ -519,6 +591,6 @@ H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>copy .\system\son .\system\sonstiges\test2.txt .\system\sonstiges\wplay.man .\system\sonstiges\yplay.man - 18 Datei(en) kopiert. + 19 Datei(en) kopiert. H:\Projekte\Technik\hive 1\software\TriOS\TriOS-SVN\hive-trios>echo off diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..2ad622d --- /dev/null +++ b/readme.txt @@ -0,0 +1,4 @@ + +Informationen zum System und zur Installation im Verzeichnis "doku". + +Informationen zum Projekt: hive-project.de \ No newline at end of file diff --git a/system/administra/admnet/admnet.spin b/system/administra/admnet/admnet.spin new file mode 100644 index 0000000..9ee80b9 Binary files /dev/null and b/system/administra/admnet/admnet.spin differ diff --git a/system/regnatix/fm.spin b/system/regnatix/fm.spin index 6bdf91f..8ea759a 100644 Binary files a/system/regnatix/fm.spin and b/system/regnatix/fm.spin differ diff --git a/system/regnatix/ftp.spin b/system/regnatix/ftp.spin new file mode 100644 index 0000000..cefcfe5 --- /dev/null +++ b/system/regnatix/ftp.spin @@ -0,0 +1,540 @@ +{{ +┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Autor: Jörg Deckert │ +│ Copyright (c) 2013 Jörg Deckert │ +│ See end of file for terms of use. │ +│ Die Nutzungsbedingungen befinden sich am Ende der Datei │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────┘ + +Informationen : hive-project.de +Kontakt : joergd@bitquell.de +System : TriOS +Name : flash +Chip : Regnatix +Typ : Programm +Version : +Subversion : +Funktion : FTP-Client +Komponenten : - +COG's : - +Logbuch : + +22.12.2013-joergd - erste Version +05.01.2014-joergd - Defaultwerte gesetzt + - Speichern auf SD-Card + - Parameter für Benutzer und Paßwort + +Kommandoliste : + + +Notizen : + + +}} + +OBJ + ios: "reg-ios" + str: "glob-string" + num: "glob-numbers" 'Number Engine + +CON + +_CLKMODE = XTAL1 + PLL16X +_XINFREQ = 5_000_000 + + LANMASK = %00000000_00000000_00000000_00100000 + +CON 'NVRAM Konstanten -------------------------------------------------------------------------- + +#4, NVRAM_IPADDR +#8, NVRAM_IPMASK +#12, NVRAM_IPGW +#16, NVRAM_IPDNS +#20, NVRAM_IPBOOT +#24, NVRAM_HIVE ' 4 Bytes + +DAT + + strNVRAMFile byte "nvram.sav",0 'contains the 56 bytes of NVRAM, if RTC is not available + +VAR + + long ip_addr + byte parastr[64] + byte remdir[64] + byte filename[64] + byte username[64] + byte password[64] + byte strTemp[128] + byte addrset + byte save2card + byte handleidx_control 'Handle FTP Control Verbindung + byte handleidx_data 'Handle FTP Data Verbindung + +PUB main + + ip_addr := 0 + save2card := FALSE + remdir[0] := 0 + filename[0] := 0 + username[0] := 0 + password[0] := 0 + + ios.start + ifnot (ios.admgetspec & LANMASK) + ios.print(@strNoNetwork) + ios.stop + ios.printnl + ios.parastart 'parameterübergabe starten + repeat while ios.paranext(@parastr) 'parameter einlesen + if byte[@parastr][0] == "/" 'option? + case byte[@parastr][1] + "?": ios.print(@help) + "h": if ios.paranext(@parastr) + setaddr(@parastr) + "d": ios.paranext(@remdir) + "f": ios.paranext(@filename) + "u": ios.paranext(@username) + "p": ios.paranext(@password) + "s": save2card := TRUE + other: ios.print(@help) + + ifnot byte[@filename][0] == 0 + ifnot ftpconnect + ifnot ftplogin + ifnot ftpcwd + if ftppasv + ftpretr + else + ios.print(@strNoFile) + + + ftpclose + ios.stop + +PRI ftpconnect + + ifnot (ip_addr) ' Adresse 0.0.0.0 + ios.print(@strNoHost) + if ios.rtcTest 'RTC chip available? + ip_addr := ios.getNVSRAM(NVRAM_IPBOOT) << 24 + ip_addr += ios.getNVSRAM(NVRAM_IPBOOT+1) << 16 + ip_addr += ios.getNVSRAM(NVRAM_IPBOOT+2) << 8 + ip_addr += ios.getNVSRAM(NVRAM_IPBOOT+3) + else + ios.sddmset(ios#DM_USER) 'u-marker setzen + ios.sddmact(ios#DM_SYSTEM) 's-marker aktivieren + ifnot ios.sdopen("R",@strNVRAMFile) + ios.sdseek(NVRAM_IPBOOT) + ip_addr := ios.sdgetc << 24 + ip_addr += ios.sdgetc << 16 + ip_addr += ios.sdgetc << 8 + ip_addr += ios.sdgetc + ios.sdclose + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + if (ip_addr) + ios.print(@strUseBoot) + else + return(-1) +#ifdef __DEBUG + ios.print(@strStartLAN) +#endif + ios.lanstart + ios.print(@strConnect) + if (handleidx_control := ios.lan_connect(ip_addr, 21)) == $FF + ios.print(@strErrorNoSock) + return(-1) + ifnot (ios.lan_waitconntimeout(handleidx_control, 2000)) + ios.print(@strErrorConnect) + return(-1) +#ifdef __DEBUG + ios.print(@strConnected) +#endif + ifnot getResponse(string("220 ")) + ios.print(@strError220) + return(-1) + return(0) + +PRI ftpclose + + ifnot handleidx_control == $FF + ios.lan_close(handleidx_control) + handleidx_control := $FF + ifnot handleidx_data == $FF + ios.lan_close(handleidx_data) + handleidx_data := $FF + +PRI ftplogin | pwreq, respOK, hiveid + + pwreq := FALSE + respOK := FALSE + + sendStr(string("USER ")) + if strsize(@username) + sendStr(@username) + sendStr(string(13,10)) + else + sendStr(string("anonymous",13,10)) + + repeat until readLine == -1 +#ifdef __DEBUG + ios.print(string(" < ")) + ios.print(@strTemp) + ios.printnl +#endif + strTemp[4] := 0 + if strcomp(@strTemp, string("230 ")) + respOk := TRUE + quit + elseif strcomp(@strTemp, string("331 ")) + pwreq := TRUE + respOk := TRUE + quit + ifnot respOK + ios.print(@strErrorLogin) + return(-1) + + ifnot pwreq + return(0) + + sendStr(string("PASS ")) + if strsize(@password) + sendStr(@password) + sendStr(string(13,10)) + else + if ios.rtcTest 'RTC chip available? + hiveid := ios.getNVSRAM(NVRAM_HIVE) + hiveid += ios.getNVSRAM(NVRAM_HIVE+1) << 8 + hiveid += ios.getNVSRAM(NVRAM_HIVE+2) << 16 + hiveid += ios.getNVSRAM(NVRAM_HIVE+3) << 24 + else + ios.sddmset(ios#DM_USER) 'u-marker setzen + ios.sddmact(ios#DM_SYSTEM) 's-marker aktivieren + ifnot ios.sdopen("R",@strNVRAMFile) + ios.sdseek(NVRAM_HIVE) + hiveid := ios.sdgetc + hiveid += ios.sdgetc << 8 + hiveid += ios.sdgetc << 16 + hiveid += ios.sdgetc << 24 + ios.sdclose + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + sendStr(string("anonymous@hive")) + sendStr(str.trimCharacters(num.ToStr(hiveid, num#DEC))) + sendStr(string(13,10)) + + ifnot getResponse(string("230 ")) + ios.print(@strErrorPass) + return(-1) + + return(0) + +PRI ftpcwd | i + + if byte[@remdir][0] == 0 + i := sendStr(string("CWD ")) || sendStr(@defdir) || sendStr(string(13,10)) + else + i := sendStr(string("CWD ")) || sendStr(@remdir) || sendStr(string(13,10)) + if i + ios.print(@strErrorCWD) + return(-1) + ifnot getResponse(string("250 ")) + ios.print(@strError250) + ios.printchar("(") + ios.print(@strTemp+4) + ios.print(string(")",13)) + return(-1) + return(0) + +PRI ftppasv : port | i, k, port256, port1 + + port := 0 + port256 := 0 + port1 := 0 + k := 0 + + if sendStr(string("PASV",13,10)) + return(0) + + repeat until readLine == -1 +#ifdef __DEBUG + ios.print(string(" < ")) + ios.print(@strTemp) + ios.printnl +#endif + strTemp[4] := 0 + if strcomp(@strTemp, string("227 ")) + repeat i from 5 to 126 + if (strTemp[i] == 0) OR (strTemp[i] == 13) OR (strTemp[i] == 10) + quit + if strTemp[i] == 44 'Komma + strTemp[i] := 0 + k++ + if k == 4 '4. Komma, Port Teil 1 folgt + port256 := i + 1 + if k == 5 '5. Komma, Port Teil 2 folgt + port1 := i + 1 + if strTemp[i] == 41 'Klammer zu + strTemp[i] := 0 + if (port256 & port1) + port := (num.FromStr(@strTemp+port256, num#DEC) * 256) + num.FromStr(@strTemp+port1, num#DEC) + quit + + if (port == 0) + ios.print(@strErrorPasvPort) + return(0) +#ifdef __DEBUG + ios.print(@strOpenPasv) + ios.print(num.ToStr(port, num#DEC)) + ios.printnl +#endif + if (handleidx_data := ios.lan_connect(ip_addr, port)) == $FF + ios.print(@strErrorSockPasv) + return(0) + ifnot (ios.lan_waitconntimeout(handleidx_data, 2000)) + ios.print(@strErrorPasvConn) + return(0) + +PRI ftpretr | len, respOK + + if sendStr(string("TYPE I",13,10)) + ios.print(@strErrorSendType) + return(-1) + ifnot getResponse(string("200 ")) + ios.print(@strErrorChType) + return(-1) + + if sendStr(string("SIZE ")) || sendStr(@filename) || sendStr(string(13,10)) + ios.print(@strErrorSendSize) + return(-1) + ifnot getResponse(string("213")) + ios.print(@strErrorSize) + ios.printchar("(") + ios.print(@strTemp+4) + ios.print(string(")",13)) + return(-1) + ifnot(len := num.FromStr(@strTemp+4, num#DEC)) + ios.print(@strErrorGetSize) + return(-1) + + ios.print(@strGetFile) + if sendStr(string("RETR ")) || sendStr(@filename) || sendStr(string(13,10)) + ios.print(@strErrorSendFN) + return -1 + respOK := FALSE + repeat until readLine == -1 +#ifdef __DEBUG + ios.print(string(" < ")) + ios.print(@strTemp) + ios.printnl +#endif + strTemp[4] := 0 + if strcomp(@strTemp, string("150 ")) + respOk := TRUE + quit + elseif strcomp(@strTemp, string("125 ")) + respOk := TRUE + quit + ifnot respOK + ios.print(@strErrorRetr) + ios.printchar("(") + ios.print(@strTemp+4) + ios.print(string(")",13)) + return(-1) + + if ios.lan_rxdata(handleidx_data, @filename, len) + ios.print(@strErrorRXData) + return(-1) + + ifnot getResponse(string("226 ")) + ios.print(@strErrorRetrOK) + return(-1) + + if save2card + ios.print(@strWrite2SD) + writeToSDCard + +PRI writeToSDCard | fnr, len, i + + fnr := ios.rd_open(@filename) + ifnot fnr == -1 + len := ios.rd_len(fnr) + ios.sddel(@filename) 'falls alte Datei auf SD-Card vorhanden, diese löschen + ifnot ios.sdnewfile(@filename) + ifnot ios.sdopen("W",@filename) + i := 0 + ios.sdxputblk(fnr,len) 'Daten als Block schreiben + ios.sdclose + ios.rd_del(@filename) + ios.rd_close(fnr) + +PRI setaddr (ipaddr) | pos, count 'IP-Adresse in Variable schreiben + + count := 3 + repeat while ipaddr + pos := str.findCharacter(ipaddr, ".") + if(pos) + byte[pos++] := 0 + ip_addr += num.FromStr(ipaddr, num#DEC) << (8*count--) + ipaddr := pos + if(count == -1) + quit + +PRI getResponse (strOk) : respOk | len + + respOk := FALSE + + repeat until readLine == -1 +#ifdef __DEBUG + ios.print(string(" < ")) + ios.print(@strTemp) + ios.printnl +#endif + strTemp[strsize(strOk)] := 0 + if strcomp(@strTemp, strOk) + respOk := TRUE + quit + + return respOk + +PRI readLine | i, ch + + repeat i from 0 to 126 + ch := ios.lan_rxtime(handleidx_control, 2000) + if ch == 13 + ch := ios.lan_rxtime(handleidx_control, 2000) + if ch == -1 or ch == 10 + quit + strTemp[i] := ch + + strTemp[i] := 0 + + return ch 'letztes Zeichen oder -1, wenn keins mehr empfangen + +PRI sendStr (strSend) : error + +#ifdef __DEBUG + ios.print(string(" > ")) + ios.print(strSend) + ios.printnl +#endif + error := ios.lan_txdata(handleidx_control, strSend, strsize(strSend)) + +DAT ' Locale + +#ifdef __LANG_EN + 'locale: english + + defdir byte "/hive/sdcard/system",0 + + strNoNetwork byte 13,"Administra doesn't provide network functions!",13,"Please load admnet.",13,0 + strNoFile byte "No file to download specified, exit...",13,0 + strNoHost byte "No host (ftp server) specified (parameter /h)",13,0 + strUseBoot byte "Using boot server (set with ipconfig).",13,0 + strStartLAN byte "Starting LAN...",13,0 + strConnect byte "Connecting to ftp server...",13,0 + strErrorNoSock byte "No free socket.",13,0 + strErrorConnect byte "Couldn't connect to ftp server.",13,0 + strConnected byte "Connected to ftp server, waiting for answer...",13,0 + strError220 byte "Ftp server doesn't acknowledge the connection (220).",13,0 + strErrorLogin byte "Ftp server doesn't acknowledge the login (230/331)",13,0 + strErrorPass byte "Ftp server doesn't acknowledge the password (230)",13,0 + strErrorCWD byte "Error sendig remote directory",13,0 + strError250 byte "Ftp server doesn't acknowledge the directory change (250).",13,0 + strErrorPasvPort byte "Couldn't get the passive port.",13,0 + strOpenPasv byte "Open Connection to passive port ",0 + strErrorSockPasv byte "No free socket fpr passive connection.",13,0 + strErrorPasvConn byte "Couldn't connect to passive port.",13,0 + strErrorSendType byte "Error sending file type",13,0 + strErrorChType byte "Ftp serve couldn't change file type (200).",13,0 + strErrorSendSize byte "Error sending SIZE command",13,0 + strErrorSize byte "Ftp server couldn't send file size (213).",13,"File not found? SIZE not supported?",13,0 + strErrorGetSize byte "Couldn't get file size.",13,0 + strGetFile byte "Retrieve file, please wait...",13,0 + strErrorSendFN byte "Error sending file name.",13,0 + strErrorRetr byte "Ftp server couldn't send file (150/125).",13,0 + strErrorRXData byte "Error retrieving file.",13,0 + strErrorRetrOK byte "Ftp server doesn't acknowledge sending of file (226).",13,0 + strWrite2SD byte "Saving to sd card...",13,0 + + help byte "/? : Help",13 + byte "/h : host ip address (ftp server)",13 + byte " (default: boot server from ipconfig)",13 + byte "/d : change to remote directory",13 + byte " (default: /hive/sdcard/system)",13 + byte "/f : download ",13 + byte "/u : Username at ftp server",13 + byte " (default: anonymous)",13 + byte "/p : password at ftp server",13 + byte " (default: anonymous@hive)",13 + byte "/s : save file to sd card",13 + byte 0 + +#else + 'default locale: german + + defdir byte "/hive/sdcard/system",0 + + strNoNetwork byte 13,"Administra stellt keine Netzwerk-Funktionen zur Verfügung!",13,"Bitte admnet laden.",13,0 + strNoFile byte "Keine Datei zum Downloaden angegeben, beende...",13,0 + strNoHost byte "FTP-Server nicht angegeben (Parameter /h)",13,0 + strUseBoot byte "Verwende Boot-Server (mit ipconfig gesetzt).",13,0 + strStartLAN byte "Starte LAN...",13,0 + strConnect byte "Verbinde mit FTP-Server...",13,0 + strErrorNoSock byte "Kein Socket frei...",13,0 + strErrorConnect byte "Verbindung mit FTP-Server konnte nicht aufgebaut werden.",13,0 + strConnected byte "Verbindung mit FTP-Server hergestellt, warte auf Antwort...",13,0 + strError220 byte "FTP-Server bestätigt den Verbindungsaufbau nicht (220).",13,0 + strErrorLogin byte "FTP-Server hat Login nicht bestätigt (230/331)",13,0 + strErrorPass byte "FTP-Server hat das Paßwort nicht bestätigt (230)",13,0 + strErrorCWD byte "Fehler beim Senden des Verzeichnisses",13,0 + strError250 byte "FTP-Server hat den Verzeichniswechsel nicht bestätigt (250).",13,0 + strErrorPasvPort byte "Konnte zu öffnenden Passiv-Port nicht ermitteln.",13,0 + strOpenPasv byte "Öffne Verbindung zu Passiv-Port ",0 + strErrorSockPasv byte "Kein Socket für Passiv-Verbindung frei...",13,0 + strErrorPasvConn byte "Passiv-Verbindung mit FTP-Server konnte nicht aufgebaut werden.",13,0 + strErrorSendType byte "Fehler beim Senden des Types",13,0 + strErrorChType byte "FTP-Server konnte Übertragungs-Typ nicht ändern (200).",13,0 + strErrorSendSize byte "Fehler beim Senden des SIZE-Kommandos",13,0 + strErrorSize byte "FTP-Server kann die Datei-Größe nicht übermitteln (213).",13,"Datei nicht vorhanden? SIZE nicht unterstützt?",13,0 + strErrorGetSize byte "Konnte Filegröße nicht ermitteln.",13,0 + strGetFile byte "Empfange Datei, bitte warten...",13,0 + strErrorSendFN byte "Fehler beim Senden des Filenamens.",13,0 + strErrorRetr byte "FTP-Server kann die Datei nicht senden (150/125).",13,0 + strErrorRXData byte "Fehler beim Empfang der Datei.",13,0 + strErrorRetrOK byte "FTP-Server hat den Empfang durch den Client nicht bestätigt (226).",13,0 + strWrite2SD byte "Speichere auf SD-Card...",13,0 + + help byte "/? : Hilfe",13 + byte "/h : FTP-Server-Adresse (Host)",13 + byte " (default: mit ipconfig gesetzter Boot-Server)",13 + byte "/d : in entferntes Verzeichnis wechseln",13 + byte " (default: /hive/sdcard/system)",13 + byte "/f : Download ",13 + byte "/u : Benutzername am FTP-Server",13 + byte " (default: anonymous)",13 + byte "/p : Paßwort am FTP-Server",13 + byte " (default: anonymous@hive)",13 + byte "/s : Datei auf SD-Card speichern",13 + byte 0 +#endif + +DAT 'lizenz + +{{ + +┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ TERMS OF USE: MIT License │ +├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ +│files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ +│modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ +│is furnished to do so, subject to the following conditions: │ +│ │ +│The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ +│ │ +│THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ +│WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ +│COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ +│ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +}} diff --git a/system/regnatix/ipconfig.spin b/system/regnatix/ipconfig.spin new file mode 100644 index 0000000..73ddece --- /dev/null +++ b/system/regnatix/ipconfig.spin @@ -0,0 +1,295 @@ +{{ +┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ Autor: Jörg Deckert │ +│ Copyright (c) 2013 Jörg Deckert │ +│ See end of file for terms of use. │ +│ Die Nutzungsbedingungen befinden sich am Ende der Datei │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────┘ + +Informationen : hive-project.de +Kontakt : joergd@bitquell.de +System : TriOS +Name : flash +Chip : Regnatix +Typ : Programm +Version : +Subversion : +Funktion : IP-Konfiguration in NVRAM ablegen +Komponenten : - +COG's : - +Logbuch : + +11.06.2013-joergd - erste Version, basierend auf time.spin +05.01.2014-joergd - kleine Verbesserungen im Parameter-Handling + +Kommandoliste : + + +Notizen : + + +}} + +OBJ + ios: "reg-ios" + str: "glob-string" + num: "glob-numbers" + +CON + +_CLKMODE = XTAL1 + PLL16X +_XINFREQ = 5_000_000 + + LANMASK = %00000000_00000000_00000000_00100000 + +CON 'NVRAM Konstanten -------------------------------------------------------------------------- + +#4, NVRAM_IPADDR +#8, NVRAM_IPMASK +#12, NVRAM_IPGW +#16, NVRAM_IPDNS +#20, NVRAM_IPBOOT +#24, NVRAM_HIVE ' 4 Bytes + +DAT + + strNVRAMFile byte "nvram.sav",0 'contains the 56 bytes of NVRAM, if RTC is not available + +VAR + +byte parastr[64] +byte rtcAvailable + +PUB main | i + + ios.start 'ios initialisieren + ios.printnl + + ifnot (ios.admgetspec & LANMASK) + ios.print(@strNoNetwork) + ios.stop + if ios.rtcTest 'RTC chip available? + rtcAvailable := TRUE + else 'use configfile + rtcAvailable := FALSE + ios.print(@strNoRTC) + ios.sddmset(ios#DM_USER) 'u-marker setzen + ios.sddmact(ios#DM_SYSTEM) 's-marker aktivieren + if ios.sdopen("R",@strNVRAMFile) 'config file available + ios.sdnewfile(@strNVRAMFile) 'no, create it + if ios.sdopen("W",@strNVRAMFile) + ios.print(@strErrorOpen) + ios.stop + else + repeat i from 0 to 55 'set default value for pseudo NVRAM Bytes 0 - 55 + ios.sdputc(0) + ios.sdclose + else + ios.sdclose + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + + ios.parastart 'parameterübergabe starten + repeat while ios.paranext(@parastr) 'parameter einlesen + if byte[@parastr][0] == "/" 'option? + case byte[@parastr][1] + "?": ios.print(@help) + "l": cmd_listcfg + "a": if ios.paranext(@parastr) + cmd_setaddr(NVRAM_IPADDR, @parastr) + "m": if ios.paranext(@parastr) + cmd_setaddr(NVRAM_IPMASK, @parastr) + "g": if ios.paranext(@parastr) + cmd_setaddr(NVRAM_IPGW, @parastr) + "d": if ios.paranext(@parastr) + cmd_setaddr(NVRAM_IPDNS, @parastr) + "b": if ios.paranext(@parastr) + cmd_setaddr(NVRAM_IPBOOT, @parastr) + "i": if ios.paranext(@parastr) + cmd_sethive(num.FromStr(@parastr, num#DEC)) + other: ios.print(@help) + ios.stop + +PRI cmd_listcfg | hiveid 'nvram: IP-Konfiguration anzeigen + + ifnot rtcAvailable + ios.sddmset(ios#DM_USER) 'u-marker setzen + ios.sddmact(ios#DM_SYSTEM) 's-marker aktivieren + if ios.sdopen("R",@strNVRAMFile) + ios.print(@strErrorOpen) + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + return + + ios.print(@strAddr) + listaddr(NVRAM_IPADDR) + ios.print(string("/")) + listaddr(NVRAM_IPMASK) + ios.printnl + + ios.print(@strGw) + listaddr(NVRAM_IPGW) + ios.printnl + + ios.print(@strDNS) + listaddr(NVRAM_IPDNS) + ios.printnl + + ios.print(@strBoot) + listaddr(NVRAM_IPBOOT) + ios.printnl + + ios.print(@strHive) + if rtcAvailable + hiveid := ios.getNVSRAM(NVRAM_HIVE) + hiveid += ios.getNVSRAM(NVRAM_HIVE+1) << 8 + hiveid += ios.getNVSRAM(NVRAM_HIVE+2) << 16 + hiveid += ios.getNVSRAM(NVRAM_HIVE+3) << 24 + else + ios.sdseek(NVRAM_HIVE) + hiveid := ios.sdgetc + hiveid += ios.sdgetc << 8 + hiveid += ios.sdgetc << 16 + hiveid += ios.sdgetc << 24 + ios.print(str.trimCharacters(num.ToStr(hiveid, num#DEC))) + ios.printnl + + ifnot rtcAvailable + ios.sdclose + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + +PRI listaddr (nvidx) | count 'IP-Adresse anzeigen + + ifnot rtcAvailable + ios.sdseek(nvidx) + + repeat count from 0 to 3 + if(count) + ios.print(string(".")) + if rtcAvailable + ios.print(str.trimCharacters(num.ToStr(ios.getNVSRAM(nvidx+count), num#DEC))) + else + ios.print(str.trimCharacters(num.ToStr(ios.sdgetc, num#DEC))) + +PRI cmd_setaddr (nvidx, ipaddr) | pos, count 'IP-Adresse setzen + + ifnot rtcAvailable + ios.sddmset(ios#DM_USER) 'u-marker setzen + ios.sddmact(ios#DM_SYSTEM) 's-marker aktivieren + if ios.sdopen("W",@strNVRAMFile) + ios.print(@strErrorOpen) + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + return + else + ios.sdseek(nvidx) + + count := 0 + repeat while ipaddr + pos := str.findCharacter(ipaddr, ".") + if(pos) + byte[pos++] := 0 + if rtcAvailable + ios.setNVSRAM(nvidx+count++, num.FromStr(ipaddr, num#DEC)) + else + ios.sdputc(num.FromStr(ipaddr, num#DEC)) + ipaddr := pos + if(count == 4) + quit + + ifnot rtcAvailable + ios.sdclose + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + + ios.lanstop + ios.lanstart + +PRI cmd_sethive (hiveid) 'Hive-Id setzen + + if rtcAvailable + ios.setNVSRAM(NVRAM_HIVE, hiveid & $FF) + ios.setNVSRAM(NVRAM_HIVE+1, (hiveid >> 8) & $FF) + ios.setNVSRAM(NVRAM_HIVE+2, (hiveid >> 16) & $FF) + ios.setNVSRAM(NVRAM_HIVE+3, (hiveid >> 24) & $FF) + else + ios.sddmset(ios#DM_USER) 'u-marker setzen + ios.sddmact(ios#DM_SYSTEM) 's-marker aktivieren + if ios.sdopen("W",@strNVRAMFile) + ios.print(@strErrorOpen) + else + ios.sdseek(NVRAM_HIVE) + ios.sdputc(hiveid & $FF) + ios.sdputc((hiveid >> 8) & $FF) + ios.sdputc((hiveid >> 16) & $FF) + ios.sdputc((hiveid >> 24) & $FF) + ios.sdclose + ios.sddmact(ios#DM_USER) 'u-marker aktivieren + + ios.lanstop + ios.lanstart + +DAT 'sys: helptext + +#ifdef __LANG_EN + 'locale: english + + strNoNetwork byte "Administra doesn't provide network functions!",13,"Please load admnet.",13,0 + strNoRTC byte "RTC/NVRAM not found",13,"using configuration in /system/nvram.sav",13,0 + strAddr byte " Ip address: ",0 + strGw byte " Gateway: ",0 + strDNS byte " DNS server: ",0 + strBoot byte " Boot server: ",0 + strHive byte " Hive ID: ",0 + strErrorOpen byte "Can't open configuration file",13,0 + + help byte "/? : Help",13 + byte "/l : List configuration",13 + byte "/a : Set ip address",13 + byte "/m : Set network mask",13 + byte "/g : Set default gateway",13 + byte "/d : Set DNS server",13 + byte "/b : Set boot server",13 + byte "/i : Set Hive ID",13 + byte 0 + +#else + 'default locale: german + + strNoNetwork byte "Administra stellt keine Netzwerk-Funktionen zur Verfügung!",13,"Bitte admnet laden.",13,0 + strNoRTC byte "RTC/NVRAM nicht vorhanden",13,"nutze Konfiguration in /system/nvram.sav",13,0 + strAddr byte " IP-Adresse: ",0 + strGw byte " Gateway: ",0 + strDNS byte " DNS-Server: ",0 + strBoot byte " Boot-Server: ",0 + strHive byte " Hive-Id: ",0 + strErrorOpen byte "Kann Konfigurationsdatei nicht öffnen.",13,0 + + help byte "/? : Hilfe",13 + byte "/l : Konfiguration anzeigen",13 + byte "/a : IP-Adresse setzen",13 + byte "/m : Netzwerk-Maske setzen",13 + byte "/g : Gateway setzen",13 + byte "/d : DNS-Server setzen",13 + byte "/b : Boot-Server setzen",13 + byte "/i : Hive-Id setzen",13 + byte 0 + +#endif + +DAT 'lizenz + +{{ + +┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ TERMS OF USE: MIT License │ +├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ +│files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ +│modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ +│is furnished to do so, subject to the following conditions: │ +│ │ +│The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ +│ │ +│THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ +│WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ +│COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ +│ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ +└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +}} diff --git a/system/regnatix/irc.spin b/system/regnatix/irc.spin new file mode 100644 index 0000000..9e17320 Binary files /dev/null and b/system/regnatix/irc.spin differ diff --git a/system/regnatix/man.spin b/system/regnatix/man.spin index 753cd7e..87670b7 100644 Binary files a/system/regnatix/man.spin and b/system/regnatix/man.spin differ diff --git a/system/regnatix/perplex.spin b/system/regnatix/perplex.spin new file mode 100644 index 0000000..9abf40e Binary files /dev/null and b/system/regnatix/perplex.spin differ diff --git a/system/regnatix/perplex.txt b/system/regnatix/perplex.txt new file mode 100644 index 0000000..b0caff8 --- /dev/null +++ b/system/regnatix/perplex.txt @@ -0,0 +1,17 @@ + +openwr - slave schreibend ffnen +openrd - slave lesend ffnen +close - slave schlieen +put - zeichen zu plexus senden +get - zeichen von plexus empfangen +map - slavemap anzeigen +scan - anzeige aller slaveadressen +test - test fr interne sepia-karte +test# adda port - test fr spezifische sepia-karte +game - gamedevice abfragen (pollregister) +setgame adda port - adressen fr poller setzen adda/port +polloff - polling anhalten +pollon - polling starten +bye - programm beenden + +Parameter hexadezimal! diff --git a/system/regnatix/ramtest.spin b/system/regnatix/ramtest.spin index b55b2f2..6a67332 100644 Binary files a/system/regnatix/ramtest.spin and b/system/regnatix/ramtest.spin differ diff --git a/system/regnatix/regime.spin b/system/regnatix/regime.spin index f3fb0ea..6bb105b 100644 Binary files a/system/regnatix/regime.spin and b/system/regnatix/regime.spin differ diff --git a/system/sonstiges/ftp.man b/system/sonstiges/ftp.man new file mode 100644 index 0000000..416f04c --- /dev/null +++ b/system/sonstiges/ftp.man @@ -0,0 +1,39 @@ + +/h : FTP-Server-Adresse (Host) + (default: mit ipconfig gesetzter Boot-Server) +/d : in entferntes Verzeichnis wechseln + (default: /hive/sdcard/system) +/f : Download +/u : Benutzername am FTP-Server + (default: anonymous) +/p : Paßwort am FTP-Server + (default: anonymous@hive) +/s : Datei auf SD-Card speichern + + +Ein Beispiel: +Zum Download von + + ftp://1.2.3.4/verzeichnis/unterverzeichnis/datei.txt + +verwendet man folgende Befehlszeile: + + ftp /h 1.2.3.4 /d /verzeichnis/unterverzeichnis /f datei.txt + +Dabei erfolgt die Anmeldung wegen der fehlenden Parameter +/u und /p als "anonymous" mit dem Pawort "anonymous@hivexxx" +(xxx: mit ipconfig gesetzte Hive-Id). Die Datei wird in +der RAM-Disk gespeichert (s. Kommando "xdir") und knnte +mittels "xsave" auf SD-Card gespeichert werden. + +Mit Nutzung aller Default-Werte gengt die Eingabe des +folgenden Befehls: + + ftp /s /f ipconfig.bin + +Damit wird die Datei "ipconfig.bin" vom FTP-Server mit der +IP-Adresse des mittels "ipconfig" konfigurierten Boot- +Servers aus dem Verzeichnis "/hive/sdcard/system" geladen +und im aktuellen Verzeichnis auf der SD-Card +abgespeichert. Von dort knnte sie direkt gestartet werden. + diff --git a/system/sonstiges/sysconf.man b/system/sonstiges/sysconf.man index 484e2f7..57a412f 100644 --- a/system/sonstiges/sysconf.man +++ b/system/sonstiges/sysconf.man @@ -1,18 +1,18 @@ -/? : Hilfe -/l : Konfiguration anzeigen ------------ Administra-Funktionen -/ah 0|1 : hss ab-/anschalten -/aw 0|1 : wav ab-/anschalten -/as 0|1 : systemklnge ab-/anschalten -/al 0..100 : wav-lautstrke links -/ar 0..100 : wav-lautstrke rechts -/ah 0..15 : hss-lautstrke -/af : administra reset, flash booten -/at : transfergeschwindigkeit messen ------------ Bellatrix-Funktionen -/ci : farbtabelle anzeigen -/cs datei : farbtabelle speichern -/cl datei : farbtabelle laden ------------ Port-Funktionen -/po nr anz : Impulse an port ausgeben -/pi : Status der Port abfragen \ No newline at end of file +/? : Hilfe +/l : Konfiguration anzeigen +---------------- Administra-Funktionen +/ah 0|1 : hss ab-/anschalten +/aw 0|1 : wav ab-/anschalten +/as 0|1 : systemklnge ab-/anschalten +/al 0..100 : wav-lautstrke links +/ar 0..100 : wav-lautstrke rechts +/ah 0..15 : hss-lautstrke +/af : administra reset, flash booten +/at : transfergeschwindigkeit messen +---------------- Bellatrix-Funktionen +/ci : farbtabelle anzeigen +/cs datei : farbtabelle speichern +/cl datei : farbtabelle laden +---------------- Port-Funktionen +/po nr anz time : Impulse an port ausgeben +/pi : Status der Port abfragen \ No newline at end of file