' WLAN CAN Device Server ' (c) Avisaro AG 14.10.2008 ' Version 1-8 setleds 32 sleep 100 let n = 0 REM Default-Werte ? if (KEYS & 1) = 1 then for n = 0 to 120 if ((KEYS & 1) = 0) then goto STARTING end if setleds 255 sleep 500 setleds 0 sleep 10 next n exec "wlan ssid avisaro" sleep 100 exec "wlan security none" sleep 100 exec "wlan mode adhoc" sleep 100 exec "ip local 192.168.0.74" sleep 100 exec "ip mask 255.255.255.0" sleep 100 exec "can 125000 49 0 49 0" sleep 100 exec "prot can" setleds 255 do sleep 1 loop end if STARTING: sleep 5000 inmode -3 outmode -2 dim C(1400) dim R(100) DIM A(500) DIM B(0) let trans = 0 let n = 0 let t = TIME + 5 let f = 60 let m = 0 let u = 0 let y = 0 REM INIT WEB let x$ = "Target UDP-IP (All = 4x255):" put -100, x$, len(x$) let x$ = "Send to / Listen (Port):" put -102, x$, len(x$) let x$ = "Status (Script WC1 ver 1.7):" 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$) TRY_CONNECT: let x$ = "connecting" gosub load_web let y = RESOLV (t$) sleep 500 udpopen 201, y, u, u, 5, 0 hset 201, 1, 8 hset 201, 0, 8 setleds 0 sleep 50 setleds 32 let y = status(201) if y = 1 then let x$ = "UDP Opened" gosub load_web REM Connected goto MAIN else close 201 end if goto TRY_CONNECT MAIN: 'if (KEYS & 1) = 1 then ' close 201 ' setleds 32 ' goto TRY_CONNECT 'end if let trans = 0 'getcan C get -3, C if BYTESREAD >= 28 then setleds 16 repeat_putlan: put 201, C, BYTESREAD if LASTERR <> 0 then sleep 0 goto repeat_putlan end if let trans = 1 end if get 201, C if BYTESREAD >= 28 then setleds 16 repeat_putcan: put -7, C, BYTESREAD if LASTERR <> 0 then sleep 0 goto repeat_putcan end if let trans = 1 end if if (trans = 0) then ' mal wenig los if t < TIME then setleds 48 let x$ = "UDP ok" put -105, x$, len(x$) gosub load_web let t = TIME end if end if sleep 0 goto MAIN load_web: put -105, x$, len(x$) REM Änderung auf Webseite ? get -103, x$ if val(x$) <> u then let u = val(x$) save 25, u end if get -101, x$ if t$ <> x$ then let t$ = x$ save 0, t$ end if return