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

From Flowcode Help
Jump to navigationJump to search
Line 32: Line 32:
  
  
{|
+
{| class="wikitable"
 
! Embedded Component
 
! Embedded Component
 
! Support Status
 
! Support Status

Revision as of 13:53, 18 September 2019


Author Matrix TSL
Version 1.0 (Release)
Category Comms: Networking


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.

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

Components such as MQTT and Modbus TCP can control the network comms layer to avoid repeating code and also to allow the embedded hardware bridge that controls connected TCP/IP embedded modules.

If the Network Communications component is connected to an embedded TCP/IP component then it will allow the TCP/IP communications to work on embedded hardware.


Embedded Component Support Status
Raspberry Pi 1/2/3 Supported
W5500 In Progress
ESP8266 In Progress

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

UINT


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

UINT


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.

No additional information