Receive Serial Data (script step reference)

Troi Serial Plug-in > Script steps reference > Receive Serial Data
Troi Serial Plug-in for FileMaker Pro

Receive Serial Data

Receives data from a serial port with the specified name.

SyntaxScript step badge

Receive Serial Data [ Select ; Result (error) ; Port name ; Encoding ;
Get last match ]


Select entire contentsreplaces the entire contents of a field with the result. If not checked the result is added to the currently selected portion of the field
Result datathe data received
Port namethe name of the port to receive data from
Encodingthe desired character encoding like UTF-8, or "Convert bytes to numbers" which converts all received bytes to their numeric value, with a space as separator
Get last matchget the last string of text that matches the match string

Returned Result

Data type returned



The returned result is the data received or an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors when receiving, by testing if the first two characters are dollars. Returned error codes can be:

$$-28notOpenErrthe port is not open
$$-108memFullErrran out of memory
$$-50paramErrthere was an error with the parameter
$$-4210portDoesNotExistErrport with this name is not available on this computer
$$-4211allPortsNullErrno serial ports are available on this computer
$$-207notEnoughBufferSpacethe input buffer is full

Other errors may be returned.

Originated in

Troi Serial Plug-in 9.0


FileMaker Pro 16


The port needs to be opened first (see Open Serial Port).
If no data is available an empty string is returned.
The plug-in will get any data that is received at the time the function is called. This might not be all data coming in. You might need to wait and append new data coming in at a later time.

When you use the “Get last match” option the last matching string of text is returned. Older text is discarded.

Please be aware that only the ASCII characters 0…255 will be received, as a serial port uses 8 bit characters.

When using the encoding “Convert bytes to numbers” all received bytes are converted to their numeric value. It will for example return “65 66 67 “, when receiving the bytes “ABC”. Note that each number is followed by a space, as separator, including after the last number.


Receive Serial Data [ Select ; $Result ; "SerialPort1" ]

This will receive data from the SerialPort1. It might return “All the world is a sta”. If you call it again later new data may have come in and the result might be “ge and we are merely players.” It is best to concatenate the data coming in.

Example 2

Below you find a “Receive Data” script for receiving data into a variable $TempResultReceived. The script tests for errors.

We assume that $PortName contains the name of the previously opened port.

Add the following script steps:

Receive Serial Data [ Select ; $TempResultReceived ; $PortName ]
If [ Left ( $TempResultReceived ; 2 ) = "$$" ]
	If [ $TempResultReceived = "$$-28" ]
		Show Message [ Open the port first ]
		If [ $TempResultReceived = "$$-207" ]
			Show Message [ Buffer overflow error ]
			Show Message [ An error occurred! ]
		End If
	End If
Halt Script
	# No error, so concatenate the data and do your stuff:
	Set Variable [ $TotalResult ; $TotalResult & $TempResultReceived ]
	#  .... add your own steps here ...
End If
Set Field [ gTotalResult ; $TotalResult // also save into a global field ]

Related script stepsScript step badge

Open Serial Port
Send Serial Data

Related functionsFunction badge


Online Help Page for Troi Serial Plug-in for 12 to 16 –> Receive Serial Data (serip7806) 2017-0525 11:16:26