Jump to content

Component: TCP/IP (W5500) (W5500) (Comms: Networking)

From Flowcode Help
Revision as of 16:57, 1 September 2026 by Wiki bot (talk | contribs)
Author Matrix TSL
Version 10.0
Category Comms: Networking


TCP/IP (W5500) component

TCP/IP component designed to work with the W5500 device used on the ETH WIZ Click

Version information

Library Version, Component Version, Date, Author, Info
10, 0.0, 23-06-25, MW, Fixed a bug wihtin DHCP_Run that's causing compiler error with ESP32


Detailed description

No detailed description exists yet for this component

Examples

HTTP Server

Simple example showing the W5500 component being used stand alone to create a web server.

W5500 Webserver


Network Comms

Here are some examples using the Network Communication component linked to the W5500 component.

NetworkComms W5500 Client

NetworkComms W5500 Webserver






Macro reference

CreateIPSocket

CreateIPSocket
Note that sockets on up to 4 channels can be simultaneously opened and these channels are numbered 0 to 3. Note that sockets with different modes can be opened on different channels. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Protocol
Specifies which IP protocol to use 
- BYTE Broadcast
Allows broadcast type packets to be sent and received 
- BYTE Return


CreateMACSocket

CreateMACSocket
This macro creates a socket for sending and receiving Ethernet data using raw data. 
- BYTE Promiscuous
Receive everything (1) or just data bound for your MAC (0) 
- BYTE Broadcast
Allows broadcast messages to be accepted (1) or rejected (0) 
- BYTE Error
Allowsmessages with errors to be accepted (1) or rejected (0) 
- BYTE Return


CreateTCPSocket

CreateTCPSocket
This macro creates a socket for sending and receiving TCP data. 
- BYTE Channel
Specifies the communications channel 0-3 
- UINT Src_Port
Port Number 
- BYTE Return


CreateUDPSocket

CreateUDPSocket
This macro creates a socket for sending and receiving UDP data. 
- BYTE Channel
Specifies the communications channel 0-3 
- UINT Src_Port
Port Number 
- BYTE Return


DHCP_CheckLease

DHCP_CheckLease
Call once per second from your main loop when DHCP is enabled. Decrements the T1 renewal timer and when it expires attempts a unicast renewal, falling back to full rediscovery if the renewal fails. Returns: 0=lease OK, 2=renewed, 3=rebind failed, 4=rebind succeeded. 
- BYTE Return


DHCP_Run

DHCP_Run
Advances the DHCP state machine by one step and returns 0. States: 0=send DISCOVER; 1=wait for OFFER (type 2), timeout on miss; 2=wait for ACK (type 5) then advance to state 3 (leased); 3=leased, no-op (DHCP_CheckLease handles renewal); 4=renewal REQUEST sent, advance to 5; 5=wait for renewal ACK (type 5) or NAK/timeout back to 0. Called automatically by Initialise during startup. To force renegotiation: set DHCP_State=0, DHCP_Timeout=0, then call this macro in a polling loop until DHCP_State reaches 3 or DHCP_Timeout exceeds 1000. 
- BYTE Return


DNS_GetHostByName

DNS_GetHostByName
Resolves a hostname to an IPv4 address using the configured DNS server. Opens a UDP socket on the specified channel, sends a type-A query, waits up to ~2 seconds for a response, then parses the answer. Returns 1 on success with DNS_ResolvedIP populated, or 0 on timeout or any error. 
- BYTE Channel
UDP socket channel to use (0-3). Must not conflict with DHCP channel. 
- STRING Hostname
URL to try and resolve e.g. "Flowcode.co.uk" 
- BYTE Return


DNS_GetResolvedIP

DNS_GetResolvedIP
Returns the specified byte (index 0-3) of the IP address resolved by the most recent successful DNS_GetHostByName call. 
- BYTE Idx
IP byte index 0-3. 
- BYTE Return


DNS_GetServer

DNS_GetServer
Returns the specified byte (index 0-3) of the configured DNS server IP address. 
- BYTE Idx
IP byte index 0-3. 
- BYTE Return


GetIPString

GetIPString
Formats one of the DHCP-assigned network addresses as a null-terminated dotted-decimal ASCII string (e.g. "192.168.1.100") and writes it into Output. Selection: 0=assigned IP, 1=subnet mask, 2=gateway, 3=DNS server. Output must be at least 16 bytes. 
- BYTE Selection
Which address: 0=IP, 1=Subnet, 2=Gateway, 3=DNS 
- STRING Output
Caller-supplied buffer of at least 16 bytes; receives the formatted string 
- VOID Return


