Difference between revisions of "Component: COM Port (Runtime Tools)"
From Flowcode Help
Jump to navigationJump to searchLine 5: | Line 5: | ||
|- | |- | ||
| width="20%" style="color:gray;" | Version | | width="20%" style="color:gray;" | Version | ||
− | | | + | | 103.11 |
|- | |- | ||
| width="20%" style="color:gray;" | Category | | width="20%" style="color:gray;" | Category | ||
Line 15: | Line 15: | ||
Serial based simulation component for use with systems such as RS232, Bluetooth and USB Serial. | Serial based simulation component for use with systems such as RS232, Bluetooth and USB Serial. | ||
− | == | + | ==Version information== |
− | + | Library Version, Component Version, Date, Author, Info | |
+ | 11, 103.11, 01-05-25, BR, Changed SendString macro to make it more efficient | ||
+ | |||
− | |||
==Detailed description== | ==Detailed description== | ||
Line 373: | Line 374: | ||
| colspan="2" | Array to store the incoming data | | colspan="2" | Array to store the incoming data | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
| width="90%" | NumValues | | width="90%" | NumValues | ||
|- | |- | ||
Line 388: | Line 389: | ||
| colspan="2" | Max amount of time in ms to wait between bytes | | colspan="2" | Max amount of time in ms to wait between bytes | ||
|- | |- | ||
− | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9- | + | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT |
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
Line 423: | Line 424: | ||
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveString''' | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveString''' | ||
|- | |- | ||
− | | colspan="2" | Attempts to receive an string using the COM port Returns the number of bytes received. | + | | colspan="2" | 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. |
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Time to wait for incoming data in milliseconds | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | MaxLength | ||
+ | |- | ||
+ | | colspan="2" | Max number of bytes to try and read | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===ReceiveStringWithTermination=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReceiveStringWithTermination''' | ||
+ | |- | ||
+ | | colspan="2" | Attempts to receive an string using the COM port. Will return if the selected termination characters are received. Returns the number of bytes received. | ||
|- | |- | ||
|- | |- | ||
Line 435: | Line 460: | ||
|- | |- | ||
| colspan="2" | Max number of bytes to try and read | | colspan="2" | Max number of bytes to try and read | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Termination | ||
+ | |- | ||
+ | | colspan="2" | String to check for to terminate the receive. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | TerminationLength | ||
+ | |- | ||
+ | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING | ||
Line 454: | Line 489: | ||
|- | |- | ||
| colspan="2" | Example: "VID_12BF&PID_0101" | | colspan="2" | Example: "VID_12BF&PID_0101" | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | ===ScanForDeviceIDEx=== | ||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ScanForDeviceIDEx''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | HWID | ||
+ | |- | ||
+ | | colspan="2" | Example: "VID_12BF&PID_0101" | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | SkipCount | ||
+ | |- | ||
+ | | colspan="2" | 0=Returns first match, 1=Returns second match etc. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | ScanForDevId | ||
+ | |- | ||
+ | | colspan="2" | 0=Scan PID/VID / 1=Scan DeviceID | ||
|- | |- | ||
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
Line 637: | Line 701: | ||
| colspan="2" | Data to transmit | | colspan="2" | Data to transmit | ||
|- | |- | ||
− | | width="10%" align="center" | [[File:Fc9- | + | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT |
| width="90%" | NumValues | | width="90%" | NumValues | ||
|- | |- | ||
Line 795: | Line 859: | ||
| colspan="2" | | | colspan="2" | | ||
|} | |} | ||
+ | |||
+ | ==Component Source Code== | ||
+ | |||
+ | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_COM_Port.fcfx FC_Comp_Source_COM_Port.fcfx] | ||
+ | |||
+ | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_COM_Port.fcfx FC_Comp_Source_COM_Port.fcfx] |
Latest revision as of 08:58, 9 June 2025
Author | Matrix Ltd |
Version | 103.11 |
Category | Runtime Tools |
Contents
- 1 COM Port component
- 2 Version information
- 3 Detailed description
- 4 Examples
- 5 Macro reference
- 5.1 ClosePort
- 5.2 ConfigureConsole
- 5.3 GetConsoleHandle
- 5.4 GetProp
- 5.5 OpenPort
- 5.6 ReceiveBinary16Bit
- 5.7 ReceiveBinary32Bit
- 5.8 ReceiveBinaryFloat
- 5.9 ReceiveByte
- 5.10 ReceiveByteArray
- 5.11 ReceiveFloat
- 5.12 ReceiveHexNumber
- 5.13 ReceiveINTArray
- 5.14 ReceiveNumber
- 5.15 ReceiveString
- 5.16 ReceiveStringWithTermination
- 5.17 ScanForDeviceID
- 5.18 ScanForDeviceIDEx
- 5.19 SendBinary16Bit
- 5.20 SendBinary32Bit
- 5.21 SendBinaryFloat
- 5.22 SendByte
- 5.23 SendByteArray
- 5.24 SendFloat
- 5.25 SendHexNumber
- 5.26 SendINTArray
- 5.27 SendNumber
- 5.28 SendString
- 5.29 SetDTRState
- 5.30 SetFlowControl
- 5.31 SetProp
- 6 Property reference
- 7 Component Source Code
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 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
Auto Detect Port Number
This example auto detects and opens a COM Port based on preassigned USB Identifiers VID/PID.
For a known device the VID and PID can be found via Windows device manager.
Macro reference
ClosePort
![]() |
ClosePort |
Closes the currently open COM port, ending communications and allowing it to be accessed via another application. | |
![]() |
Return |
ConfigureConsole
![]() |
ConfigureConsole |
![]() |
Status |
![]() |
Return |
GetConsoleHandle
![]() |
GetConsoleHandle |
Gets the handle to the console allowing data displaying on the panel etc. | |
![]() |
Return |
GetProp
![]() |
GetProp |
Allows the property filter for the COM port list to be copied to a parent component. | |
![]() |
PropName |
![]() |
Return |
OpenPort
![]() |
OpenPort |
Opens the currently selected COM port, allowing data to be sent and received. | |
![]() |
Return |
ReceiveBinary16Bit
ReceiveBinary32Bit
ReceiveBinaryFloat
ReceiveByte
![]() |
ReceiveByte |
Attempts to receive a byte using the COM port No valid return data is provided by the timeout value property. | |
![]() |
Timeout |
Time to wait for incoming data in milliseconds | |
![]() |
Return |
ReceiveByteArray
ReceiveFloat
ReceiveHexNumber
ReceiveINTArray
ReceiveNumber
ReceiveString
ReceiveStringWithTermination
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. | |
![]() |
HWID |
Example: "VID_12BF&PID_0101" | |
![]() |
Return |
ScanForDeviceIDEx
SendBinary16Bit
![]() |
SendBinary16Bit |
Sends out a 16-bit binary value split across two bytes. | |
![]() |
Value |
![]() |
MSBfirst |
0=Least significant byte first, 1=Most significant byte first | |
![]() |
Return |
SendBinary32Bit
![]() |
SendBinary32Bit |
Sends out a 32-bit binary value split across four bytes. | |
![]() |
Value |
![]() |
MSBfirst |
0=Least significant byte first, 1=Most significant byte first | |
![]() |
Return |
SendBinaryFloat
![]() |
SendBinaryFloat |
Sends out a 32-bit binary floating point value split across four bytes. | |
![]() |
Value |
![]() |
MSBfirst |
0=Least significant byte first, 1=Most significant byte first | |
![]() |
Return |
SendByte
![]() |
SendByte |
Sends a single byte to be sent out via the COM port. | |
![]() |
Data |
![]() |
Return |
SendByteArray
![]() |
SendByteArray |
Sends an array of bytes to the COM port. | |
![]() |
Data |
Data byte array to send | |
![]() |
Length |
Number of bytes to send | |
![]() |
Return |
SendFloat
![]() |
SendFloat |
Sends out a floating point number as an ASCII String from the UART interface. | |
![]() |
Number |
![]() |
Return |
SendHexNumber
SendINTArray
SendNumber
![]() |
SendNumber |
Sends out a number as an ASCII String from the UART interface. | |
![]() |
Number |
![]() |
Return |
SendString
![]() |
SendString |
Sends an string of characters to the COM port. | |
![]() |
Data |
Data byte array to send | |
![]() |
Return |
SetDTRState
![]() |
SetDTRState |
Allows the DTR signal to be enabled or disabled. | |
![]() |
State |
A value of 0 disables the DTR, 1 or above willl enable the DTR. | |
![]() |
Return |
SetFlowControl
![]() |
SetFlowControl |
Allows the Flowcontrol signals to be enabled or disabled. | |
![]() |
State |
A value of 0 disables flow control, 1 or above willl enable flow control. | |
![]() |
Return |
SetProp
![]() |
SetProp |
Allows the COM port property to be set from a parent component. | |
![]() |
PropName |
![]() |
PropVal |
![]() |
Return |
Property reference
Component Source Code
Please click here to download the component source project: FC_Comp_Source_COM_Port.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_COM_Port.fcfx