Controls the serial port with the specified name. The port needs to be opened first (see also Serial_Open).
Serial_Control ( switches ; portname )
|switches||the action that needs to be done|
|portname||the name of the port to control|
Switches can be either:
|-Suspend||This will suspend reading the incoming stream of data.|
|-Resume||This will resume reading the incoming stream of data.|
Data type returned
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.
Troi Serial Plug-in 3.0
FileMaker Pro 16 to 19
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.
Set Field [ gResult ; Serial_Control ( "-Suspend" ; "COM1" ) ]
This will suspend the incoming stream of data.
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 script step
|Suspend/Resume Serial Port|