Difference between revisions of "Component: Network Communications (Comms: Networking)"
Line 1: | Line 1: | ||
+ | |||
+ | |||
+ | {| width="50%" | ||
+ | |- | ||
+ | | width="20%" style="color: gray;" | Author | ||
+ | | Matrix TSL | ||
+ | |- | ||
+ | | width="20%" style="color: gray;" | Version | ||
+ | | 1.0 (Release) | ||
+ | |- | ||
+ | | width="20%" style="color: gray;" | Category | ||
+ | | Comms: Networking | ||
+ | |} | ||
+ | |||
+ | |||
+ | |||
+ | ==[[File:Component Icon 91049bf5_2436_42dc_947a_c30c86463d98.png|Image]] 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. | ||
+ | |||
+ | ==Examples== | ||
+ | |||
+ | |||
Here are some examples showing the Network Communications component in action. | 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. | + | 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. | Here is a simple example showing the component used by itself to request data from a remote server on the internet. | ||
Line 26: | Line 50: | ||
− | Here is the current status of the Network Communications component with the various embedded modules. | + | Here is the current status of the Network Communications component with the various embedded modules. |
{| class="wikitable" | {| class="wikitable" | ||
Line 64: | Line 88: | ||
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. | 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== | ||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>Connect</tt></u></span>=== | ||
+ | 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 | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|<- STRING]] ''Address'' | ||
+ | ::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'' | ||
+ | |||
+ | :[[Variable Types|UINT]] ''Port'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|BOOL]] : Returns true if the operation is a success, else false | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>Receive</tt></u></span>=== | ||
+ | Attempts to receive up to a specified number of bytes from the active connection. | ||
+ | |||
+ | Returns the number of bytes received. | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|<- STRING]] ''Data'' | ||
+ | ::''This parameter may be returned back to the caller'' | ||
+ | |||
+ | :[[Variable Types|UINT]] ''Count'' | ||
+ | ::Maximum number of bytes to read | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|UINT]] | ||
+ | |||
+ | |||
+ | ===<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. | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|<- STRING]] ''Data'' | ||
+ | ::Array containing the data to send | ||
+ | ::''This parameter may be returned back to the caller'' | ||
+ | |||
+ | :[[Variable Types|UINT]] ''Count'' | ||
+ | ::Number of bytes to send from the data array | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|UINT]] | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>Listen</tt></u></span>=== | ||
+ | Bind the socket to a port on the local host and set to listen mode. | ||
+ | |||
+ | Returns: 0=Fail, 1=OK | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :[[Variable Types|UINT]] ''Port'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|BOOL]] : Returns true if the operation is a success, else false | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>SocketOpen</tt></u></span>=== | ||
+ | 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 | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :''This macro has no parameters'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :[[Variable Types|BOOL]] : Returns true if the operation is a success, else false | ||
+ | |||
+ | |||
+ | ===<span style="font-weight: normal;"><u><tt>SocketClose</tt></u></span>=== | ||
+ | Closes the current socket connection | ||
+ | |||
+ | '''Parameters''' | ||
+ | |||
+ | :''This macro has no parameters'' | ||
+ | |||
+ | |||
+ | '''Return value''' | ||
+ | |||
+ | :''This call does not return a value'' | ||
+ | |||
+ | |||
+ | |||
+ | ==Simulation macro reference== | ||
+ | |||
+ | ''This component does not contain any simulation macros'' | ||
+ | |||
+ | |||
+ | ==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''. | ||
+ | |||
+ | 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. | ||
+ | |||
+ | <span style="font-weight: normal;"><u>Status</u></span> | ||
+ | |||
+ | This property is of type ''Line of text'' and can be referenced with the variable name ''Status''. | ||
+ | |||
+ | Informs the user of the current status of support for the connected component. |
Revision as of 13:09, 19 August 2021
Author | Matrix TSL |
Version | 1.0 (Release) |
Category | Comms: Networking |
Contents
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.
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.
Library Components
Components such as Webserver (GENERIC), MQTT and Modbus TCP can connect to and control the network comms layer.
Here is a simple example showing the component used with the Webserver (GENERIC) component.
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.
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
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
Parameters
- <- STRING Address
- 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
- UINT Port
Return value
- BOOL : Returns true if the operation is a success, else false
Receive
Attempts to receive up to a specified number of bytes from the active connection.
Returns the number of bytes received.
Parameters
- <- STRING Data
- This parameter may be returned back to the caller
- UINT Count
- Maximum number of bytes to read
Return value
Send
Sends the specified number of bytes via the active connection.
Returns the number of bytes sent, 0=Fail.
Parameters
- <- STRING Data
- Array containing the data to send
- This parameter may be returned back to the caller
- UINT Count
- Number of bytes to send from the data array
Return value
Listen
Bind the socket to a port on the local host and set to listen mode.
Returns: 0=Fail, 1=OK
Parameters
- UINT Port
Return value
- BOOL : Returns true if the operation is a success, else false
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
Parameters
- This macro has no parameters
Return value
- BOOL : Returns true if the operation is a success, else false
SocketClose
Closes the current socket connection
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component does not contain any simulation macros
Property reference
TCP/IP Component
This property is of type Panel object and can be referenced with the variable name 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.
Status
This property is of type Line of text and can be referenced with the variable name Status.
Informs the user of the current status of support for the connected component.