available
result = available(conn)
Input: conn · Output: result
What it is
conn (a Serial handle from serial_open).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = available(conn) | conn Serialnot documented yet | result — | Returns an integer: bytes waiting on the OS's serial input buffer right now, without blocking. Check it before a read you do not want to block on. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
ports = serial_ports()
if length(ports) > 0
conn = serial_open(ports[0], 9600, timeout_ms=200)
n = available(conn) # bytes waiting, non-blocking
data = read_bytes(conn, 4) # up to 4 bytes, short read on timeout
print("available={n}, got {length(data)} byte(s)")
close(conn)
else
print("no serial hardware attached")
end if
output
available=0, got 0 byte(s)
from concurrency
How it works
serial_open(port, baud_rate, ...) / serial_ports() (§ real module's own doc comment for the full builtin-by-builtin design. read_bytes/available are new method names (no other Value kind answers to them, unlike read_line/ close/write above, which are shared with Value::File/ Value::UrlStream and so are guarded arms further up this match instead).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.