
The STATUS function allows a program to get the state of various handles. It needs one single argument that is the handle number to be queried. STATUS can be used on files, TCP connections, UDP channels and on some pseudo handles. The list below describes that in detail:
| 1 | File is open for reading |
| 2 | File is open for writing |
| -1 | File is closed |
| 0 | Not a file handle |
| 1 | Socket is in listening state |
| 2 | Socket was in listening state and has just received a connection request (SYN) |
| 3 | Socket wants to connect to another TCP (Has sent a SYN) |
| 4 | Socket is about to be closed (in FIN_WAIT_1 state) |
| 5 | Socket is about to be closed (in FIN_WAIT_2 state) |
| 6 | Socket wants to close the connection |
| 7 | Socket has received last packet before the communication ends |
| 8 | Socket waits for last packet before the communication ends |
| 9 | Socket is connected |
| 0 | Socket is closed |
| 1 | UDP channel is open,. Handle in use |
| 0 | Handle not in use |
| 1 | WLAN connected |
| 0 | WLAN not connected |
SCAN : Search for WLAN networks
SCANNED : Returns number of found WLAN networks
GETSCAN : Read results from scan command
STATUS(-4]) : Returns status of WLAN connection
| x | Number of free packet buffers |
| x | Number of Bytes in TX Fifo |
If IIC is used in Slave mode, Incomiing and outgoing data is stored into FIFO buffers. STATUS(-15) returns the number of bytes that the TX buffer currently holds. Data is transmitted in the background, so this value may change from call to call.
The following example demonstrates the STATUS function for file handles. You need an SD slot to run this example. If a file named "status.txt" already exists, it will be deleted.
outmode -2
close 1
kill "status.txt"
print "status of 1: ";
let s = status(1)
print s
open "W", 1, "status.txt"
if LASTERR <> 0 then
print "failed to create new file"
end
end if
print "status of 1: ";
let s = status(1)
print s
close 1
print "status of 1: ";
let s = status(1)
print s
STATUS will be extended in future releases in order to retrieve more system information.
V3.34 and below: STATUS can't be used in expressions and must always assigned to variables. This problem is fixed in V 3.35 and above.