Difference between revisions of "Component: Network Communications (Comms: Networking)"

From Flowcode Help
Jump to navigationJump to search
Line 1: Line 1:
 
+
{| style="width:50%"
 
 
{| width="50%"
 
 
|-
 
|-
| width="20%" style="color: gray;" | Author
+
| width="20%" style="color:gray;" | Author
 
| Matrix TSL
 
| Matrix TSL
 
|-
 
|-
| width="20%" style="color: gray;" | Version
+
| width="20%" style="color:gray;" | Version
| 1.0 (Release)
+
| 1.5
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| Comms: Networking
 
| Comms: Networking
 
|}
 
|}
  
  
 +
==Network Communications component==
 +
A component designed to simplify the process of TCP/IP communications. Compatible with most of the Flowcode supported TCP/IP and WIFI components. A useful building block for creating components such as IoT and Modbus TCP.
 +
 +
==Detailed description==
  
==[[File:Component Icon 91049bf5_2436_42dc_947a_c30c86463d98.png|Image]] Network Communications component==
+
''No detailed description exists yet for this component''
A component designed to simplify the process of TCP/IP communications.
 
Compatible with most of the Flowcode supported TCP/IP and WIFI components.
 
A useful building block for creating components such as IoT and Modbus TCP.
 
  
 
==Examples==
 
==Examples==
 +
 +
  
  
Line 91: Line 92:
 
==Downloadable macro reference==
 
==Downloadable macro reference==
  
===<span style="font-weight: normal;"><u><tt>Connect</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Connects to an IP address as a client on the specified port.
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connect'''
 +
|-
 +
| colspan="2" | Connects to an IP address as a client on the specified port. Some TCP/IP modules (RPI and ESP8266) will accept a URL instead of an IP address. Returns: 0=Fail, 1=OK&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 +
| width="90%" | Address
 +
|-
 +
| colspan="2" | IP address as a string e.g. "192.168.1.1" or URL on some TCP/IP modules&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Port
 +
|-
 +
| colspan="2" | Port number to connect to.&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
Some TCP/IP modules (RPI and ESP8266) will accept a URL instead of an IP address.
 
  
Returns: 0=Fail, 1=OK
+
{| 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;" | '''Receive'''
 +
|-
 +
| colspan="2" | Attempts to receive up to a specified number of bytes from the active connection. Returns the number of bytes received.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 +
| width="90%" | Data
 +
|-
 +
| colspan="2" | Data Array to store the data into.&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Count
 +
|-
 +
| colspan="2" | Maximum number of bytes to read&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Timeout
 +
|-
 +
| colspan="2" | Maximum time to wait in mS (approx)&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|<- STRING]] ''Address''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::IP address as a string e.g. "192.168.1.1" or URL on some TCP/IP modules
+
|-
::''This parameter may be returned back to the caller''
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Send'''
 +
|-
 +
| colspan="2" | Sends the specified number of bytes via the active connection. Returns the number of bytes sent, 0=Fail.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
 +
| width="90%" | Data
 +
|-
 +
| colspan="2" | Array containing the data to send&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Count
 +
|-
 +
