' WLAN CAN Device Server ' (c) Avisaro AG 15.05.2009 ' Version 3-1 put -203, #1 sleep 1000 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 put -202, #1 sleep 500 put -202, #0 sleep 10 next n exec "restart clear" put -202, #1 put -203, #1 do sleep 1 loop end if STARTING: sleep 500 inmode -3 outmode -2 dim C(1400) let trans = 0 let n = 0 let t = TIME + 5 let f = 60 let m = 0 let u = 0 let y = 0 let ip1$ = "" let Modus$ = "" let x$ = "Uplink IP Adresse:" put -100, x$, len(x$) let x$ = "Start/Mitte/Ende:" put -102, x$, len(x$) let x$ = "Status (Script WC3 ver 1):" put -104, x$, len(x$) load 0, ip1$ if (len(ip1$) > 16 or len(ip1$) = 2) then let ip1$ = "192.168.0.1" save 0, ip1$ end if put -101, ip1$, len(ip1$) load 25, Modus$ if (Modus$ <> "Start") and (Modus$ <> "Mitte") and (Modus$ <> "Ende") then let Modus$ = "Mitte" save 25, Modus$ end if put -103, Modus$, len(Modus$) TRY_CONNECT: put -202, #0 sleep 500 put -202, #1 ' CAN leer lesen get -3, C if (Modus$ = "Start") then close 102 sleep 50 listen 102, 9321, 0 sleep 500 let y = status(102) if (y = 9) then goto MAIN end if end if if (Modus$ = "Mitte") then y = status(102) if (y <> 9) then close 102 sleep 50 listen 102, 9321, 0 'else ' Buffer leer lesen ' get 102, C end if close 101 sleep 100 let y = RESOLV (ip1$) sleep 100 connect 101, y, 9321, 5 sleep 500 let y = status(101) if (y = 9) then goto MAIN end if end if if (Modus$ = "Ende") then close 101 let y = RESOLV (ip1$) sleep 100 connect 101, y, 9321, 5 sleep 500 let y = status(101) if (y = 9) then goto MAIN end if end if let x$ = "waiting ..." gosub load_web goto TRY_CONNECT MAIN: let trans = 0 if (Modus$ = "Start") then y = status(102) if y <> 9 then close 102 goto TRY_CONNECt end if end if if (Modus$ = "Mitte") then y = status(101) if y <> 9 then close 101 close 102 goto TRY_CONNECt end if y = status(102) if (y = 0) then close 102 listen 102, 9321, 0 end if end if if (Modus$ = "Ende") then y = status(101) if y <> 9 then close 101 goto TRY_CONNECt end if end if get -3, C if BYTESREAD >= 28 then put -203, #0 repeat_up1: y = status(101) if (y = 9) then put 101, C, BYTESREAD if LASTERR <> 0 then sleep 1 goto repeat_up1 end if end if repeat_down1: y = status(102) if (y = 9) then put 102, C, BYTESREAD if LASTERR <> 0 then sleep 1 goto repeat_down1 end if end if end if get 101, C if BYTESREAD >= 28 then put -203, #0 repeat_can1: put -7, C, BYTESREAD ' keine Errorbehandlung (nicht sinnvoll) repeat_down2: y = status(102) if (y = 9) then put 102, C, BYTESREAD if LASTERR <> 0 then sleep 1 goto repeat_down2 end if end if end if get 102, C if BYTESREAD >= 28 then put -203, #0 repeat_can2: put -7, C, BYTESREAD ' keine Errorbehandlung (nicht sinnvoll) repeat_up2: y = status(101) if (y = 9) then put 101, C, BYTESREAD if LASTERR <> 0 then sleep 1 goto repeat_up2 end if end if end if if (trans = 0) then ' mal wenig los if t < TIME then put -203, #1 let x$ = "connected" 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 x$ <> Modus$ then let Modus$ = x$ save 25, x$ end if get -101, x$ if x$ <> ip1$ then let t$ = x$ save 0, x$ end if return