SerialPort.AvailableBytes
-------------------------

Queries number of bytes available in buffer.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SerialPort](component_SerialPort.md) | [4.4](newinversion44.md) | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes, on macOS and Windows | ❌ No |

MBS( "SerialPort.AvailableBytes"; PortReference ) 

**MBS**( **"SerialPort.AvailableBytes";** /\* Queries number of bytes available in buffer. \*/  
**$PortReference**) /\* The reference number of the port. You get this number from [SerialPort.Open](SerialPortOpen.md) when you open the port.e.g. $port \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PortReference | The reference number of the port. You get this number from [SerialPort.Open](SerialPortOpen.md) 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](SerialPortRead.md)"; $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 ) &gt; 0)\]  
 #read some data  
 Set Variable \[$newdata ; Value:MBS ( "[SerialPort.Read](SerialPortRead.md)"; $port ; 10000; "windows" )\]  
 Set Variable \[$data ; Value:$data &amp; $newdata \]  
 #next  
 Pause/Resume Script \[Duration (seconds): ,1\]  
End Loop  
### See also

- [SerialPort.Open](SerialPortOpen.md)
- [SerialPort.Read](SerialPortRead.md)
- [SerialPort.ReadByte](SerialPortReadByte.md)
- [SerialPort.ReadHex](SerialPortReadHex.md)

### Blog Entries

- [MBS Filemaker Plugin, version 4.4pr7](https://www.mbsplugins.de/archive/2014-10-27/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function is free to use.

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

  
[SendMail.Sign](SendMailSign.md) - [SerialPort.Clear](SerialPortClear.md)

[HTML Version](SerialPortAvailableBytes.shtml)