Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5   8.0   8.1    Statistic  


Reads bytes from serial port and returns them as text.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
SerialPort 3.0 Yes Yes Yes No No

MBS( "SerialPort.Read"; PortReference; length { ; Encoding } )


Parameter Description Example value
PortReference The reference number of the port. You get this number from SerialPort.Open when you open the port. $port
length Maximum number of bytes to read. 10
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.
Possible encoding names: ANSI, Arabic-Mac, Arabic-Win, Baltic-Win, CentralEurope-Mac, ChineseSimp-Mac, ChineseSimp-Win, ChineseTrad-Mac, ChineseTrad-Win, Cyrillic-Mac, Cyrillic-Win, EasternEurope-Win, Greek-Mac, Greek-Win, Hebrew-Mac, Hebrew-Win, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-15, Korean-Johab, Korean-Mac, Korean-Win, Latin1, Mac, Native, ShiftJIS-Mac, ShiftJIS-Win, Turkish-Mac, Turkish-Win, UTF-8, DOS or Windows. Pass native to use the native encoding of the current platform.


Returns text or error message.


Reads bytes from serial port and returns them as text.
The text returned may be shorter than length bytes.
See also SerialPort.AvailableBytes function.


Read up to 8 bytes and decode them from Windows text encoding into FileMaker:

$value = MBS( "SerialPort.Read"; $port; 8; "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

SerialPort.Open   -   SerialPort.ReadByte

Feedback: Report problem or ask question.

MBS Xojo Plugins