Serial_Control |
Controls the serial port with the specified name. The port needs to be opened first (see also Serial_Open).
Syntax
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 function
Serial_Open |
Related script step
Suspend/Resume Serial Port |
Related topics
Troi Serial Plug-in online help (overview)