FTP-Client, IPConfig: better parameter handling
This commit is contained in:
parent
8e4f23cf7c
commit
addc0f927f
|
@ -173,7 +173,8 @@ A_AYS = %00000000_00000000_00000010_00000000
|
||||||
a_lanRXTime 'bestimmte Zeit warten auf Byte aus Empfangspuffer
|
a_lanRXTime 'bestimmte Zeit warten auf Byte aus Empfangspuffer
|
||||||
a_lanRXData 'Daten aus Empfangspuffer lesen
|
a_lanRXData 'Daten aus Empfangspuffer lesen
|
||||||
a_lanTXData 'Daten senden
|
a_lanTXData 'Daten senden
|
||||||
a_lanRXByte '80 'wenn vorhanden, Byte aus Empfangspuffer lesen
|
a_lanRXByte 'wenn vorhanden, Byte aus Empfangspuffer lesen
|
||||||
|
a_lanIsConnected '81 'TRUE, wenn Socket verbunden, sonst FALSE
|
||||||
|
|
||||||
' ---------------------------------------------- CHIP-MANAGMENT
|
' ---------------------------------------------- CHIP-MANAGMENT
|
||||||
#92, a_mgrSetSound 'soundsubsysteme verwalten
|
#92, a_mgrSetSound 'soundsubsysteme verwalten
|
||||||
|
|
|
@ -1036,6 +1036,8 @@ PUB lanstart 'LAN starten
|
||||||
''busprotokoll : [071]
|
''busprotokoll : [071]
|
||||||
|
|
||||||
bus_putchar1(gc#a_lanStart)
|
bus_putchar1(gc#a_lanStart)
|
||||||
|
waitcnt(cnt + clkfreq) '1sek warten (nach ios.lanstart dauert es, bis der Stack funktioniert)
|
||||||
|
|
||||||
|
|
||||||
PUB lanstop 'LAN beenden
|
PUB lanstop 'LAN beenden
|
||||||
''funktionsgruppe : lan
|
''funktionsgruppe : lan
|
||||||
|
@ -1045,6 +1047,7 @@ PUB lanstop 'LAN beenden
|
||||||
''busprotokoll : [072]
|
''busprotokoll : [072]
|
||||||
|
|
||||||
bus_putchar1(gc#a_lanStop)
|
bus_putchar1(gc#a_lanStop)
|
||||||
|
waitcnt(cnt + clkfreq) '1sek warten, bis in Administra wirklich beendet
|
||||||
|
|
||||||
PUB lan_connect(ipaddr, remoteport): handleidx
|
PUB lan_connect(ipaddr, remoteport): handleidx
|
||||||
''funktionsgruppe : lan
|
''funktionsgruppe : lan
|
||||||
|
@ -1132,6 +1135,7 @@ PUB lan_rxdata(handleidx, filename, len): error | fnr
|
||||||
'' : len - Anzahl zu empfangende Bytes
|
'' : len - Anzahl zu empfangende Bytes
|
||||||
'' : error - ungleich Null bei Fehler
|
'' : error - ungleich Null bei Fehler
|
||||||
|
|
||||||
|
rd_del(filename) 'File aus RAM-Disk löschen (falls vorhanden)
|
||||||
rd_newfile(filename,len)
|
rd_newfile(filename,len)
|
||||||
fnr := rd_open(filename)
|
fnr := rd_open(filename)
|
||||||
ifnot fnr == -1
|
ifnot fnr == -1
|
||||||
|
@ -1182,6 +1186,20 @@ PUB lan_rxbyte(handleidx): rxbyte
|
||||||
rxbyte := bus_getchar1
|
rxbyte := bus_getchar1
|
||||||
rxbyte := ~rxbyte
|
rxbyte := ~rxbyte
|
||||||
|
|
||||||
|
PUB lan_isconnected(handleidx): connected
|
||||||
|
''funktionsgruppe : lan
|
||||||
|
''funktion : TRUE, wenn Socket verbunden, sonst FALSE
|
||||||
|
''eingabe : -
|
||||||
|
''ausgabe : -
|
||||||
|
''busprotokoll : [081][sub_putlong.handleidx]][get.connected]
|
||||||
|
'' : handleidx - lfd. Nr. der Verbindung
|
||||||
|
'' : connected - TRUE, wenn Socket verbunden, sonst FALSE
|
||||||
|
|
||||||
|
bus_putchar1(gc#a_lanIsConnected)
|
||||||
|
bus_putchar1(handleidx)
|
||||||
|
connected := bus_getchar1
|
||||||
|
connected := ~connected
|
||||||
|
|
||||||
CON ''------------------------------------------------- Hydra Sound System
|
CON ''------------------------------------------------- Hydra Sound System
|
||||||
|
|
||||||
PUB hss_playfile(stradr) | status 'hss: spielt übergebene hss-datei von sd-card
|
PUB hss_playfile(stradr) | status 'hss: spielt übergebene hss-datei von sd-card
|
||||||
|
|
|
@ -300,6 +300,7 @@ PUB main | cmd,err 'chip: kommandointerpret
|
||||||
gc#a_lanRXData: lan_rxdata 'Daten aus Empfangspuffer lesen
|
gc#a_lanRXData: lan_rxdata 'Daten aus Empfangspuffer lesen
|
||||||
gc#a_lanTXData: lan_txdata 'Daten senden
|
gc#a_lanTXData: lan_txdata 'Daten senden
|
||||||
gc#a_lanRXByte: lan_rxbyte 'wenn vorhanden, Byte aus Empfangspuffer lesen
|
gc#a_lanRXByte: lan_rxbyte 'wenn vorhanden, Byte aus Empfangspuffer lesen
|
||||||
|
gc#a_lanIsConnected: lan_isconnected 'TRUE, wenn Socket verbunden, sonst FALSE
|
||||||
|
|
||||||
' ---------------------------------------------- CHIP-MANAGMENT
|
' ---------------------------------------------- CHIP-MANAGMENT
|
||||||
gc#a_mgrGetSpec: mgr_getspec 'spezifikation abfragen
|
gc#a_mgrGetSpec: mgr_getspec 'spezifikation abfragen
|
||||||
|
@ -1348,6 +1349,17 @@ PRI lan_rxbyte
|
||||||
|
|
||||||
bus_putchar(sock.readByteNonBlocking(sockhandle[bus_getchar]))
|
bus_putchar(sock.readByteNonBlocking(sockhandle[bus_getchar]))
|
||||||
|
|
||||||
|
PRI lan_isconnected
|
||||||
|
''funktionsgruppe : lan
|
||||||
|
''funktion : Returns true if the socket is connected, false otherwise
|
||||||
|
''eingabe : -
|
||||||
|
''ausgabe : -
|
||||||
|
''busprotokoll : [081][get.handleidx][put.connected]
|
||||||
|
'' : handleidx - lfd. Nr. der Verbindung
|
||||||
|
'' : connected - TRUE wenn verbunden, sonst FALSE
|
||||||
|
|
||||||
|
bus_putchar(sock.isConnected(sockhandle[bus_getchar]))
|
||||||
|
|
||||||
DAT
|
DAT
|
||||||
long ' long alignment for addresses
|
long ' long alignment for addresses
|
||||||
ip_addr byte 10, 1, 1, 1 'ip
|
ip_addr byte 10, 1, 1, 1 'ip
|
||||||
|
|
|
@ -20,7 +20,9 @@ COG's : -
|
||||||
Logbuch :
|
Logbuch :
|
||||||
|
|
||||||
22.12.2013-joergd - erste Version
|
22.12.2013-joergd - erste Version
|
||||||
|
05.01.2014-joergd - Defaultwerte gesetzt
|
||||||
|
- Speichern auf SD-Card
|
||||||
|
- Parameter für Benutzer und Paßwort
|
||||||
|
|
||||||
Kommandoliste :
|
Kommandoliste :
|
||||||
|
|
||||||
|
@ -42,22 +44,37 @@ _XINFREQ = 5_000_000
|
||||||
|
|
||||||
LANMASK = %00000000_00000000_00000000_00100000
|
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
|
||||||
|
|
||||||
VAR
|
VAR
|
||||||
|
|
||||||
long ip_addr
|
long ip_addr
|
||||||
byte parastr[64]
|
byte parastr[64]
|
||||||
byte remdir[64]
|
byte remdir[64]
|
||||||
byte filename[64]
|
byte filename[64]
|
||||||
|
byte username[64]
|
||||||
|
byte password[64]
|
||||||
byte strTemp[128]
|
byte strTemp[128]
|
||||||
byte addrset
|
byte addrset
|
||||||
|
byte save2card
|
||||||
byte handleidx_control 'Handle FTP Control Verbindung
|
byte handleidx_control 'Handle FTP Control Verbindung
|
||||||
byte handleidx_data 'Handle FTP Data Verbindung
|
byte handleidx_data 'Handle FTP Data Verbindung
|
||||||
|
|
||||||
PUB main
|
PUB main
|
||||||
|
|
||||||
ip_addr := 0
|
ip_addr := 0
|
||||||
|
save2card := FALSE
|
||||||
remdir[0] := 0
|
remdir[0] := 0
|
||||||
filename[0] := 0
|
filename[0] := 0
|
||||||
|
username[0] := 0
|
||||||
|
password[0] := 0
|
||||||
|
|
||||||
ios.start
|
ios.start
|
||||||
ifnot (ios.admgetspec & LANMASK)
|
ifnot (ios.admgetspec & LANMASK)
|
||||||
|
@ -69,19 +86,23 @@ PUB main
|
||||||
if byte[@parastr][0] == "/" 'option?
|
if byte[@parastr][0] == "/" 'option?
|
||||||
case byte[@parastr][1]
|
case byte[@parastr][1]
|
||||||
"?": ios.print(@help)
|
"?": ios.print(@help)
|
||||||
"s": if ios.paranext(@parastr)
|
"f": if ios.paranext(@parastr)
|
||||||
setaddr(@parastr)
|
setaddr(@parastr)
|
||||||
"v": ios.paranext(@remdir)
|
"v": ios.paranext(@remdir)
|
||||||
"d": ios.paranext(@filename)
|
"d": ios.paranext(@filename)
|
||||||
|
"u": ios.paranext(@username)
|
||||||
|
"p": ios.paranext(@password)
|
||||||
|
"s": save2card := TRUE
|
||||||
other: ios.print(@help)
|
other: ios.print(@help)
|
||||||
|
|
||||||
ifnot ftpconnect
|
|
||||||
ifnot ftplogin(string("anonymous"),string("password"))
|
|
||||||
ifnot byte[@remdir][0] == 0
|
|
||||||
ftpcwd
|
|
||||||
ifnot byte[@filename][0] == 0
|
ifnot byte[@filename][0] == 0
|
||||||
|
ifnot ftpconnect
|
||||||
|
ifnot ftplogin
|
||||||
|
ftpcwd
|
||||||
if ftppasv
|
if ftppasv
|
||||||
ftpretr
|
ftpretr
|
||||||
|
else
|
||||||
|
ios.print(string("Keine Datei zum Downloaden angegeben, beende...",10))
|
||||||
|
|
||||||
|
|
||||||
ftpclose
|
ftpclose
|
||||||
|
@ -90,28 +111,27 @@ PUB main
|
||||||
PRI ftpconnect
|
PRI ftpconnect
|
||||||
|
|
||||||
ifnot (ip_addr) ' Adresse 0.0.0.0
|
ifnot (ip_addr) ' Adresse 0.0.0.0
|
||||||
ios.print(string("FTP-Server nicht angegeben (Parameter /s)"))
|
ios.print(string("FTP-Server nicht angegeben (Parameter /s)",10))
|
||||||
ios.printnl
|
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)
|
||||||
|
if (ip_addr)
|
||||||
|
ios.print(string("Verwende Boot-Server (mit ipconfig gesetzt).",10))
|
||||||
|
else
|
||||||
return(-1)
|
return(-1)
|
||||||
ios.print(string("Starte LAN..."))
|
ios.print(string("Starte LAN...",10))
|
||||||
ios.printnl
|
|
||||||
ios.lanstart
|
ios.lanstart
|
||||||
delay_ms(800) 'nach ios.lanstart dauert es, bis der Stack funktioniert
|
ios.print(string("Verbinde mit FTP-Server...",10))
|
||||||
ios.print(string("Verbinde mit FTP-Server..."))
|
|
||||||
ios.printnl
|
|
||||||
if (handleidx_control := ios.lan_connect(ip_addr, 21)) == $FF
|
if (handleidx_control := ios.lan_connect(ip_addr, 21)) == $FF
|
||||||
ios.print(string("Kein Socket frei..."))
|
ios.print(string("Kein Socket frei...",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
ifnot (ios.lan_waitconntimeout(handleidx_control, 2000))
|
ifnot (ios.lan_waitconntimeout(handleidx_control, 2000))
|
||||||
ios.print(string("Verbindung mit FTP-Server konnte nicht aufgebaut werden."))
|
ios.print(string("Verbindung mit FTP-Server konnte nicht aufgebaut werden.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
ios.print(string("Verbindung mit FTP-Server hergestellt, warte auf Antwort..."))
|
ios.print(string("Verbindung mit FTP-Server hergestellt, warte auf Antwort...",10))
|
||||||
ios.printnl
|
|
||||||
ifnot getResponse(string("220 "))
|
ifnot getResponse(string("220 "))
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
|
@ -124,17 +144,17 @@ PRI ftpclose
|
||||||
ios.lan_close(handleidx_data)
|
ios.lan_close(handleidx_data)
|
||||||
handleidx_data := $FF
|
handleidx_data := $FF
|
||||||
|
|
||||||
PRI ftplogin(username, password) | pwreq, respOK
|
PRI ftplogin | pwreq, respOK, hiveid
|
||||||
|
|
||||||
pwreq := FALSE
|
pwreq := FALSE
|
||||||
respOK := FALSE
|
respOK := FALSE
|
||||||
|
|
||||||
ifnot strsize(username)
|
sendStr(string("USER "))
|
||||||
username := string("anonymous")
|
if strsize(@username)
|
||||||
if sendStr(string("USER ")) || sendStr(username) || sendStr(string(13,10))
|
sendStr(@username)
|
||||||
ios.print(string("Fehler beim Senden des Usernamens"))
|
sendStr(string(13,10))
|
||||||
ios.printnl
|
else
|
||||||
return(-1)
|
sendStr(string("anonymous",13,10))
|
||||||
|
|
||||||
repeat until readLine == -1
|
repeat until readLine == -1
|
||||||
ios.print(string(" < "))
|
ios.print(string(" < "))
|
||||||
|
@ -149,33 +169,42 @@ PRI ftplogin(username, password) | pwreq, respOK
|
||||||
respOk := TRUE
|
respOk := TRUE
|
||||||
quit
|
quit
|
||||||
ifnot respOK
|
ifnot respOK
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
ifnot pwreq
|
ifnot pwreq
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
if sendStr(string("PASS ")) || sendStr(password) || sendStr(string(13,10))
|
sendStr(string("PASS "))
|
||||||
ios.print(string("Fehler beim Senden des Passworts"))
|
if strsize(@password)
|
||||||
ios.printnl
|
sendStr(@password)
|
||||||
return(-1)
|
sendStr(string(13,10))
|
||||||
|
else
|
||||||
|
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
|
||||||
|
sendStr(string("anonymous@hive"))
|
||||||
|
sendStr(str.trimCharacters(num.ToStr(hiveid, num#DEC)))
|
||||||
|
sendStr(string(13,10))
|
||||||
|
|
||||||
ifnot getResponse(string("230 "))
|
ifnot getResponse(string("230 "))
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
PRI ftpcwd
|
PRI ftpcwd | i
|
||||||
|
|
||||||
if sendStr(string("CWD ")) || sendStr(@remdir) || sendStr(string(13,10))
|
if byte[@remdir][0] == 0
|
||||||
ios.print(string("Fehler beim Senden des Verzeichnisses"))
|
i := sendStr(string("CWD ")) || sendStr(@defdir) || sendStr(string(13,10))
|
||||||
ios.printnl
|
else
|
||||||
|
i := sendStr(string("CWD ")) || sendStr(@remdir) || sendStr(string(13,10))
|
||||||
|
if i
|
||||||
|
ios.print(string("Fehler beim Senden des Verzeichnisses",10))
|
||||||
return(-1)
|
return(-1)
|
||||||
ifnot getResponse(string("250 "))
|
ifnot getResponse(string("250 "))
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
|
@ -212,45 +241,38 @@ PRI ftppasv : port | i, k, port256, port1
|
||||||
quit
|
quit
|
||||||
|
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
ios.print(string("FTP-Server-Fehler beim Öffnen des Passiv-Ports"))
|
ios.print(string("FTP-Server-Fehler beim Öffnen des Passiv-Ports",10))
|
||||||
ios.printnl
|
|
||||||
return(0)
|
return(0)
|
||||||
ios.print(string("Öffne Verbindung zu Passiv-Port "))
|
ios.print(string("Öffne Verbindung zu Passiv-Port "))
|
||||||
ios.print(num.ToStr(port, num#DEC))
|
ios.print(num.ToStr(port, num#DEC))
|
||||||
ios.printnl
|
ios.printnl
|
||||||
if (handleidx_data := ios.lan_connect(ip_addr, port)) == $FF
|
if (handleidx_data := ios.lan_connect(ip_addr, port)) == $FF
|
||||||
ios.print(string("Kein Socket frei..."))
|
ios.print(string("Kein Socket frei...",10))
|
||||||
ios.printnl
|
|
||||||
return(0)
|
return(0)
|
||||||
ifnot (ios.lan_waitconntimeout(handleidx_data, 2000))
|
ifnot (ios.lan_waitconntimeout(handleidx_data, 2000))
|
||||||
ios.print(string("Verbindung mit FTP-Server konnte nicht aufgebaut werden."))
|
ios.print(string("Verbindung mit FTP-Server konnte nicht aufgebaut werden.",10))
|
||||||
ios.printnl
|
|
||||||
return(0)
|
return(0)
|
||||||
|
|
||||||
PRI ftpretr | len, respOK
|
PRI ftpretr | len, respOK
|
||||||
|
|
||||||
if sendStr(string("TYPE I",13,10))
|
if sendStr(string("TYPE I",13,10))
|
||||||
ios.print(string("Fehler beim Senden des Types"))
|
ios.print(string("Fehler beim Senden des Types",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
ifnot getResponse(string("200 "))
|
ifnot getResponse(string("200 "))
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
if sendStr(string("SIZE ")) || sendStr(@filename) || sendStr(string(13,10))
|
if sendStr(string("SIZE ")) || sendStr(@filename) || sendStr(string(13,10))
|
||||||
ios.print(string("Fehler beim Senden des SIZE-Kommandos"))
|
ios.print(string("Fehler beim Senden des SIZE-Kommandos",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
ifnot getResponse(string("213"))
|
ifnot getResponse(string("213"))
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
ifnot(len := num.FromStr(@strTemp+4, num#DEC))
|
ifnot(len := num.FromStr(@strTemp+4, num#DEC))
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
if sendStr(string("RETR ")) || sendStr(@filename) || sendStr(string(13,10))
|
if sendStr(string("RETR ")) || sendStr(@filename) || sendStr(string(13,10))
|
||||||
ios.print(string("Fehler beim Senden des Filenamens"))
|
ios.print(string("Fehler beim Senden des Filenamens",10))
|
||||||
return -1
|
return -1
|
||||||
respOK := FALSE
|
respOK := FALSE
|
||||||
repeat until readLine == -1
|
repeat until readLine == -1
|
||||||
|
@ -265,20 +287,35 @@ PRI ftpretr | len, respOK
|
||||||
respOk := TRUE
|
respOk := TRUE
|
||||||
quit
|
quit
|
||||||
ifnot respOK
|
ifnot respOK
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
if ios.lan_rxdata(handleidx_data, @filename, len)
|
if ios.lan_rxdata(handleidx_data, @filename, len)
|
||||||
ios.print(string("Fehler beim Empfang der Datei."))
|
ios.print(string("Fehler beim Empfang der Datei.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
ifnot getResponse(string("226 "))
|
ifnot getResponse(string("226 "))
|
||||||
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten."))
|
ios.print(string("Keine oder falsche Antwort vom FTP-Server erhalten.",10))
|
||||||
ios.printnl
|
|
||||||
return(-1)
|
return(-1)
|
||||||
|
|
||||||
|
if save2card
|
||||||
|
writeToSDCard
|
||||||
|
ios.print(string("Speichere auf SD-Card...",10))
|
||||||
|
|
||||||
|
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
|
PRI setaddr (ipaddr) | pos, count 'IP-Adresse in Variable schreiben
|
||||||
|
|
||||||
count := 3
|
count := 3
|
||||||
|
@ -327,16 +364,20 @@ PRI sendStr (strSend) : error
|
||||||
ios.printnl
|
ios.printnl
|
||||||
error := ios.lan_txdata(handleidx_control, strSend, strsize(strSend))
|
error := ios.lan_txdata(handleidx_control, strSend, strsize(strSend))
|
||||||
|
|
||||||
PRI delay_ms(Duration)
|
DAT
|
||||||
waitcnt(((clkfreq / 1_000 * Duration - 3932)) + cnt)
|
|
||||||
|
|
||||||
DAT 'sys: helptext
|
defdir byte "/hive/sdcard/system",0
|
||||||
|
help byte "/? : Hilfe",10
|
||||||
|
byte "/f <a.b.c.d> : FTP-Server-Adresse",10
|
||||||
help byte "/? : Hilfe",13
|
byte " (default: mit ipconfig gesetzter Boot-Server)",10
|
||||||
byte "/s <a.b.c.d> : Server-Adresse",13
|
byte "/v <verzeichnis>: in entferntes Verzeichnis wechseln",10
|
||||||
byte "/v <verzeichnis>: in entferntes Verzeichnis wechseln",13
|
byte " (default: /hive/sdcard/system)",10
|
||||||
byte "/d <filename> : Download <filename>",13
|
byte "/d <dateiname> : Download <dateiname>",10
|
||||||
|
byte "/u <username> : Benutzername am FTP-Server",10
|
||||||
|
byte " (default: anonymous)",10
|
||||||
|
byte "/p <password> : Paßwort am FTP-Server",10
|
||||||
|
byte " (default: anonymous@hive<Hive-Id>)",10
|
||||||
|
byte "/s : Datei auf SD-Card speichern",10
|
||||||
byte 0
|
byte 0
|
||||||
|
|
||||||
DAT 'lizenz
|
DAT 'lizenz
|
||||||
|
|
|
@ -20,7 +20,7 @@ COG's : -
|
||||||
Logbuch :
|
Logbuch :
|
||||||
|
|
||||||
11.06.2013-joergd - erste Version, basierend auf time.spin
|
11.06.2013-joergd - erste Version, basierend auf time.spin
|
||||||
|
05.01.2014-joergd - kleine Verbesserungen im Parameter-Handling
|
||||||
|
|
||||||
Kommandoliste :
|
Kommandoliste :
|
||||||
|
|
||||||
|
@ -33,13 +33,15 @@ Notizen :
|
||||||
OBJ
|
OBJ
|
||||||
ios: "reg-ios"
|
ios: "reg-ios"
|
||||||
str: "glob-string"
|
str: "glob-string"
|
||||||
num: "glob-numbers" 'Number Engine
|
num: "glob-numbers"
|
||||||
|
|
||||||
CON
|
CON
|
||||||
|
|
||||||
_CLKMODE = XTAL1 + PLL16X
|
_CLKMODE = XTAL1 + PLL16X
|
||||||
_XINFREQ = 5_000_000
|
_XINFREQ = 5_000_000
|
||||||
|
|
||||||
|
LANMASK = %00000000_00000000_00000000_00100000
|
||||||
|
|
||||||
CON 'NVRAM Konstanten --------------------------------------------------------------------------
|
CON 'NVRAM Konstanten --------------------------------------------------------------------------
|
||||||
|
|
||||||
#4, NVRAM_IPADDR
|
#4, NVRAM_IPADDR
|
||||||
|
@ -57,6 +59,8 @@ PUB main
|
||||||
|
|
||||||
ios.start 'ios initialisieren
|
ios.start 'ios initialisieren
|
||||||
ios.printnl
|
ios.printnl
|
||||||
|
ifnot (ios.admgetspec & LANMASK)
|
||||||
|
ios.print(string("WARNUNG!",10,"Administra stellt keine Netzwerk-Funktionen zur Verfügung!",10,"Bitte admnet laden.",10,"(ipconfig funktioniert trotzdem)",10))
|
||||||
ios.parastart 'parameterübergabe starten
|
ios.parastart 'parameterübergabe starten
|
||||||
repeat while ios.paranext(@parastr) 'parameter einlesen
|
repeat while ios.paranext(@parastr) 'parameter einlesen
|
||||||
if byte[@parastr][0] == "/" 'option?
|
if byte[@parastr][0] == "/" 'option?
|
||||||
|
@ -100,20 +104,20 @@ PRI cmd_listcfg | hiveid 'nvram: IP-Konfig
|
||||||
|
|
||||||
ios.print(string(" Hive-Id: "))
|
ios.print(string(" Hive-Id: "))
|
||||||
hiveid := ios.getNVSRAM(NVRAM_HIVE)
|
hiveid := ios.getNVSRAM(NVRAM_HIVE)
|
||||||
hiveid := hiveid + ios.getNVSRAM(NVRAM_HIVE+1) << 8
|
hiveid += ios.getNVSRAM(NVRAM_HIVE+1) << 8
|
||||||
hiveid := hiveid + ios.getNVSRAM(NVRAM_HIVE+2) << 16
|
hiveid += ios.getNVSRAM(NVRAM_HIVE+2) << 16
|
||||||
hiveid := hiveid + ios.getNVSRAM(NVRAM_HIVE+3) << 24
|
hiveid += ios.getNVSRAM(NVRAM_HIVE+3) << 24
|
||||||
ios.print(str.trimCharacters(num.ToStr(hiveid, num#DEC)))
|
ios.print(str.trimCharacters(num.ToStr(hiveid, num#DEC)))
|
||||||
ios.printnl
|
ios.printnl
|
||||||
|
|
||||||
PRI listaddr (nvidx) | count 'nvram: IP-Adresse setzen
|
PRI listaddr (nvidx) | count 'IP-Adresse anzeigen
|
||||||
|
|
||||||
repeat count from 0 to 3
|
repeat count from 0 to 3
|
||||||
if(count)
|
if(count)
|
||||||
ios.print(string("."))
|
ios.print(string("."))
|
||||||
ios.print(str.trimCharacters(num.ToStr(ios.getNVSRAM(nvidx+count), num#DEC)))
|
ios.print(str.trimCharacters(num.ToStr(ios.getNVSRAM(nvidx+count), num#DEC)))
|
||||||
|
|
||||||
PRI cmd_setaddr (nvidx, ipaddr) | pos, count 'nvram: IP-Adresse setzen
|
PRI cmd_setaddr (nvidx, ipaddr) | pos, count 'IP-Adresse setzen
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
repeat while ipaddr
|
repeat while ipaddr
|
||||||
|
@ -125,30 +129,30 @@ PRI cmd_setaddr (nvidx, ipaddr) | pos, count 'nvram: IP-Adresse
|
||||||
if(count == 4)
|
if(count == 4)
|
||||||
quit
|
quit
|
||||||
|
|
||||||
|
ios.lanstop
|
||||||
ios.lanstart
|
ios.lanstart
|
||||||
cmd_listcfg
|
|
||||||
|
|
||||||
PRI cmd_sethive (hiveid) 'nvram: IP-Adresse setzen
|
PRI cmd_sethive (hiveid) 'Hive-Id setzen
|
||||||
|
|
||||||
ios.setNVSRAM(NVRAM_HIVE, hiveid & $FF)
|
ios.setNVSRAM(NVRAM_HIVE, hiveid & $FF)
|
||||||
ios.setNVSRAM(NVRAM_HIVE+1, (hiveid >> 8) & $FF)
|
ios.setNVSRAM(NVRAM_HIVE+1, (hiveid >> 8) & $FF)
|
||||||
ios.setNVSRAM(NVRAM_HIVE+2, (hiveid >> 16) & $FF)
|
ios.setNVSRAM(NVRAM_HIVE+2, (hiveid >> 16) & $FF)
|
||||||
ios.setNVSRAM(NVRAM_HIVE+3, (hiveid >> 24) & $FF)
|
ios.setNVSRAM(NVRAM_HIVE+3, (hiveid >> 24) & $FF)
|
||||||
|
|
||||||
|
ios.lanstop
|
||||||
ios.lanstart
|
ios.lanstart
|
||||||
cmd_listcfg
|
|
||||||
|
|
||||||
DAT 'sys: helptext
|
DAT 'sys: helptext
|
||||||
|
|
||||||
|
|
||||||
help byte "/? : Hilfe",13
|
help byte "/? : Hilfe",10
|
||||||
byte "/l : Konfiguration anzeigen",13
|
byte "/l : Konfiguration anzeigen",10
|
||||||
byte "/a <a.b.c.d> : IP-Adresse setzen",13
|
byte "/a <a.b.c.d> : IP-Adresse setzen",10
|
||||||
byte "/m <x.x.x.x> : Netzwerk-Maske setzen",13
|
byte "/m <x.x.x.x> : Netzwerk-Maske setzen",10
|
||||||
byte "/g <e.f.g.h> : Gateway setzen",13
|
byte "/g <e.f.g.h> : Gateway setzen",10
|
||||||
byte "/d <i.j.k.l> : DNS-Server setzen",13
|
byte "/d <i.j.k.l> : DNS-Server setzen",10
|
||||||
byte "/b <m.n.o.p> : Boot-Server setzen",13
|
byte "/b <m.n.o.p> : Boot-Server setzen",10
|
||||||
byte "/i <Id> : Hive-Id setzen",13
|
byte "/i <Id> : Hive-Id setzen",10
|
||||||
byte 0
|
byte 0
|
||||||
|
|
||||||
DAT 'lizenz
|
DAT 'lizenz
|
||||||
|
|
|
@ -259,7 +259,6 @@ PRI f_connect | t
|
||||||
ios.winset(2)
|
ios.winset(2)
|
||||||
ios.print(string(10,"Starte LAN..."))
|
ios.print(string(10,"Starte LAN..."))
|
||||||
ios.lanstart
|
ios.lanstart
|
||||||
waitcnt(cnt + clkfreq) '1sek warten (nach ios.lanstart dauert es, bis der Stack funktioniert)
|
|
||||||
ios.print(string(10,"Verbinde mit IRC-Server..."))
|
ios.print(string(10,"Verbinde mit IRC-Server..."))
|
||||||
if (handleidx := ios.lan_connect(ip_addr, ip_port)) == $FF
|
if (handleidx := ios.lan_connect(ip_addr, ip_port)) == $FF
|
||||||
ios.print(string(10,"Kein Socket frei!"))
|
ios.print(string(10,"Kein Socket frei!"))
|
||||||
|
|
Loading…
Reference in New Issue