Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

SerialPort.AvailableBytes

Queries number of bytes available in buffer.

Component Version macOS Windows Linux Server iOS SDK
SerialPort 4.4 ✅ Yes ✅ Yes ❌ No ✅ Yes, on macOS and Windows ❌ No
MBS( "SerialPort.AvailableBytes"; PortReference )   More

Parameters

Parameter Description Example
PortReference The reference number of the port. You get this number from SerialPort.Open when you open the port. $port

Result

Returns number or error.

Description

Queries number of bytes available in buffer.

Examples

Queries bytes and reads them:

$count = MBS( "SerialPort.AvailableBytes"; $PortReference )
$text = MBS( "SerialPort.Read"; $PortReference; $count; "windows" )

Read in loop as long as data comes in:

# read data until end
Set Variable [$data; Value:""]
Loop
    Pause/Resume Script [Duration (seconds): ,1]
    #exit when no more data
    Exit Loop If [not (MBS( "SerialPort.AvailableBytes"; $port ) > 0)]
    #read some data
    Set Variable [$newdata; Value:MBS( "SerialPort.Read"; $port; 10000; "windows" )]
    Set Variable [$data; Value:$data & $newdata]
    #next
    Pause/Resume Script [Duration (seconds): ,1]
End Loop

See also

Blog Entries

This function is free to use.

Created 21st October 2014, last changed 30th November 2016


SendMail.Sign - SerialPort.Clear