Difference between revisions of "Component: COM Port (Runtime Tools)"
From Flowcode Help
Jump to navigationJump to searchLine 17: | Line 17: | ||
==Component Source Code== | ==Component Source Code== | ||
− | Please click here | + | 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] |
==Detailed description== | ==Detailed description== | ||
+ | |||
+ | |||
Line 42: | Line 44: | ||
==Examples== | ==Examples== | ||
+ | |||
+ | |||
Line 73: | Line 77: | ||
==Macro reference== | ==Macro reference== | ||
+ | |||
+ | {| 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;" | '''ReceiveByte''' | ||
+ | |- | ||
+ | | colspan="2" | Attempts to receive a byte using the COM port No valid return data is provided by the timeout value property. | ||
+ | |- | ||
+ | |- | ||
+ | | 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" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ConfigureConsole''' | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Status | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendString''' | ||
+ | |- | ||
+ | | colspan="2" | Sends an string of characters to the COM port. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data byte array to send | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveINTArray''' | ||
+ | |- | ||
+ | | colspan="2" | Receives an array of 16-bit INT/UINT values and returns the number of values received. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Array to store the incoming data | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumValues | ||
+ | |- | ||
+ | | colspan="2" | Maximum number of values to try and receive | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Max amount of time in ms to wait between bytes | ||
+ | |- | ||
+ | | 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'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveNumber''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Max time in ms to wait in between bytes | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | IgnoreData | ||
+ | |- | ||
+ | | colspan="2" | 0=Dont ignore any data, 1=Ignore any initial none numeric data | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s32-icon.png]] - LONG | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendBinary16Bit''' | ||
+ | |- | ||
+ | | colspan="2" | Sends out a 16-bit binary value split across two bytes. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Value | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendINTArray''' | ||
+ | |- | ||
+ | | colspan="2" | Transmits an array of 16-bit INT/UINT values via the UART peripheral | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data to transmit | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumValues | ||
+ | |- | ||
+ | | colspan="2" | Number of 16-bit values to send from the array | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendNumber''' | ||
+ | |- | ||
+ | | colspan="2" | Sends out a number as an ASCII String from the UART interface. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-s32-icon.png]] - LONG | ||
+ | | width="90%" | Number | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveBinary32Bit''' | ||
+ | |- | ||
+ | | colspan="2" | Receives a binary 32-bit value split across four bytes. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Max amount of time in ms to wait between bytes | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ClosePort''' | ||
+ | |- | ||
+ | | colspan="2" | Closes the currently open COM port, ending communications and allowing it to be accessed via another application. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveBinaryFloat''' | ||
+ | |- | ||
+ | | colspan="2" | Receives a binary 32-bit floating point value split across four bytes. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Max amount of time in ms to wait between bytes | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendByte''' | ||
+ | |- | ||
+ | | colspan="2" | Sends a single byte to be sent out via the COM port. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SetDTRState''' | ||
+ | |- | ||
+ | | colspan="2" | Allows the DTR signal to be enabled or disabled. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | State | ||
+ | |- | ||
+ | | colspan="2" | A value of 0 disables the DTR, 1 or above willl enable the DTR. | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ScanForDeviceID''' | ||
+ | |- | ||
+ | | colspan="2" | Checks to see if a device VID/PID string is present and returns the COM port number. 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" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''GetConsoleHandle''' | ||
+ | |- | ||
+ | | colspan="2" | Gets the handle to the console allowing data displaying on the panel etc. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-h32-icon.png]] - HANDLE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendByteArray''' | ||
+ | |- | ||
+ | | colspan="2" | Sends an array of bytes to the COM port. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Data byte array to send | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Length | ||
+ | |- | ||
+ | | colspan="2" | Number of bytes to send | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveBinary16Bit''' | ||
+ | |- | ||
+ | | colspan="2" | Receives a binary 16-bit value split across two bytes. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Max amount of time in ms to wait between bytes | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveFloat''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Max time in ms to wait in between bytes | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | IgnoreData | ||
+ | |- | ||
+ | | colspan="2" | 0=Dont ignore any data, 1=Ignore any initial none numeric data | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendFloat''' | ||
+ | |- | ||
+ | | colspan="2" | Sends out a floating point number as an ASCII String from the UART interface. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" | Number | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendHexNumber''' | ||
+ | |- | ||
+ | | colspan="2" | Sends out a number as an ASCII hexadecimal String from the UART interface. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" | Number | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumChars | ||
+ | |- | ||
+ | | colspan="2" | Number of characters in the string data, 0 for auto, 2 for 0x00, 4 for 0x0000 | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | Prefix | ||
+ | |- | ||
+ | | colspan="2" | Generate hexadecimal prefix 0x e.g. 1= 0xFF, 0= FF | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SetFlowControl''' | ||
+ | |- | ||
+ | | colspan="2" | Allows the Flowcontrol signals to be enabled or disabled. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | State | ||
+ | |- | ||
+ | | colspan="2" | A value of 0 disables flow control, 1 or above willl enable flow control. | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''OpenPort''' | ||
+ | |- | ||
+ | | colspan="2" | Opens the currently selected COM port, allowing data to be sent and received. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveHexNumber''' | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Max time in ms to wait in between bytes | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | IgnoreData | ||
+ | |- | ||
+ | | colspan="2" | 0=Dont ignore any data, 1=Ignore any initial none numeric data | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | Prefix | ||
+ | |- | ||
+ | | colspan="2" | Look for prefix before receiving, 1=0xFF, 0=FF | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SetProp''' | ||
+ | |- | ||
+ | | colspan="2" | Allows the COM port property to be set from a parent component. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | PropName | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" | PropVal | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendBinary32Bit''' | ||
+ | |- | ||
+ | | colspan="2" | Sends out a 32-bit binary value split across four bytes. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG | ||
+ | | width="90%" | Value | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''SendBinaryFloat''' | ||
+ | |- | ||
+ | | colspan="2" | Sends out a 32-bit binary floating point value split across four bytes. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT | ||
+ | | width="90%" | Value | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL | ||
+ | | width="90%" | MSBfirst | ||
+ | |- | ||
+ | | colspan="2" | 0=Least significant byte first, 1=Most significant byte first | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''GetProp''' | ||
+ | |- | ||
+ | | colspan="2" | Allows the property filter for the COM port list to be copied to a parent component. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | PropName | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | 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'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveByteArray''' | ||
+ | |- | ||
+ | | colspan="2" | Attempts to receive an array of bytes using the COM port Returns the number of bytes received. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | 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" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | Timeout | ||
+ | |- | ||
+ | | colspan="2" | Time to wait for incoming data in milliseconds | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| 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;" | '''ReceiveString''' | ||
+ | |- | ||
+ | | colspan="2" | Attempts to receive an string using the COM port Returns the number of bytes received. | ||
+ | |- | ||
+ | |- | ||
+ | | 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'' | ||
+ | |} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Property reference== | ||
+ | |||
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties''' | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | COM Port | ||
+ | |- | ||
+ | | colspan="2" | Selects which port to communicate with, only lists ports which are currently available. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
+ | | width="90%" | Refresh COM Ports | ||
+ | |- | ||
+ | | colspan="2" | 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. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-14-icon.png]] | ||
+ | | width="90%" | Baud | ||
+ | |- | ||
+ | | colspan="2" | Baud rate passed to the COM port to control the rate of data. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-14-icon.png]] | ||
+ | | width="90%" | Timeout Value | ||
+ | |- | ||
+ | | colspan="2" | Value to specify what is returned when no incoming receive data is present. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
+ | | width="90%" | Console Data | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
+ | | width="90%" | Auto Close | ||
+ | |- | ||
+ | | colspan="2" | Auto close the port on Sim stop event | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | New Line Format | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |}==Macro reference== | ||
{| class="wikitable" style="width:60%; background-color:#FFFFFF;" | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" |
Revision as of 15:13, 20 January 2023
Author | Matrix Ltd |
Version | 3.0 |
Category | Runtime Tools |
Contents
COM Port component
Serial based simulation component for use with systems such as RS232, Bluetooth and USB Serial.
Component Source Code
Please click here to view the component source code (Beta): FC_Comp_Source_COM_Port.fcfx
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
![]() |
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 |
![]() |
ConfigureConsole |
![]() |
Status |
![]() |
Return |
![]() |
SendString |
Sends an string of characters to the COM port. | |
![]() |
Data |
Data byte array to send | |
![]() |
Return |
![]() |
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 |
![]() |
SendNumber |
Sends out a number as an ASCII String from the UART interface. | |
![]() |
Number |
![]() |
Return |
![]() |
ClosePort |
Closes the currently open COM port, ending communications and allowing it to be accessed via another application. | |
![]() |
Return |
![]() |
SendByte |
Sends a single byte to be sent out via the COM port. | |
![]() |
Data |
![]() |
Return |
![]() |
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 |
![]() |
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 |
![]() |
GetConsoleHandle |
Gets the handle to the console allowing data displaying on the panel etc. | |
![]() |
Return |
![]() |
SendByteArray |
Sends an array of bytes to the COM port. | |
![]() |
Data |
Data byte array to send | |
![]() |
Length |
Number of bytes to send | |
![]() |
Return |
![]() |
SendFloat |
Sends out a floating point number as an ASCII String from the UART interface. | |
![]() |
Number |
![]() |
Return |
![]() |
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 |
![]() |
OpenPort |
Opens the currently selected COM port, allowing data to be sent and received. | |
![]() |
Return |
![]() |
SetProp |
Allows the COM port property to be set from a parent component. | |
![]() |
PropName |
![]() |
PropVal |
![]() |
Return |
![]() |
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 |
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 |
![]() |
GetProp |
Allows the property filter for the COM port list to be copied to a parent component. | |
![]() |
PropName |
![]() |
Return |
Property reference
==Macro reference==
![]() |
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 |
![]() |
ConfigureConsole |
![]() |
Status |
![]() |
Return |
![]() |
SendString |
Sends an string of characters to the COM port. | |
![]() |
Data |
Data byte array to send | |
![]() |
Return |
![]() |
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 |
![]() |
SendNumber |
Sends out a number as an ASCII String from the UART interface. | |
![]() |
Number |
![]() |
Return |
![]() |
ClosePort |
Closes the currently open COM port, ending communications and allowing it to be accessed via another application. | |
![]() |
Return |
![]() |
SendByte |
Sends a single byte to be sent out via the COM port. | |
![]() |
Data |
![]() |
Return |
![]() |
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 |
![]() |
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 |
![]() |
GetConsoleHandle |
Gets the handle to the console allowing data displaying on the panel etc. | |
![]() |
Return |
![]() |
SendByteArray |
Sends an array of bytes to the COM port. | |
![]() |
Data |
Data byte array to send | |
![]() |
Length |
Number of bytes to send | |
![]() |
Return |
![]() |
SendFloat |
Sends out a floating point number as an ASCII String from the UART interface. | |
![]() |
Number |
![]() |
Return |
![]() |
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 |
![]() |
OpenPort |
Opens the currently selected COM port, allowing data to be sent and received. | |
![]() |
Return |
![]() |
SetProp |
Allows the COM port property to be set from a parent component. | |
![]() |
PropName |
![]() |
PropVal |
![]() |
Return |
![]() |
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 |
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 |
![]() |
GetProp |
Allows the property filter for the COM port list to be copied to a parent component. | |
![]() |
PropName |
![]() |
Return |