zeroflag / punyforth

Forth inspired programming language for the ESP8266
Other
406 stars 43 forks source link

An interesting bug in the example dht22-data-loger or in netcon? #51

Open gerey73 opened 5 years ago

gerey73 commented 5 years ago

I changed the example a little:

exception: EGAVEUP
variable: data
variable: server
variable: ecnt
 : measure ( -- temperature humidity | throws:EGAVEUP )
    10 0 do
        ['] dht-measure catch ?dup if ex-type cr 5000 ms else unloop exit then
    loop
    EGAVEUP throw ;
 : data! ( temperature humidity -- ) 16 lshift swap or data ! ;
 : connect ( -- ) 8005 "192.168.1.6" TCP netcon-connect server ! ; 
 : dispose ( -- ) server @ netcon-dispose ;
 : send ( -- ) server @ data 4 netcon-write-buf ;
 : log ( temperature humidity -- ) data! connect ['] send catch dispose throw ;
 : log-measurement ( -- ) { measure log } catch ?dup if  ex-type  1 ecnt +! ecnt @ space . cr then ; 
\ : main ( -- ) log-measurement 50 ms 120000000 deep-sleep ;
: main begin log-measurement 2000 ms again ;    

As long as the "server" receiving the information is working, everything seems fine. But if you stop the server and wait for> 70 attempts to connect to the server and start the server again, then (esp8266) can no longer connect. Up to 70 attempts a connection is restored. Failed to connect to 192.168.1.6:8005. Error: -14 NETCON error: -14 ENETCON 67 Failed to connect to 192.168.1.6:8005. Error: -14 NETCON error: -14 ENETCON 68 Failed to connect to 192.168.1.6:8005. Error: -14 NETCON error: -14 ENETCON 69 Failed to connect to 192.168.1.6:8005. Error: -14 NETCON error: -14 ENETCON 70 Failed to connect to 192.168.1.6:8005. Error: -14 NETCON error: -14 ENETCON 71 ENETCON 72 ENETCON 73 ENETCON 74 ENETCON 75 ENETCON 76 ENETCON 77