GetSocketStatus

GetSocketStatus
This returns the state of the requested channel's socket. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Return


Initialise

Initialise
Resets and initialises the W5500 IC. Sets up the gateway address, subnet mask, device IP address and device MAC address. This macro must be called before any other TCP_IP component macros. Returns 1 to indicate successful communication. 
- BYTE Return


MIAC_Module_GetData

MIAC_Module_GetData
Internal. Returns one byte from the response buffer of the most recently polled MIAC industrial module. 
- BYTE Index
Zero-based index of the byte to retrieve from the MIAC response buffer 
- BYTE Return


MIAC_Module_Message

MIAC_Module_Message
Internal. Sends a command message to a MIAC industrial module over the CAN-style serial bus and waits for an acknowledgement. 
- UINT CAN_ID
CAN bus identifier of the target MIAC module 
- UINT CMD_ID
Command identifier sent to the module 
- BYTE Return


MIAC_Module_PushData

MIAC_Module_PushData
Internal. Appends a byte to the outgoing data buffer used by the next MIAC_Module_Message call. 
- BYTE Data
Byte to append to the outgoing MIAC data buffer 
- VOID Return


MIAC_Module_SetData

MIAC_Module_SetData
Internal. Sends a command packet containing up to six data bytes to a connected MIAC industrial add-on module. 
- BYTE Count
Number of data bytes to include in the message (0-6) 
- BYTE D0
First data byte 
- BYTE D1
Second data byte (unused if Count is less than 2) 
- BYTE D2
Third data byte (unused if Count is less than 3) 
- BYTE D3
Fourth data byte (unused if Count is less than 4) 
- BYTE D4
Fifth data byte (unused if Count is less than 5) 
- BYTE D5
Sixth data byte (unused if Count is less than 6) 
- VOID Return


RxDataAvailable

RxDataAvailable
This macro is used to check whether or not data has been received by the Internet E-Block. A return value of zero indicated that no data has been received. A positive return value indicates that data is available. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Return


RxDataSize

RxDataSize
This macro is used to detect the size of data collected by the Rx_data_available macro. 
- BYTE Channel
Specifies the communications channel 0-3 
- UINT Return


RxFlushData

RxFlushData
Once data reception has been completed, this macro should be called to discard the data packet and allow other data packets to be read. 
- BYTE Channel
Specifies the communications channel 0-3 
- VOID Return


RxMatchMyIP

RxMatchMyIP
This macro returns a non-zero value when the next 4 bytes of data in the specified channel's reception buffer are the same as the Internet E-block's IP address. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Return


RxMatchMyMAC

RxMatchMyMAC
This macro returns a non-zero value when the next 6 bytes of data in the specified channel's reception buffer are the same as the Internet E-block's MAC address entered in the component's property page. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Return


RxMatch_2_Bytes

RxMatch_2_Bytes
This macro returns a non-zero value when the next 2 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 4 bytes and 6 bytes. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Byte1
Specifies the value of the first byte 
- BYTE Byte2
Specifies the value of the second byte 
- BYTE Return


RxMatch_4_Bytes

RxMatch_4_Bytes
This macro returns a non-zero value when the next 4 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 2 bytes and 6 bytes. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Byte1
Specifies the value of the first byte 
- BYTE Byte2
Specifies the value of the second byte 
- BYTE Byte3
Specifies the value of the third byte 
- BYTE Byte4
Specifies the value of the fourth byte 
- BYTE Return


RxMatch_6_Bytes

RxMatch_6_Bytes
This macro returns a non-zero value when the next 6 bytes of data in the specified channel's reception buffer are the same as those passed as parameters. There are similar functions that check for 2 bytes and 4 bytes. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Byte1
Specifies the value of the first byte 
- BYTE Byte2
Specifies the value of the second byte 
- BYTE Byte3
Specifies the value of the third byte 
- BYTE Byte4
Specifies the value of the fourth byte 
- BYTE Byte5
Specifies the value of the fifth byte 
- BYTE Byte6
Specifies the value of the sixth byte 
- BYTE Return


RxReadArray

RxReadArray
A call to this macro will return a byte of data in the reception buffer of the specified channel. It will also internally increment a pointer to that data so that the next call to 'Rx_readbyte' (or any other read function) will read the next byte  
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Data
Destination byte array to receive the data 
- UINT Count
Number of bytes to read from the receive buffer 
- VOID Return


RxReadByte

