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


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


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


Returns number or error.


Queries number of bytes available in buffer.


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:""]
    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]
    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