| colspan="2" | Number of bytes to send from the data array&nbsp;
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|UINT]] ''Port''
 
  
 +
{| 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;" | '''Listen'''
 +
|-
 +
| colspan="2" | Bind the socket to a port on the local host and set to listen mode. First Open a Socket on the local host Returns: 0=Fail, 1=OK&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Port
 +
|-
 +
| colspan="2" | Port number to listen on.&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
'''Return value'''
 
  
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
+
{| 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;" | '''SocketOpen'''
 +
|-
 +
| colspan="2" | Attempts to create a socket on the local device. This must be succesful to allow TCP/IP communications with a remote destination. Returns: 0=Fail / 1=OK&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>Receive</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Attempts to receive up to a specified number of bytes from the active connection.
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SocketClose'''
 +
|-
 +
| colspan="2" | Closes the current socket connection&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
Returns the number of bytes received.
 
  
'''Parameters'''
+
{| 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;" | '''AcceptOpen'''
 +
|-
 +
| colspan="2" | Required for systems where there can be multiple incoming threads Returns 1 if there is incoming comms requiring a new thread, else returns 0&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|<- STRING]] ''Data''
 
::''This parameter may be returned back to the caller''
 
  
:[[Variable Types|UINT]] ''Count''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Maximum number of bytes to read
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AcceptClose'''
 +
|-
 +
| colspan="2" | Goes with the AcceptOpen function to close the new thread handle.&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
  
'''Return value'''
+
{| 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;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Initialises the network communications component.&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|UINT]]
 
  
 +
{| 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;" | '''ReadDigitalInputs'''
 +
|-
 +
| colspan="2" | Reads the state of a single digital input. Can pack a max of 8-bits together in a single operation&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | StartAddress
 +
|-
 +
| colspan="2" | Coil Address Range 0 to (NumCoils - 1)&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | AddressCount
 +
|-
 +
| colspan="2" | Range 1-8&nbsp;
 +
|-
 +
| 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''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>Send</tt></u></span>===
 
Sends the specified number of bytes via the active connection.
 
  
Returns the number of bytes sent, 0=Fail.
+
{| 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;" | '''SetAnalogInput'''
 +
|-
 +
| colspan="2" | Sets the state of a single analogue input.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Address
 +
|-
 +
| colspan="2" | Coil Address&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Value
 +
|-
 +
| colspan="2" | Analogue Value range 0 - 65535&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|<- STRING]] ''Data''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Array containing the data to send
+
|-
::''This parameter may be returned back to the caller''
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Starts up the UART to allow communications and initialises the states of the various  Modbus Coils, Inputs and Registers to 0. Returns 1 if USB is started ok.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:]] -
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|UINT]] ''Count''
 