RxReadByte
A call to this macro will return a byte of data in the reception buffer of the specified channel. It will also internally increment a pointer to that data so that the next call to 'Rx_readbyte' (or any other read function) will read the next byte  
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Return


RxReadHeader

RxReadHeader
Once data in a particular channel has been received, the header will be filled with information about the received data. This macro will return the information in the header. The idx parameter specifies which byte of information in the header to read  
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Idx
Specifies the byte index to return 
- BYTE Return


RxReadString

RxReadString
A call to this macro will return a string of data in the reception buffer of the specified channel. It will also internally increment a pointer to that data so that the next call to 'Rx_readbyte' (or any other read function) will read the next byte  
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Length
Maximum number of characters to read 
- STRING Return


RxSkipBytes

RxSkipBytes
Often when receiving data packets, it may be necessary to ignore large sections of the data. This can be achieved by reading each byte individually (and ignoring the returned data), but a better way is to use this Rx_skipbytes macro. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Count
Specifies how many bytes to skip 
- VOID Return


SetDestination

SetDestination
This is used in IP and UDP modes to set the destination of the intended data transfer. The destination IP address needs to be set for both IP and UDP modes. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Dst_IP0
Specifies the first byte of an IP address 
- BYTE Dst_IP1
Specifies the second byte of an IP address 
- BYTE Dst_IP2
Specifies the third byte of an IP address 
- BYTE Dst_IP3
Specifies the fourth byte of an IP address 
- UINT Dst_Port
Destination Port 
- BYTE Return


SetGateway

SetGateway
This macro sets up the Internet E-Block's Gateway address. In most circumstances, this macro will not be required as the gateway address setting in the component property page will remain constant throughout your application. 
- BYTE IP0
First Byte of IP address 
- BYTE IP1
Second Byte of IP address 
- BYTE IP2
Third Byte of IP address 
- BYTE IP3
Fourth Byte of IP address 
- VOID Return


SetMACAddress

SetMACAddress
This macro sets up the Internet E-Block's MAC address. In most circumstances, this macro will not be required as the MAC address setting in the component property page will remain constant throughout your application. 
- BYTE MAC0
First Byte of address 
- BYTE MAC1
Second Byte of address 
- BYTE MAC2
Third Byte of address 
- BYTE MAC3
Fourth Byte of address 
- BYTE MAC4
Fourth Byte of address 
- BYTE MAC5
Fifth Byte of address 
- VOID Return


SetMyIP

SetMyIP
This macro sets up the Internet E-Block's own IP address. In most circumstances, this macro will not be required as the IP address setting in the component property page will remain constant throughout your application. 
- BYTE IP0
First Byte of IP address 
- BYTE IP1
Second Byte of IP address 
- BYTE IP2
Third Byte of IP address 
- BYTE IP3
Fourth Byte of IP address 
- VOID Return


SetSubnetMask

SetSubnetMask
This macro sets up the Internet E-Block's Subnet Mask. In most circumstances, this macro will not be required as the subnet mask setting in the component property page will remain constant throughout your application. 
- BYTE IP0
First Byte of IP address 
- BYTE IP1
Second Byte of IP address 
- BYTE IP2
Third Byte of IP address 
- BYTE IP3
Fourth Byte of IP address 
- VOID Return


TCPClose

TCPClose
When an established TCP connection has finished transmission of data, either the local application (i.e. your code) or the remote application (i.e. the application at the other end of the connection) can initiate closure of the socket. 
- BYTE Channel
Specifies the communications channel 0-3 
- VOID Return


TCPConnect

TCPConnect
This macro puts a previously opened TCP channel in "active open" mode. This is the required mode when writing a TCP client application (e.g. using SMTP to send an email). 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Dst_IP0
First Byte of IP address 
- BYTE Dst_IP1
Second Byte of IP address 
- BYTE Dst_IP2
Third Byte of IP address 
- BYTE Dst_IP3
Fourth Byte of IP address 
- UINT Dst_Port
Destination Port 
- BYTE Return


TCPListen

TCPListen
This macro puts a previously opened TCP channel in "passive open" mode. This is the required mode when writing a TCP server application (e.g. a web server to display HTML web pages). 
- BYTE Channel
Specifies the communications channel 0-3 
- VOID Return


TxEnd

TxEnd
Once the transmit buffer has been filled with data, call this macro to actually send the data. 
- BYTE Channel
Specifies the communications channel 0-3 
- VOID Return


TxSendArray

TxSendArray
This macro fills the specified channel's transmit buffer with data. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Data
Data byte to append to Tx buffer. 
- UINT Count
Number of bytes to transmit 
- VOID Return


