Serial_Control (function reference)

By September 1, 2019 September 4th, 2019 Online 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

switchesthe action that needs to be done
portnamethe name of the port to control

Switches

Switches can be either:

-SuspendThis will suspend reading the incoming stream of data.
-ResumeThis 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:

0no errorthe data was sent
$$-28notOpenErrthe port is not open
$$-50paramErrthere was an error with the parameter

Other errors may be returned.

Originated in

Troi Serial Plug-in 3.0

Compatibility

FileMaker Pro 14 to 18

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 ) ]

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 14 to 18 –> Serial_Control (serip4801) 2019-0904 11:29:03