ftp client (first version, incomplete)
This commit is contained in:
parent
4ae38fb283
commit
ab882355a6
|
@ -163,7 +163,7 @@ A_AYS = %00000000_00000000_00000010_00000000
|
|||
a_rtcPauseForSec 'Pauses execution for a number of seconds. Returns a puesdo random value derived from the current clock frequency and the time when called. Number - Number of seconds to pause for between 0 and 2,147,483,647.
|
||||
a_rtcPauseForMSec '58 'Pauses execution for a number of milliseconds. Returns a puesdo random value derived from the current clock frequency and the time when called. Number - Number of milliseconds to pause for between 0 and 2,147,483,647.
|
||||
|
||||
' ---------------------------------------------- NET-FUNKTIONEN
|
||||
' ---------------------------------------------- LAN-FUNKTIONEN
|
||||
#71, a_lanStart 'Start Network
|
||||
a_lanStop 'Stop Network
|
||||
a_lanConnect 'ausgehende TCP-Verbindung öffnen
|
||||
|
@ -183,7 +183,7 @@ A_AYS = %00000000_00000000_00000010_00000000
|
|||
a_lanTXFlush 'Sendepuffer leeren
|
||||
a_lanTXCheck 'Verbindung prüfen und Byte senden
|
||||
a_lanTX 'Byte senden
|
||||
a_lanTXData 'Daten senden
|
||||
a_lanTXData '90 'Daten senden
|
||||
|
||||
' ---------------------------------------------- CHIP-MANAGMENT
|
||||
#92, a_mgrSetSound 'soundsubsysteme verwalten
|
||||
|
|
|
@ -1030,18 +1030,68 @@ CON ''------------------------------------------------- LAN_FUNKTIONEN
|
|||
|
||||
PUB lanstart 'LAN starten
|
||||
''funktionsgruppe : lan
|
||||
''funktion : TCP-Netzwerk starten
|
||||
''busprotokoll : -
|
||||
''funktion : Netzwerk starten
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [071]
|
||||
|
||||
bus_putchar1(gc#a_lanStart)
|
||||
|
||||
PUB lanstop 'LAN beenden
|
||||
''funktionsgruppe : lan
|
||||
''funktion : TCP-Netzwerk beenden
|
||||
''busprotokoll : -
|
||||
''funktion : Netzwerk anhalten
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [072]
|
||||
|
||||
bus_putchar1(gc#a_lanStop)
|
||||
|
||||
PUB lan_connect(ipaddr, remoteport): handle
|
||||
''funktionsgruppe : lan
|
||||
''funktion : ausgehende TCP-Verbindung öffnen (mit Server verbinden)
|
||||
'' : Da hier feste Puffer (bufrxconn,buftxconn) verwendet werden,
|
||||
'' : darf diese Funktion nur einmal aufgerufen werden
|
||||
'' : (driver_socket.spin handelt per default bis 4 Sockets)
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [073][sub_putlong.ipaddr][sub_putword.remoteport][get.handle]
|
||||
'' : ipaddr - ipv4 address packed into a long (ie: 1.2.3.4 => $01_02_03_04)
|
||||
'' : remoteport - port number to connect to
|
||||
'' : handle - lfd. Nr. der Verbindung
|
||||
|
||||
bus_putchar1(gc#a_lanConnect)
|
||||
bus_putlong1(ipaddr)
|
||||
bus_putword1(remoteport)
|
||||
handle := bus_getchar1
|
||||
|
||||
PUB lan_listen
|
||||
PUB lan_relisten
|
||||
PUB lan_isconnected
|
||||
PUB lan_rxcount
|
||||
PUB lan_resetbuffers
|
||||
PUB lan_waitconntimeout
|
||||
PUB lan_close(handle)
|
||||
''funktionsgruppe : lan
|
||||
''funktion : TCP-Verbindung (ein- oder ausgehend) schließen
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [080][put.handle]
|
||||
'' : handle - lfd. Nr. der zu schließenden Verbindung
|
||||
|
||||
bus_putchar1(gc#a_lanClose)
|
||||
bus_putchar1(handle)
|
||||
|
||||
PUB lan_rxflush
|
||||
PUB lan_rxcheck
|
||||
PUB lan_rxtime
|
||||
PUB lan_rxbyte
|
||||
PUB lan_rxdatatime
|
||||
PUB lan_rxdata
|
||||
PUB lan_txflush
|
||||
PUB lan_txcheck
|
||||
PUB lan_tx
|
||||
PUB lan_txdata
|
||||
|
||||
CON ''------------------------------------------------- Hydra Sound System
|
||||
|
||||
PUB hss_playfile(stradr) | status 'hss: spielt übergebene hss-datei von sd-card
|
||||
|
|
|
@ -164,6 +164,10 @@ CNT_HBEAT = 5_000_0000 'blinkgeschw. front-led
|
|||
|
||||
MPLEN = 12000 'größe des hss-musikpuffers
|
||||
|
||||
'Netzwerk-Puffergrößen (müssen Vielfaches von 2 sein!)
|
||||
rxlen = 2048
|
||||
txlen = 128
|
||||
|
||||
'index für dmarker
|
||||
#0, RMARKER 'root
|
||||
SMARKER 'system
|
||||
|
@ -172,12 +176,30 @@ MPLEN = 12000 'größe des hss-musikpu
|
|||
BMARKER
|
||||
CMARKER
|
||||
|
||||
CON 'Signaldefinitionen --------------------------------------------------------------------------
|
||||
|
||||
'signaldefinitionen administra (todo: nach glob-con.spin auslagern!!!)
|
||||
|
||||
#14, A_NETCS,A_NETSCK,A_NETSI,A_NETSO 'Pins zum ENC28J60
|
||||
|
||||
CON 'NVRAM Konstanten --------------------------------------------------------------------------
|
||||
|
||||
' todo: nach glob-con.spin auslagern!!!
|
||||
|
||||
#4, NVRAM_IPADDR
|
||||
#8, NVRAM_IPMASK
|
||||
#12, NVRAM_IPGW
|
||||
#16, NVRAM_IPDNS
|
||||
#20, NVRAM_IPBOOT
|
||||
#24, NVRAM_HIVE ' 4 Bytes
|
||||
|
||||
OBJ
|
||||
sdfat : "adm-fat" 'fatengine
|
||||
rtc : "adm-rtc" 'RTC-Engine
|
||||
com : "adm-com" 'serielle schnittstelle
|
||||
lan : "driver_socket" 'LAN
|
||||
sock : "driver_socket" 'LAN
|
||||
gc : "glob-con" 'globale konstanten
|
||||
num : "glob-numbers" 'Number Engine
|
||||
|
||||
VAR
|
||||
|
||||
|
@ -185,6 +207,10 @@ VAR
|
|||
byte tbuf[20] 'stringpuffer
|
||||
byte tbuf2[20]
|
||||
long com_baud
|
||||
byte bufrxconn[rxlen] 'LAN Empfangspuffer ausgehende Verbindung
|
||||
byte buftxconn[txlen] 'LAN Sendepuffer ausgehende Verbindung
|
||||
byte bufrxlist[rxlen] 'LAN Empfangspuffer eingehende Verbindung
|
||||
byte buftxlist[txlen] 'LAN Sendepuffer eingehende Verbindung
|
||||
|
||||
CON ''------------------------------------------------- ADMINISTRA
|
||||
|
||||
|
@ -1090,22 +1116,102 @@ PRI rtc_pauseForMilliseconds 'rtc: Pauses execution f
|
|||
|
||||
CON ''------------------------------------------------- LAN-FUNKTIONEN
|
||||
|
||||
PRI lan_start
|
||||
PRI lan_start | hiveid, hivestr, strpos, macpos
|
||||
''funktionsgruppe : lan
|
||||
''funktion : Netzwerk starten
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [071]
|
||||
|
||||
ip_addr := rtc.getNVSRAM(NVRAM_IPADDR)
|
||||
ip_addr[1] := rtc.getNVSRAM(NVRAM_IPADDR+1)
|
||||
ip_addr[2] := rtc.getNVSRAM(NVRAM_IPADDR+2)
|
||||
ip_addr[3] := rtc.getNVSRAM(NVRAM_IPADDR+3)
|
||||
|
||||
ip_subnet := rtc.getNVSRAM(NVRAM_IPMASK)
|
||||
ip_subnet[1] := rtc.getNVSRAM(NVRAM_IPMASK+1)
|
||||
ip_subnet[2] := rtc.getNVSRAM(NVRAM_IPMASK+2)
|
||||
ip_subnet[3] := rtc.getNVSRAM(NVRAM_IPMASK+3)
|
||||
|
||||
ip_gateway := rtc.getNVSRAM(NVRAM_IPGW)
|
||||
ip_gateway[1] := rtc.getNVSRAM(NVRAM_IPGW+1)
|
||||
ip_gateway[2] := rtc.getNVSRAM(NVRAM_IPGW+2)
|
||||
ip_gateway[3] := rtc.getNVSRAM(NVRAM_IPGW+3)
|
||||
|
||||
ip_dns := rtc.getNVSRAM(NVRAM_IPDNS)
|
||||
ip_dns[1] := rtc.getNVSRAM(NVRAM_IPDNS+1)
|
||||
ip_dns[2] := rtc.getNVSRAM(NVRAM_IPDNS+2)
|
||||
ip_dns[3] := rtc.getNVSRAM(NVRAM_IPDNS+3)
|
||||
|
||||
hiveid := rtc.getNVSRAM(NVRAM_HIVE)
|
||||
hiveid := hiveid + rtc.getNVSRAM(NVRAM_HIVE+1) << 8
|
||||
hiveid := hiveid + rtc.getNVSRAM(NVRAM_HIVE+2) << 16
|
||||
hiveid := hiveid + rtc.getNVSRAM(NVRAM_HIVE+3) << 24
|
||||
hivestr := num.ToStr(hiveid, num#DEC)
|
||||
strpos := strsize(hivestr)
|
||||
macpos := 5
|
||||
repeat while (strpos AND macpos)
|
||||
strpos--
|
||||
if(strpos)
|
||||
strpos--
|
||||
mac_addr[macpos] := num.FromStr(hivestr+strpos, num#HEX)
|
||||
byte[hivestr+strpos] := 0
|
||||
macpos--
|
||||
|
||||
sock.start(A_NETCS,A_NETSCK,A_NETSI,A_NETSO, -1, @mac_addr, @ip_addr)
|
||||
|
||||
|
||||
PRI lan_stop
|
||||
''funktionsgruppe : lan
|
||||
''funktion : Netzwerk anhalten
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [072]
|
||||
|
||||
sock.stop
|
||||
|
||||
PRI lan_connect | ipaddr, remoteport, handle
|
||||
''funktionsgruppe : lan
|
||||
''funktion : ausgehende TCP-Verbindung öffnen (mit Server verbinden)
|
||||
'' : Da hier feste Puffer (bufrxconn,buftxconn) verwendet werden,
|
||||
'' : darf diese Funktion nur einmal aufgerufen werden
|
||||
'' : (driver_socket.spin handelt per default bis 4 Sockets)
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [073][sub_getlong.ipaddr][sub_getword.remoteport][put.handle]
|
||||
'' : ipaddr - ipv4 address packed into a long (ie: 1.2.3.4 => $01_02_03_04)
|
||||
'' : remoteport - port number to connect to
|
||||
'' : handle - lfd. Nr. der Verbindung
|
||||
|
||||
{if sock.isValidHandle(handle)
|
||||
close}
|
||||
|
||||
ipaddr := sub_getlong
|
||||
remoteport := sub_getword
|
||||
|
||||
handle := sock.connect(ipaddr, remoteport, @bufrxconn, rxlen, @buftxconn, txlen)
|
||||
|
||||
bus_putchar(handle) 'handle senden
|
||||
|
||||
|
||||
|
||||
PRI lan_connect
|
||||
PRI lan_listen
|
||||
PRI lan_relisten
|
||||
PRI lan_isconnected
|
||||
PRI lan_rxcount
|
||||
PRI lan_resetbuffers
|
||||
PRI lan_waitconntimeout
|
||||
PRI lan_close
|
||||
PRI lan_close | handle
|
||||
''funktionsgruppe : lan
|
||||
''funktion : TCP-Verbindung (ein- oder ausgehend) schließen
|
||||
''eingabe : -
|
||||
''ausgabe : -
|
||||
''busprotokoll : [080][get.handle]
|
||||
'' : handle - lfd. Nr. der zu schließenden Verbindung
|
||||
|
||||
handle := bus_getchar
|
||||
|
||||
sock.close(handle)
|
||||
|
||||
PRI lan_rxflush
|
||||
PRI lan_rxcheck
|
||||
PRI lan_rxtime
|
||||
|
@ -1117,6 +1223,15 @@ PRI lan_txcheck
|
|||
PRI lan_tx
|
||||
PRI lan_txdata
|
||||
|
||||
DAT
|
||||
long ' long alignment for addresses
|
||||
ip_addr byte 10, 1, 1, 1 'ip
|
||||
ip_subnet byte 255, 255, 255, 0 'subnet-maske
|
||||
ip_gateway byte 10, 1, 1, 254 'gateway
|
||||
ip_dns byte 10, 1, 1, 254 'dns
|
||||
ip_boot long 0 'boot-server (IP address in long)
|
||||
mac_addr byte $c0, $de, $ba, $be, $00, $00 'mac-adresse
|
||||
|
||||
DAT 'dummyroutine für getcogs
|
||||
org
|
||||
'
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
{{
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ 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.12.2013-joergd - erste Version
|
||||
|
||||
|
||||
Kommandoliste :
|
||||
|
||||
|
||||
Notizen :
|
||||
|
||||
|
||||
}}
|
||||
|
||||
OBJ
|
||||
ios: "reg-ios"
|
||||
str: "glob-string"
|
||||
num: "glob-numbers" 'Number Engine
|
||||
|
||||
CON
|
||||
|
||||
_CLKMODE = XTAL1 + PLL16X
|
||||
_XINFREQ = 5_000_000
|
||||
|
||||
VAR
|
||||
|
||||
long ip_addr
|
||||
byte parastr[64]
|
||||
byte addrset
|
||||
byte handle_control 'Handle FTP Control Verbindung
|
||||
byte handle_data 'Handle FTP Data Verbindung
|
||||
|
||||
PUB main
|
||||
|
||||
ip_addr := 0
|
||||
|
||||
ios.start 'ios initialisieren
|
||||
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)
|
||||
"a": if ios.paranext(@parastr)
|
||||
setaddr(@parastr)
|
||||
other: ios.print(@help)
|
||||
|
||||
if (ip_addr) ' Adresse nicht 0
|
||||
ios.lanstart
|
||||
handle_control := ios.lan_connect(ip_addr, 21)
|
||||
ios.printnl
|
||||
ios.print(string("Handle Connect: "))
|
||||
ios.print(num.ToStr(handle_control, num#DEC))
|
||||
ios.printnl
|
||||
ios.lan_close(handle_control)
|
||||
|
||||
ios.stop
|
||||
|
||||
PRI setaddr (ipaddr) | pos, count 'IP-Adresse in Variable schreiben
|
||||
|
||||
count := 0
|
||||
repeat while ipaddr
|
||||
pos := str.findCharacter(ipaddr, ".")
|
||||
if(pos)
|
||||
byte[pos++] := 0
|
||||
ip_addr[count++] := num.FromStr(ipaddr, num#DEC)
|
||||
ipaddr := pos
|
||||
if(count == 4)
|
||||
quit
|
||||
|
||||
DAT 'sys: helptext
|
||||
|
||||
|
||||
help byte "/? : Hilfe",13
|
||||
byte "/s <a.b.c.d> : Server-Adresse",13
|
||||
byte 0
|
||||
|
||||
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. │
|
||||
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
}}
|
Loading…
Reference in New Issue