Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.5   10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2    Statistic    FMM    Blog  

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

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


SendMail.SetSubject - SerialPort.Clear

Feedback: Report problem or ask question.