' WLAN RS232 Logger and TCP Device Server ' (c) Avisaro AG 07.12.2009 ' Script cc3-1.txt put -203, #1 sleep 100 exec "fsync 1000" let n = 0 REM Default-Werte ? if (KEYS & 1) = 1 then let t = time + 30 while t > time if ((KEYS & 1) = 0) then goto STARTING end if setleds 255 sleep 500 setleds 0 sleep 10 wend exec "restart clear" setleds 255 do sleep 1 loop end if STARTING: inmode -3 outmode -2 dim C(28) dim R(1400) DIM B(0) let web = 0 let t_w = time let trans = 0 let n = 0 let t = TIME + 5 let f = 60 let m = 0 let u = 0 let y = 0 let stat_f = 0 let stat_w = 0 REM INIT WEB let x$ = "Connect to IP (0 for listening):" put -100, x$, len(x$) let x$ = "Send to / Listen (Port):" put -102, x$, len(x$) let x$ = "Status (Version CC2-2):" put -104, x$, len(x$) load 0, t$ if (len(t$) > 16 or len(t$) = 2) then let t$ = "192.168.0.1" save 0, t$ end if put -101, t$, len(t$) load 25, u if (-1 = u) then let u = 23 save 25, u end if let x$ = str$(u) put -103, x$, len(x$) MAIN: if stat_w = 0 then close 101 if (t$ = str$(0)) then sleep 50 listen 101, u, 0 else let y = RESOLV (t$) sleep 500 connect 101, y, u, 5 end if let stat_w = 1 end if if stat_w = 1 then let y = status(101) if y = 9 then let x$ = "Connected" let stat_w =2 else let x$ = "not connected" if t_w = time then put -203, #0 end if end if gosub load_web if web = 1 then let stat_w = 0 end if end if if stat_w = 2 then let y = status(101) if y = 9 then 'read and output incoming data get 101, R if BYTESREAD > 0 then put -2, R, BYTESREAD put -203, #0 end if else let x$ = "not connected" let stat_w = 0 end if gosub load_web if web = 1 then let stat_w = 0 end if end if if t_w < time then let t_w = time + 1 put -203, #1 end if CONT_W: if stat_f = 0 then gosub OPEN_FILE let time_f = time +1 let stat_f = 1 end if if stat_f = 1 then if time > time_f then let stat_f = 0 end if end if CONT_F: input R if BYTESREAD > 0 then let y = status(101) if y = 9 then put 101, R, BYTESREAD put -203, #0 end if let y = status(1) if y = 2 then put 1, R, BYTESREAD put -202, #0 end if end if goto MAIN load_web: let web = 0 put -105, x$, len(x$) REM Änderung auf Webseite ? get -103, x$ if val(x$) <> u then let u = val(x$) save 25, u let web = 1 end if get -101, x$ if t$ <> x$ then let t$ = x$ save 0, t$ let web = 1 end if return OPEN_FILE: let temp = lof(0) if (temp > 0) then if (status(1) <> 2) then close 1 let n$ = date$ let f$ = mid$(date$, 3 , 2) + mid$(date$, 6 , 2) + mid$(date$, 9 , 2) + ".txt" open "AB", 1, f$ if LASTERR <> 0 then open "WB", 1, f$ if LASTERR <> 0 then close 1 end if end if else ' File is open put -202, #1 ' neuer Tag ? if n$ <> date$ then close 1 end if end if else put -202, #0 end if return