Component: TCPIP (Comms: Networking)
Author | Matrix Ltd. |
Version | 1.7 (Release) |
Category | Comms: Networking |
This inherits from TCP Template |
Contents
- 1 TCPIP component
- 2 Examples
- 3 Downloadable macro reference
- 3.1 TxSendMyIP
- 3.2 RxMatchMyIP
- 3.3 RxMatch_4_Bytes
- 3.4 SetMyIP
- 3.5 TxSendString
- 3.6 RxReadHeader
- 3.7 RxSkipBytes
- 3.8 CreateIPSocket
- 3.9 SetDestination
- 3.10 TxStart
- 3.11 RxReadByte
- 3.12 CreateUDPSocket
- 3.13 RxMatch_6_Bytes
- 3.14 RxMatch_2_Bytes
- 3.15 TxEnd
- 3.16 RxReadString
- 3.17 CreateTCPSocket
- 3.18 RxDataAvailable
- 3.19 TxSendByte
- 3.20 TCPListen
- 3.21 RxFlushData
- 3.22 TCPConnect
- 3.23 RxMatchMyMAC
- 3.24 RxDataSize
- 3.25 CreateMACSocket
- 3.26 TxSendMyMAC
- 3.27 TCPClose
- 3.28 GetSocketStatus
- 3.29 Initialise
- 4 Simulation macro reference
- 4.1 TxSendMyIP
- 4.2 RxMatchMyIP
- 4.3 RxMatch_4_Bytes
- 4.4 SetPropertyVal
- 4.5 SetMyIP
- 4.6 TxSendString
- 4.7 RxSkipBytes
- 4.8 RxReadHeader
- 4.9 CreateIPSocket
- 4.10 SetDestination
- 4.11 GetConsole
- 4.12 TxStart
- 4.13 RxReadByte
- 4.14 CreateUDPSocket
- 4.15 RxMatch_6_Bytes
- 4.16 RxMatch_2_Bytes
- 4.17 RxReadString
- 4.18 TxEnd
- 4.19 CreateTCPSocket
- 4.20 RxDataAvailable
- 4.21 TxSendByte
- 4.22 TCPListen
- 4.23 RxFlushData
- 4.24 TCPConnect
- 4.25 GetPropertyVal
- 4.26 RxMatchMyMAC
- 4.27 RxDataSize
- 4.28 TxSendMyMAC
- 4.29 CreateMACSocket
- 4.30 GetSocketStatus
- 4.31 TCPClose
- 4.32 Initialise
- 5 Property reference
TCPIP component
TCP/IP component designed to work with the WIZ810MJ module from Wiznet, as used on version 2 EB023 E-block and the MIAC Industrial Addon module.
Examples
No additional examples
Downloadable macro reference
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
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.
Parameters
- 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
Return value
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.
Parameters
- 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
Return value
- This call does not return a value
TxSendString
This macro fills the specified channel's transmit buffer with data. It can fill the buffer with a string of information.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- <- STRING Data
- Data byte to append to Tx buffer.
- This parameter may be returned back to the caller
- BYTE Length
Return value
- This call does not return a value
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
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Idx
- Specifies the byte index to return
Return value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Count
- Specifies how many bytes to skip
Return value
- This call does not return a value
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.
Parameters
- 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
Return value
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.
Parameters
- 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
- BYTE Dst_Port_Hi
- Port High Byte
- BYTE Dst_Port_Lo
- Port Low Byte
Return value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
CreateUDPSocket
This macro creates a socket for sending and receiving UDP data.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Src_Port_Hi
- Port High Byte
- BYTE Src_Port_Lo
- Port Low Byte
Return value
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.
Parameters
- 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
Return value
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.
Parameters
- 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
Return value
TxEnd
Once the transmit buffer has been filled with data, call this macro to actually send the data.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Length
Return value
CreateTCPSocket
This macro creates a socket for sending and receiving TCP data.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Src_Port_Hi
- Port High Byte
- BYTE Src_Port_Lo
- Port Low Byte
Return value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
TxSendByte
This macro fills the specified channel's transmit buffer with data. It can fill the buffer with a single byte of data, or with a string of information.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Data
- Data byte to append to Tx buffer.
Return value
- This call does not return a value
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).
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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).
Parameters
- 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
- BYTE Dst_Port_Hi
- High Byte of destination port
- BYTE Dst_Port_Lo
- Low Byte of destination port
Return value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
RxDataSize
This macro is used to detect the size of data collected by the Rx_data_available macro.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
CreateMACSocket
This macro creates a socket for sending and receiving Ethernet data using raw data.
Parameters
- 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)
Return value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
GetSocketStatus
This returns the state of the requested channel's socket.
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
Initialise
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component inherits simulation macros from TCP Template
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
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.
This call is provided by TCP Template
Parameters
- 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
Return value
SetPropertyVal
No additional information
This call is provided by TCP Template
Parameters
- <- STRING Property
- This parameter may be returned back to the caller
- <- STRING Value
- This parameter may be returned back to the caller
Return value
- This call does not return a value
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.
This call is provided by TCP Template
Parameters
- 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
Return value
- This call does not return a value
TxSendString
This macro fills the specified channel's transmit buffer with data. It can fill the buffer with a single byte of data, or with a string of information.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- <- STRING Data
- Data byte to append to Tx buffer.
- This parameter may be returned back to the caller
Return value
- This call does not return a value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Count
- Specifies how many bytes to skip
Return value
- This call does not return a value
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
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Idx
- Specifies the byte index to return
Return value
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.
This call is provided by TCP Template
Parameters
- 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
Return value
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.
This call is provided by TCP Template
Parameters
- 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
- BYTE Dst_Port_Hi
- Port High Byte
- BYTE Dst_Port_Lo
- Port Low Byte
Return value
- This call does not return a value
GetConsole
Obtain the console instance for the TCP/IP base.
This call is provided by TCP Template
Parameters
- This macro has no parameters
Return value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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 'RxReadByte' (or any other read function) will read the next byte
This call is provided by TCP Template
Parameters
- BYTE Channel
Return value
CreateUDPSocket
This macro creates a socket for sending and receiving UDP data.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Src_Port_Hi
- Port High Byte
- BYTE Src_Port_Lo
- Port Low Byte
Return value
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.
This call is provided by TCP Template
Parameters
- 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
Return value
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.
This call is provided by TCP Template
Parameters
- 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
Return value
RxReadString
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
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Length
Return value
TxEnd
Once the transmit buffer has been filled with data, call this macro to actually send the data.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
CreateTCPSocket
This macro creates a socket for sending and receiving TCP data.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
- BYTE Src_Port_Hi
- Port High Byte
- BYTE Src_Port_Lo
- Port Low Byte
Return value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
TxSendByte
This macro fills the specified channel's transmit buffer with data. It can fill the buffer with a single byte of data, or with a string of information.
This call is provided by TCP Template
Parameters
- BYTE Channel
- BYTE Data
Return value
- This call does not return a value
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).
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
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).
This call is provided by TCP Template
Parameters
- 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
- BYTE Dst_Port_Hi
- High Byte of destination port
- BYTE Dst_Port_Lo
- Low Byte of destination port
Return value
GetPropertyVal
No additional information
This call is provided by TCP Template
Parameters
- <- STRING Property
- This parameter may be returned back to the caller
Return value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
RxDataSize
This macro is used to detect the size of data collected by the Rx_data_available macro.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
CreateMACSocket
This macro creates a socket for sending and receiving Ethernet data using raw data.
This call is provided by TCP Template
Parameters
- 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)
Return value
GetSocketStatus
This returns the state of the requested channel's socket.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
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.
This call is provided by TCP Template
Parameters
- BYTE Channel
- Specifies the communications channel 0-3
Return value
- This call does not return a value
Initialise
Resets and initialises the Internet E-Block. It sets up the gateway address, subnet mask, device IP address and device MAC address as defined in the properties of the Flowcode component. This macro must be called before any other TCP_IP component macros
This call is provided by TCP Template
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Property reference
Label
This property is of type Line of text and can be referenced with the variable name label.
No additional information
Max Channels
This property is of type Signed integer and can be referenced with the variable name max_channels.
No additional information
Channel
This property is of type Fixed list of ints and can be referenced with the variable name channel.
No additional information
Int Pin
This property is of type Single digital pin and can be referenced with the variable name int_pin.
No additional information
CS Pin
This property is of type Single digital pin and can be referenced with the variable name cs_pin.
No additional information
MOSI Pin
This property is of type Single digital pin and can be referenced with the variable name mosi_pin.
No additional information
MISO Pin
This property is of type Single digital pin and can be referenced with the variable name miso_pin.
No additional information
SCK Pin
This property is of type Single digital pin and can be referenced with the variable name sck_pin.
No additional information
Gateway0
This property is of type Signed integer and can be referenced with the variable name gateway0.
No additional information
Gateway1
This property is of type Signed integer and can be referenced with the variable name gateway1.
No additional information
Gateway2
This property is of type Signed integer and can be referenced with the variable name gateway2.
No additional information
Gateway3
This property is of type Signed integer and can be referenced with the variable name gateway3.
No additional information
Subnet0
This property is of type Signed integer and can be referenced with the variable name subnet0.
No additional information
Subnet1
This property is of type Signed integer and can be referenced with the variable name subnet1.
No additional information
Subnet2
This property is of type Signed integer and can be referenced with the variable name subnet2.
No additional information
Subnet3
This property is of type Signed integer and can be referenced with the variable name subnet3.
No additional information
IP0
This property is of type Signed integer and can be referenced with the variable name ip0.
No additional information
IP1
This property is of type Signed integer and can be referenced with the variable name ip1.
No additional information
IP2
This property is of type Signed integer and can be referenced with the variable name ip2.
No additional information
IP3
This property is of type Signed integer and can be referenced with the variable name ip3.
No additional information
MAC0
This property is of type Signed integer and can be referenced with the variable name mac0.
No additional information
MAC1
This property is of type Signed integer and can be referenced with the variable name mac1.
No additional information
MAC2
This property is of type Signed integer and can be referenced with the variable name mac2.
No additional information
MAC3
This property is of type Signed integer and can be referenced with the variable name mac3.
No additional information
MAC4
This property is of type Signed integer and can be referenced with the variable name mac4.
No additional information
MAC5
This property is of type Signed integer and can be referenced with the variable name mac5.
No additional information