Open Serial Port (script step reference)

Troi Serial Plug-in > Script steps reference > Open Serial Port
Troi Serial Plug-in for FileMaker Pro

Open Serial Port

Opens a serial port with this name and the specified parameters.

SyntaxScript step badge

Open Serial Port [ Select ; Result (error) ; Port name ; Settings ;
File name ; Script name ; Resume paused script ;
No idle wait time ]

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 open
Settings(optional) specifies the setting of the port like the speed of the port, parity, etc.
File name(optional) the name of the FileMaker file which contains the script to trigger when data comes in
Script name(optional) specifies the name of the script to trigger when data comes in
Resume paused scriptwhen the trigger script needs to run, and an other script is already paused, the paused script will resume after the trigger script is finished
No idle wait timedon’t add idle wait times, the triggering will be faster, but the plug-in will need more computer time

Returned Result

Data type returned

Error code

Result

Returned result is an error code. Returned error codes can be:

0no errorthe port was opened
$$-50paramErrthere was an error with the parameter
$$-108memFullErrran out of memory
$$-97portInUsecould not open port, the port is in use
$$-4210portDoesNotExistErrport with this name is not available on this computer
$$-4211allPortsNullErrno serial ports are available on this computer

Other errors may be returned.

Originated in

Troi Serial Plug-in 9.0

Compatibility

FileMaker Pro 16

Considerations

If you specify a filename and scriptname any scripts specified with the function “Serial_SetDispatchScript” will be ignored for this port.

If you specify a filename you must also provide a scriptname.

Example

Open Serial Port [ Select ; $ErrorCode ; "COM2" ; 
                   "baud=19200 parity=none  data=8 stop=10 " &
                   "flowControl=DTRDSR  flowControl=RTSCTS" ;
                   "" ; "" ]

will open the COM2 port with a speed of 19200 baud and the specified options.

Example 2

Set Variable [ $Settings ; gSpeed & " " & gStopBits & " " & gDataBits & " " &
                          gParity & " " & gFlowControl ]

Open Serial Port [ Select ; $ErrorCode ; 
                   gPortName1 ;
                   $Settings
                   Get ( FileName ); 
                   "Process Data Received for 1st Port" ]

Set Field [ gErrorCode ; $ErrorCode // also save into a field ]

This will open the port in field gPortName1 with the specified speed and other options. When data comes in the script “Process Data Received for 1st Port” in the current filename will be triggered. An error code is set in the $ErrorCode variable and also saved into a global field.

Related script stepsScript step badge

Close Serial Port
Set Serial Trigger Script

Related functionsFunction badge

Serial_Close
Serial_Open
Serial_Reinitialize

Online Help Page for Troi Serial Plug-in for 12 to 16 –> Open Serial Port (serip7805) 2017-0525 11:12:41