TxSendByte

TxSendByte
This macro fills the specified channel's transmit buffer with data. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE Data
Data byte to append to Tx buffer. 
- VOID Return


TxSendMyIP

TxSendMyIP
This macro fills the specified channel's transmit buffer with 4 bytes of data representing this Internet E-Block's IP address as specified in the component's property page. 
- BYTE Channel
Specifies the communications channel 0-3 
- VOID Return


TxSendMyMAC

TxSendMyMAC
This macro fills the specified channel's transmit buffer with 6 bytes of data representing this Internet E-Block's MAC address as specified in the component's property page. 
- BYTE Channel
Specifies the communications channel 0-3 
- VOID Return


TxSendString

TxSendString
This macro fills the specified channel's transmit buffer with data. It can fill the buffer with a string of information. 
- BYTE Channel
Specifies the communications channel 0-3 
- STRING Data
Data byte to append to Tx buffer. 
- BYTE Length
Number of characters to transmit 
- VOID Return


TxStart

TxStart
This macro indicates the start of data transmission for the specified buffer. In TCP mode, data transmission can only begin once the socket has become established. In other modes, data transmission can occur as soon as the socket has been opened. 
- BYTE Channel
Specifies the communications channel 0-3 
- VOID Return


Property reference

Properties
Connections
Channel
SPI Channel selector 
Prescale
Prescale option selector 
MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
CS / SS
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
DHCP
Enable DHCP to automatically obtain IP address, subnet mask and gateway from a DHCP server. When enabled, the IP Address, Subnet Mask and Gateway IP properties are not used. 
Gateway IP
Gateway0
First octet of the default gateway IP address (e.g. 192 in 192.168.1.1). Ignored when DHCP is enabled. 
Gateway1
Second octet of the default gateway IP address. Ignored when DHCP is enabled. 
Gateway2
Third octet of the default gateway IP address. Ignored when DHCP is enabled. 
Gateway3
Fourth octet of the default gateway IP address (e.g. 1 in 192.168.1.1). Ignored when DHCP is enabled. 
Subnet Mask
Subnet0
First octet of the subnet mask (e.g. 255 for 255.255.255.0). Ignored when DHCP is enabled. 
Subnet1
Second octet of the subnet mask (e.g. 255 for 255.255.255.0). Ignored when DHCP is enabled. 
Subnet2
Third octet of the subnet mask. Ignored when DHCP is enabled. 
Subnet3
Fourth octet of the subnet mask (e.g. 0 for 255.255.255.0). Ignored when DHCP is enabled. 
IP Address
IP0
First octet of the static IP address (e.g. 192 in 192.168.1.100). Ignored when DHCP is enabled. 
IP1
Second octet of the static IP address. Ignored when DHCP is enabled. 
IP2
Third octet of the static IP address. Ignored when DHCP is enabled. 
IP3
Fourth octet of the static IP address (e.g. 100 in 192.168.1.100). Ignored when DHCP is enabled. 
DNS Server
DNS0
First octet of the DNS server IP address (e.g. 8 in 8.8.8.8). Used in static IP mode; also acts as fallback if DHCP does not provide a DNS server. 
DNS1
Second octet of the DNS server IP address (e.g. 8 in 8.8.8.8). 
DNS2
Third octet of the DNS server IP address (e.g. 8 in 8.8.8.8). 
DNS3
Fourth octet of the DNS server IP address (e.g. 8 in 8.8.8.8). Google Public DNS default. 
MAC Address
MAC0
First byte of the Ethernet MAC address (e.g. 0x00). Must be unique per device. The LSB must be 0 (unicast). 
MAC1
Second byte of the Ethernet MAC address (e.g. 0x08). 
MAC2
Third byte of the Ethernet MAC address (e.g. 0xDC - Matrix TSL OUI). 
MAC3
Fourth byte of the Ethernet MAC address. 
MAC4
Fifth byte of the Ethernet MAC address. 
MAC5
Sixth byte of the Ethernet MAC address. Change this to make each device unique. 
Simulation
Label
Display label for this component instance on the Flowcode panel. 
Sim Type
Decides how to perform the simulation of the component. TCP IP - Communicates using the Windows TCP IP communications DLL SPI / Injector - Communicates using the CAL SPI to allow the communications to be analysed and debugged. 
TCP Simulation
Network Interface
List of network interfaces connected to the PC. Sets which interface we are communicating via. 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_TCPIP_W5500.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_TCPIP_W5500.fcfx