Skip to main content

Serial_Control (function reference)

By July 1, 2023July 17th, 2023Online Help, Troi Serial Plug-in
Troi Serial Plug-in for FileMaker Pro

Serial_Control

Controls the serial port with the specified name. The port needs to be opened first (see also Serial_Open).

SyntaxFunction badge

Serial_Control ( switches ; portname )

Parameters

switches the action that needs to be done
portname the name of the port to control

Switches

Switches can be either:

-Suspend This will suspend reading the incoming stream of data.
-Resume This will resume reading the incoming stream of data.

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:

0 no error the data was sent
$$-28 notOpenErr the port is not open
$$-50 paramErr there was an error with the parameter

Other errors may be returned.

Originated in

Troi Serial Plug-in 3.0

Compatibility

FileMaker Pro 16 to FileMaker Pro 2023

Considerations

The buffer will be emptied when the port is suspended. So when you resume, only the data received after you resume will be available. While suspended you can still send data to the serial port.

This function is very useful for devices that send out continuous data, like an electronic weighing scale.

Example

Set Field [ gResult ;  Serial_Control ( "-Suspend" ;  "COM1" ) ]

This will suspend the incoming stream of data.

Example 2

For devices that send out continuous data, like an electronic weighing scale, you open the port and suspend the incoming data. Then when you want a reading you resume the incoming stream. The script will be like this:

Set Field [ gErrorCode ;  Serial_Open ( "-Unused" ;  gPortName ) ]
Set Field [ gErrorCode ;  Serial_Control ( "-Suspend" ;  gPortName ) ]
# do other stuff here, until you need data from the device ...
Set Field [ gErrorCode ;  Serial_Control ( "-Resume" ;  gPortName ) ]
# read data until you got the expected data:
Set Field [ gErrorCode ;  Serial_Read ( "-Unused" ;  gPortName ) ]
# this will suspend reception of data from the port in field gPortName:
Set Field [ gErrorCode ;  Serial_Control ( "-Suspend" ;  gPortName ) ]

Used in example file

Terminal.fmp12

Related functionFunction badge

Serial_Open

Related script stepScript step badge

Suspend/Resume Serial Port

Related topics

Troi Serial Plug-in online help (overview)


Online Help Page for Troi Serial Plug-in for 16 to 2023 –> Serial_Control (serip4801) 2023-0717 13:05:30