SerialPort.ReadLine
-------------------

Reads a line of text from serial port.

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

MBS( "SerialPort.ReadLine"; PortReference { ; Encoding } ) 

**MBS**( **"SerialPort.ReadLine";** /\* Reads a line of text from serial port. \*/  
**$PortReference**; /\* The reference number of the port. You get this number from [SerialPort.Open](SerialPortOpen.md) when you open the port.e.g. $port \*/   
**$Encoding**) /\* Optional; The text encoding for result.   
Default is native.   
This function can also handle UTF-16 as well as UTF-16LE and UTF-16BE for little/big endian byte order.  
Pass hex or base64 to get text back encoded.e.g. UTF8 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PortReference | The reference number of the port. You get this number from [SerialPort.Open](SerialPortOpen.md) when you open the port. | $port |  |
| Encoding | The text encoding for result.    Default is native.    This function can also handle UTF-16 as well as UTF-16LE and UTF-16BE for little/big endian byte order.   Pass hex or base64 to get text back encoded.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | UTF8 | Optional |

### Result

Returns text or error.

### Description

Reads a line of text from serial port.  
The plugin buffers input and reads text until first newline character. Returns text without that newline character.  
  
You may need to put in script pauses between sending a request and reading the response as the other device may need a second to process the request, answer and for the answer to be received.  
  
The script trigger pauses after it triggered a script and waits for you to call a function to read. This function clears the flag and allows the script trigger to fire again.  
### See also

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

### Release notes

- **Version 7.3**
    - Fixed issue with [SerialPort.ReadLine](http://www.mbsplugins.eu/SerialPortReadLine.shtml) being off by one.
- **Version 7.0**
    - Added [SerialPort.HasLine](http://www.mbsplugins.eu/SerialPortHasLine.shtml) and [SerialPort.ReadLine](http://www.mbsplugins.eu/SerialPortReadLine.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 7.3pr4](https://www.mbsplugins.de/archive/2017-06-29/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.0pr1](https://www.mbsplugins.de/archive/2017-01-02/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 21st December 2016 , last changed 30th January 2025

  
[SerialPort.ReadHex](SerialPortReadHex.md) - [SerialPort.Resume](SerialPortResume.md)

[HTML Version](SerialPortReadLine.shtml)