::Number of bytes to send from the data array
 
  
 +
{| 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;" | '''SetAnalogInput'''
 +
|-
 +
| colspan="2" | Sets the state of a single analogue input.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Address
 +
|-
 +
| colspan="2" | Coil Address&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Value
 +
|-
 +
| colspan="2" | Analogue Value range 0 - 65535&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Return value'''
 
  
:[[Variable Types|UINT]]
+
{| 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;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Starts up the UART to allow communications and initialises the states of the various  Modbus Coils, Inputs and Registers to 0.&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>Listen</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Bind the socket to a port on the local host and set to listen mode.
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Initialises the MIDI component and sets up the UART.&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
Returns: 0=Fail, 1=OK
 
  
'''Parameters'''
+
{| 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;" | '''CommsBaud'''
 +
|-
 +
| colspan="2" | Sets the Baud rate of the alt communications channel&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Baud
 +
|-
 +
| colspan="2" | Range: 0-7 : 0=1200 / 7=115200&nbsp;
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|UINT]] ''Port''
 
  
 +
{| 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;" | '''LCDOptions'''
 +
|-
 +
| colspan="2" | Controls some of the LCD options&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Foreground
 +
|-
 +
| colspan="2" | Range: 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Background
 +
|-
 +
| colspan="2" | Range: 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Transparent
 +
|-
 +
| colspan="2" | Range: 0-1&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Return value'''
 
  
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
+
{| 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;" | '''LCDVerbose'''
 +
|-
 +
| colspan="2" | Controls the Verbose mode.  When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Mode
 +
|-
 +
| colspan="2" | Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode&nbsp;
 +
|-
 +
| 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''
 +
|}
  
  
===<span style="font-weight: normal;"><u><tt>SocketOpen</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Attempts to create a socket on the local device.
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadDigitalInput'''
 +
|-
 +
| colspan="2" | Reads a single digital input.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Channel
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| 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''
 +
|}
  
This must be succesful to allow TCP/IP communications with a remote destination.
 
  
Returns: 0=Fail / 1=OK
+
{| 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;" | '''PWMConfig'''
 +
|-
 +
| colspan="2" | Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 :  0=1:1 1=1:8 2=1:64 3=1:256&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Channel
 +
|-
 +
| colspan="2" | Range 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Period
 +
|-
 +
| colspan="2" | Range: 0-65535&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Scaler
 +
|-
 +
| colspan="2" | Range: 0-3&nbsp;
 +
|-
 +
| 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''
 +
|}
  
'''Parameters'''
 
  
:''This macro has no parameters''
+
{| 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;" | '''PWMEnable'''
 +
|-
 +
| colspan="2" | Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | EnableMask
 +
|-
 +
| colspan="2" | Range 0-63 or 0b00000 to 0b111111&nbsp;
 +
|-
 +
| 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''
 +
|}
  
  
'''Return value'''
+
{| 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;" | '''PWMDuty'''
 +
|-
 +
| colspan="2" | Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Channel
 +
|-
 +
| colspan="2" | Range 0-5&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Duty
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| 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''
 +
|}
  
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
 
  
 +
{| 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;" | '''LCDCursor'''
 +
|-
 +
| colspan="2" | Sets the cursor position for the MIAC display&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | X
 +
|-
 +
| colspan="2" | Range: 0-21&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Y
 +
|-
 +
| colspan="2" | Range: 0-4&nbsp;
 +
|-
 +
| 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''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>SocketClose</tt></u></span>===
 
Closes the current socket connection
 
  
'''Parameters'''
+
{| 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;" | '''WriteTran'''
 +
|-
 +
| colspan="2" | Allows a single transistor output to be switched on or off.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Channel
 +
|-
 +
| colspan="2" | Range 1-4&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Value
 +
|-
 +
| colspan="2" | 0 = Off, 1 = On&nbsp;
 +
|-
 +
| 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''
 +
|}
  
:''This macro has no parameters''
 
  
 +
{| 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;" | '''Initialise'''
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
'''Return value'''
 
  
:''This call does not return a value''
+
{| 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;" | '''LCDClear'''
 +
|-
 +
| colspan="2" | Clears the MIAC display&nbsp;
 +
|-
 +
|-
 +
| 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''
 +
|}
  
  
 
==Simulation macro reference==
 
 
''This component does not contain any simulation macros''
 
  
  
 
==Property reference==
 
==Property reference==
<span style="font-weight: normal;"><u>TCP/IP Component</u></span>
 
  
This property is of type ''Panel object'' and can be referenced with the variable name ''Component''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
Property to point to the TCP/IP or WIFI component you want to use.
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
If unconnected then default to simulated TCP/IP network communications using the PC network adapter.
+
|-
 
+
|-
<span style="font-weight: normal;"><u>Status</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-17-icon.png]]
 
+
| width="90%" | TCP/IP Component
This property is of type ''Line of text'' and can be referenced with the variable name ''Status''.
+
|-
 
+
| colspan="2" | Property to point to the TCP/IP or WIFI component you want to use. If unconnected then default to simulated TCP/IP network communications using the PC network adapter.&nbsp;
Informs the user of the current status of support for the connected component.
+
|-
 +
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 +
| width="90%" | Status
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''  
 +
|-
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Simulation Control
 +
|-
 +
| colspan="2" | Allows the user to decide what happens when simulating. Simulation DLL forces all simulated TCP/IP comms to go directly via the simulation DLL bypassing any additional components. Component simulation forces the attached component to provide the simulation and maybe other aspects such as SPI/I2C communications.&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Network Interface
 +
|-
 +
| colspan="2" | Some computers may have several network interfaces such as ethernet ports and wifi access. Select the correct network interface for the network you wish to connect to. Use the IP address to confirm you are connected to the right network.&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 +
| width="90%" | IP Address
 +
|-
 +
| colspan="2" | IP Address of the selected network interface.&nbsp;
 +
|}

Revision as of 20:35, 16 November 2021

Author Matrix TSL
Version 1.5
Category Comms: Networking


Network Communications component

A component designed to simplify the process of TCP/IP communications. Compatible with most of the Flowcode supported TCP/IP and WIFI components. A useful building block for creating components such as IoT and Modbus TCP.

Detailed description

No detailed description exists yet for this component

Examples

Here are some examples showing the Network Communications component in action.

By itself the component provides a generic TCP/IP layer to drive the simulation runtime.

Here is a simple example showing the component used by itself to request data from a remote server on the internet.

FC6 Icon.png Example Network Comms Client


Library Components

Components such as Webserver (GENERIC), MQTT and Modbus TCP can connect to and control the network comms layer.

NetComms1.jpg


Here is a simple example showing the component used with the Webserver (GENERIC) component.

FC6 Icon.png Example Network Comms Web Server

Embedded Components

The Network Communications component can also be connected to embedded TCP/IP and WIFI style modules allowing for the abstraction to work with specific networking hardware modules.

NetComms2.jpg


Here is the current status of the Network Communications component with the various embedded modules.

Embedded Component Other Variants of Component Support Status
TCP/IP (Raspberry Pi) N/A Fully Supported
WLAN (ESP8266) WLAN (ESP-12S), WIFI (BL0136), WIFI (ESP8266) Fully Supported
TCP/IP (W5500) N/A Fully Supported
ENC28J60 N/A On Hold
TCP/IP (NM7010A) TCP/IP (EB023v1) On Hold
TCP/IP (W5100) TCP/IP (EB023v2), TCP/IP (WIZ810MJ) On Hold
WLAN (WIZ610WI) WIFI (EB069) On Hold


We are working through and adding support as and when we get chance so if you have a module that isn't listed or would like to try and prioritise a specific module then you can let us know via the user forums.

Downloadable macro reference

Fc9-comp-macro.png Connect
Connects to an IP address as a client on the specified port. Some TCP/IP modules (RPI and ESP8266) will accept a URL instead of an IP address. Returns: 0=Fail, 1=OK 
Fc9-string-icon.png - STRING Address
IP address as a string e.g. "192.168.1.1" or URL on some TCP/IP modules 
Fc9-u16-icon.png - UINT Port
Port number to connect to. 
[[File:]] - Return


Fc9-comp-macro.png Receive
Attempts to receive up to a specified number of bytes from the active connection. Returns the number of bytes received. 
Fc9-string-icon.png - STRING Data
Data Array to store the data into. 
Fc9-u16-icon.png - UINT Count
Maximum number of bytes to read 
Fc9-u16-icon.png - UINT Timeout
Maximum time to wait in mS (approx) 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png Send
Sends the specified number of bytes via the active connection. Returns the number of bytes sent, 0=Fail. 
Fc9-string-icon.png - STRING Data
Array containing the data to send 
Fc9-u16-icon.png - UINT Count
Number of bytes to send from the data array 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png Listen
Bind the socket to a port on the local host and set to listen mode. First Open a Socket on the local host Returns: 0=Fail, 1=OK 
Fc9-u16-icon.png - UINT Port
Port number to listen on. 
[[File:]] - Return


Fc9-comp-macro.png SocketOpen
Attempts to create a socket on the local device. This must be succesful to allow TCP/IP communications with a remote destination. Returns: 0=Fail / 1=OK 
[[File:]] - Return


Fc9-comp-macro.png SocketClose
Closes the current socket connection 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png AcceptOpen
Required for systems where there can be multiple incoming threads Returns 1 if there is incoming comms requiring a new thread, else returns 0 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png AcceptClose
Goes with the AcceptOpen function to close the new thread handle. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Initialises the network communications component. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReadDigitalInputs
Reads the state of a single digital input. Can pack a max of 8-bits together in a single operation 
Fc9-u16-icon.png - UINT StartAddress
Coil Address Range 0 to (NumCoils - 1) 
Fc9-u8-icon.png - BYTE AddressCount
Range 1-8 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png SetAnalogInput
Sets the state of a single analogue input. 
Fc9-u16-icon.png - UINT Address
Coil Address 
Fc9-u16-icon.png - UINT Value
Analogue Value range 0 - 65535 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0. Returns 1 if USB is started ok. 
[[File:]] - Return


Fc9-comp-macro.png SetAnalogInput
Sets the state of a single analogue input. 
Fc9-u16-icon.png - UINT Address
Coil Address 
Fc9-u16-icon.png - UINT Value
Analogue Value range 0 - 65535 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Starts up the UART to allow communications and initialises the states of the various Modbus Coils, Inputs and Registers to 0. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Initialises the MIDI component and sets up the UART. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png CommsBaud
Sets the Baud rate of the alt communications channel 
Fc9-u8-icon.png - BYTE Baud
Range: 0-7 : 0=1200 / 7=115200 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDOptions
Controls some of the LCD options 
Fc9-u8-icon.png - BYTE Foreground
Range: 0-1 
Fc9-u8-icon.png - BYTE Background
Range: 0-1 
Fc9-u8-icon.png - BYTE Transparent
Range: 0-1 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDVerbose
Controls the Verbose mode. When enabled the LCD automatically displays an account of the incoming API commands and parameters. When switched off the LCD is free for the user to control as required. 
Fc9-u8-icon.png - BYTE Mode
Range: 0-1 : 0=Off or User Mode / 1=API Verbose Mode 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ReadDigitalInput
Reads a single digital input. 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png PWMConfig
Sets the PWM configuration. Channel = 0 - 1 : 0 = EN_AB, A, B / 1 = EN_CD, C, D Period = 0 - 65535 Scaler = 0 - 3 : 0=1:1 1=1:8 2=1:64 3=1:256 
Fc9-u8-icon.png - BYTE Channel
Range 0-1 
Fc9-u16-icon.png - UINT Period
Range: 0-65535 
Fc9-u8-icon.png - BYTE Scaler
Range: 0-3 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png PWMEnable
Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD 
Fc9-u8-icon.png - BYTE EnableMask
Range 0-63 or 0b00000 to 0b111111 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png PWMDuty
Sets a single PWM channel duty. Channel = 0 - 5 : 0=EN_AB, 1=A, 2=B, 3=C, 4=D, 5=EN_CD Duty = 0 - 65535 
Fc9-u8-icon.png - BYTE Channel
Range 0-5 
Fc9-u16-icon.png - UINT Duty
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDCursor
Sets the cursor position for the MIAC display 
Fc9-u8-icon.png - BYTE X
Range: 0-21 
Fc9-u8-icon.png - BYTE Y
Range: 0-4 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png WriteTran
Allows a single transistor output to be switched on or off. 
Fc9-u8-icon.png - BYTE Channel
Range 1-4 
Fc9-u8-icon.png - BYTE Value
0 = Off, 1 = On 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png LCDClear
Clears the MIAC display 
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-17-icon.png TCP/IP Component
Property to point to the TCP/IP or WIFI component you want to use. If unconnected then default to simulated TCP/IP network communications using the PC network adapter. 
Fc9-type-10-icon.png Status
 
Fc9-conn-icon.png Connections
Fc9-conn-icon.png Simulations
Fc9-type-16-icon.png Simulation Control
Allows the user to decide what happens when simulating. Simulation DLL forces all simulated TCP/IP comms to go directly via the simulation DLL bypassing any additional components. Component simulation forces the attached component to provide the simulation and maybe other aspects such as SPI/I2C communications. 
Fc9-type-16-icon.png Network Interface
Some computers may have several network interfaces such as ethernet ports and wifi access. Select the correct network interface for the network you wish to connect to. Use the IP address to confirm you are connected to the right network. 
Fc9-type-10-icon.png IP Address
IP Address of the selected network interface.