Jump to content

Component: COM Port (Runtime Tools)

From Flowcode Help
Revision as of 14:20, 13 July 2026 by SteveT (talk | contribs) (Text replacement - "width="10%" align="center" style="background-color:#D8C9D8;"" to "width="10%" align="center" class="mtx-class-macrohead"")
Author Matrix Ltd
Version 103.11
Category Runtime Tools


COM Port component

Serial based simulation component for use with systems such as RS232, Bluetooth and USB Serial.

Version information

Library Version, Component Version, Date, Author, Info
10, 103.10, 07-04-25, MW, Modified ReceiveArray NumValues from Byte to UInt
11, 103.11, 01-05-25, BR, Changed SendString macro to make it more efficient


Detailed description

No detailed description exists yet for this component

Examples

No additional examples

Macro reference

ClosePort

ClosePort
Closes the currently open COM port, ending communications and allowing it to be accessed via another application. 
- VOID Return


ConfigureConsole

ConfigureConsole
 
- BYTE Status
 
- VOID Return


GetConsoleHandle

GetConsoleHandle
Gets the handle to the console allowing data displaying on the panel etc. 
- HANDLE Return


GetProp

GetProp
Allows the property filter for the COM port list to be copied to a parent component. 
- STRING PropName
 
- STRING Return


OpenPort

OpenPort
Opens the currently selected COM port, allowing data to be sent and received. 
- VOID Return


ReceiveBinary16Bit

ReceiveBinary16Bit
Receives a binary 16-bit value split across two bytes. 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- UINT Return


ReceiveBinary32Bit

ReceiveBinary32Bit
Receives a binary 32-bit value split across four bytes. 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- ULONG Return


ReceiveBinaryFloat

ReceiveBinaryFloat
Receives a binary 32-bit floating point value split across four bytes. 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- FLOAT Return


ReceiveByte

ReceiveByte
Attempts to receive a byte using the COM port No valid return data is provided by the timeout value property. 
- UINT Timeout
Time to wait for incoming data in milliseconds 
- UINT Return


ReceiveByteArray

ReceiveByteArray
Attempts to receive an array of bytes using the COM port Returns the number of bytes received.  
- BYTE Data
 
- UINT MaxLength
Max number of bytes to try and read 
- UINT Timeout
Time to wait for incoming data in milliseconds 
- UINT Return


ReceiveFloat

ReceiveFloat
Attempts to receive a floating point number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost. 
- BYTE Timeout
Max time in ms to wait in between bytes 
- BOOL IgnoreData
0=Dont ignore any data, 1=Ignore any initial none numeric data 
- FLOAT Return


ReceiveHexNumber

ReceiveHexNumber
Attempts to receive a hex number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none hexadecimal char is received, the none numeric char will be lost. 
- BYTE Timeout
Max time in ms to wait in between bytes 
- BOOL IgnoreData
0=Dont ignore any data, 1=Ignore any initial none numeric data 
- BOOL Prefix
Look for prefix before receiving, 1=0xFF, 0=FF 
- ULONG Return


ReceiveINTArray

ReceiveINTArray
Receives an array of 16-bit INT/UINT values and returns the number of values received. 
- UINT Data
Array to store the incoming data 
- UINT NumValues
Maximum number of values to try and receive 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- BYTE Timeout
Max amount of time in ms to wait between bytes 
- INT Return


ReceiveNumber

ReceiveNumber
Attempts to receive a number as ASCII characters and convert back into a numeric value. Note this function will receive until a timeout or a none numeric char is received, the none numeric char will be lost. 
- BYTE Timeout
Max time in ms to wait in between bytes 
- BOOL IgnoreData
0=Dont ignore any data, 1=Ignore any initial none numeric data 
- LONG Return


ReceiveString

ReceiveString
Attempts to receive a string using the COM port. MaxLength sets the maximum number of bytes that can be received, Timeout is the max time between characters.  
- UINT Timeout
Time to wait for incoming data in milliseconds 
- UINT MaxLength
Max number of bytes to try and read 
- STRING Return


ReceiveStringWithTermination

ReceiveStringWithTermination
Attempts to receive an string using the COM port. Will return if the selected termination characters are received. Returns the number of bytes received.  
- UINT Timeout
Time to wait for incoming data in milliseconds 
- UINT MaxLength
Max number of bytes to try and read 
- STRING Termination
String to check for to terminate the receive. 
- BYTE TerminationLength
 
- STRING Return


ScanForDeviceID

ScanForDeviceID
Checks to see if a device VID/PID string is present and returns the COM port number. Returns 0 if device not found. 
- STRING HWID
Example: "VID_12BF&PID_0101" 
- BYTE Return


ScanForDeviceIDEx

ScanForDeviceIDEx
Checks to see if a device VID/PID string is present and returns the COM port number, allows multiple devices with the same details to be detected. Returns 0 if device not found. 
- STRING HWID
Example: "VID_12BF&PID_0101" 
- BYTE SkipCount
0=Returns first match, 1=Returns second match etc. 
- BOOL ScanForDevId
0=Scan PID/VID / 1=Scan DeviceID 
- BYTE Return


SendBinary16Bit

SendBinary16Bit
Sends out a 16-bit binary value split across two bytes. 
- UINT Value
 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


SendBinary32Bit

SendBinary32Bit
Sends out a 32-bit binary value split across four bytes. 
- ULONG Value
 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


SendBinaryFloat

SendBinaryFloat
Sends out a 32-bit binary floating point value split across four bytes. 
- FLOAT Value
 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


SendByte

SendByte
Sends a single byte to be sent out via the COM port. 
- BYTE Data
 
- VOID Return


SendByteArray

SendByteArray
Sends an array of bytes to the COM port. 
- BYTE Data
Data byte array to send 
- UINT Length
Number of bytes to send 
- VOID Return


SendFloat

SendFloat
Sends out a floating point number as an ASCII String from the UART interface. 
- FLOAT Number
 
- VOID Return


SendHexNumber

SendHexNumber
Sends out a number as an ASCII hexadecimal String from the UART interface. 
- ULONG Number
 
- BYTE NumChars
Number of characters in the string data, 0 for auto, 2 for 0x00, 4 for 0x0000 
- BOOL Prefix
Generate hexadecimal prefix 0x e.g. 1= 0xFF, 0= FF 
- VOID Return


SendINTArray

SendINTArray
Transmits an array of 16-bit INT/UINT values via the UART peripheral 
- UINT Data
Data to transmit 
- UINT NumValues
Number of 16-bit values to send from the array 
- BOOL MSBfirst
0=Least significant byte first, 1=Most significant byte first 
- VOID Return


SendNumber

SendNumber
Sends out a number as an ASCII String from the UART interface. 
- LONG Number
 
- VOID Return


SendString

SendString
Sends an string of characters to the COM port. 
- STRING Data
Data byte array to send 
- VOID Return


SetDTRState

SetDTRState
Allows the DTR signal to be enabled or disabled. 
- BYTE State
A value of 0 disables the DTR, 1 or above willl enable the DTR. 
- VOID Return


SetFlowControl

SetFlowControl
Allows the Flowcontrol signals to be enabled or disabled. 
- BYTE State
A value of 0 disables flow control, 1 or above willl enable flow control. 
- VOID Return


SetProp

SetProp
Allows the COM port property to be set from a parent component. 
- STRING PropName
 
- ULONG PropVal
 
- VOID Return


Property reference

Properties
COM Port
Selects which port to communicate with, only lists ports which are currently available.  
Refresh COM Ports
When set to yes the COM port list is rescanned for newly connected or available ports. Note that refreshing the ports list may take a few seconds depending on the number of connected ports. 
Baud
Baud rate passed to the COM port to control the rate of data. 
Timeout Value
Value to specify what is returned when no incoming receive data is present. 
Console Data
 
Auto Close
Auto close the port on Sim stop event 
New Line Format
 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_COM_Port_1.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_COM_Port_1.fcfx