Send Serial Data (script step reference)

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

Send Serial Data

Sends data to the serial port with the specified name. The port needs to be opened first (see also Open Serial Port).

SyntaxScript step badge

Send Serial Data [ Select ; Result (error) ; Port name ; Data to send ]

Options

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 (error)an error code
Port namethe name of the port to send data to
Data to sendthe text data that is to be sent to the serial port

Returned Result

Data type returned

Error code

Result

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

0no errorthe data was sent
$$-28notOpenErrthe port is not open
$$-108memFullErrran out of memory
$$-50paramErrthere was an error with the parameter
$$-4210portDoesnotExistErra port with this name is not available on this computer
$$-4211allPortsNullErrno serial ports are available on this computer
$$-207notEnoughSpacethe output buffer is full

Other errors may be returned.

Originated in

Troi Serial Plug-in 9.0

Compatibility

FileMaker Pro 16

Considerations

Make sure you use a text field for the data. Other field types, like containers are currently not supported.

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

Example

Send Serial Data [ Select ; $ErrorCode ; 
                                    "Modem port" ; "So long" ]

This will send the string ” So long” to the Modem port.

Send Serial Data [ Select ; $ErrorCode ; 
                           gPortName ; textToSend ]

This will send the text in the field textToSend to the port in the field gPortName.

Example 2

Below you find a “Send Data” script for sending data from a global text field gTextToSend. The script tests for errors.

We assume that in your FileMaker file the following fields are defined:

gPortName	Global, text, contains the name of the previously opened port 
gTextToSend	Global, text, can also be a normal text field
gErrorCode	Global, text

Add the following script steps:

Send Serial Data [ Select ; gErrorCode ; gPortName ; gTextToSend ) ]
If [ Left ( gErrorCode ; 2 ) = "$$" ]
	Beep
	If [ gErrorCode = "$$-28" ]
		Show Message [ Open the port first ]
	Else
		If [ gErrorCode = "$$-207" ]
			Show Message [ Buffer overflow error ]
		Else
			Show Message [ An error occurred while sending! ]
		End If
	End If
	Halt Script
End If

Related script stepsScript step badge

Open Serial Port
Receive Serial Data

Related functionsFunction badge

Serial_Open
Serial_Receive
Serial_Send

Online Help Page for Troi Serial Plug-in for 12 to 16 –> Send Serial Data (serip7809) 2017-0525 11:27:56