Jump to content

Component: TCP/IP (BL0187) (E-blocks 2): Difference between revisions

From Flowcode Help
m Text replacement - "width="10%" align="center" style="background-color:#D8C9D8;"" to "width="10%" align="center" class="mtx-class-macrohead""
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(2 intermediate revisions by the same user not shown)
Line 71: Line 71:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ControlLEDs'''
| width="90%" class="mtx-class-macrohead" | '''ControlLEDs'''
|-
|-
| colspan="2" | Allows both the LEDs on the Ethernet socket to be controlled. Useful for checking if the SPI communications are functioning correctly. 
| colspan="2" | Allows both the LEDs on the Ethernet socket to be controlled. Useful for checking if the SPI communications are functioning correctly. 
Line 90: Line 90:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateIPSocket'''
| width="90%" class="mtx-class-macrohead" | '''CreateIPSocket'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 119: Line 119:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateMACSocket'''
| width="90%" class="mtx-class-macrohead" | '''CreateMACSocket'''
|-
|-
| colspan="2" | This macro creates a socket for sending and receiving Ethernet data using raw data. 
| colspan="2" | This macro creates a socket for sending and receiving Ethernet data using raw data. 
Line 148: Line 148:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateTCPSocket'''
| width="90%" class="mtx-class-macrohead" | '''CreateTCPSocket'''
|-
|-
| colspan="2" | This macro creates a socket for sending and receiving TCP data. 
| colspan="2" | This macro creates a socket for sending and receiving TCP data. 
Line 172: Line 172:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CreateUDPSocket'''
| width="90%" class="mtx-class-macrohead" | '''CreateUDPSocket'''
|-
|-
| colspan="2" | This macro creates a socket for sending and receiving UDP data. 
| colspan="2" | This macro creates a socket for sending and receiving UDP data. 
Line 196: Line 196:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DHCP_Setup'''
| width="90%" class="mtx-class-macrohead" | '''DHCP_Setup'''
|-
|-
| colspan="2" |  
| colspan="2" |  
Line 210: Line 210:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''DNS_Lookup'''
| width="90%" class="mtx-class-macrohead" | '''DNS_Lookup'''
|-
|-
| colspan="2" | Resolve the URL into an IP address via the DNS server. Returns non-zero if successful 
| colspan="2" | Resolve the URL into an IP address via the DNS server. Returns non-zero if successful 
Line 234: Line 234:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLocalIP'''
| width="90%" class="mtx-class-macrohead" | '''GetLocalIP'''
|-
|-
| colspan="2" | Gets the local IP address 
| colspan="2" | Gets the local IP address 
Line 253: Line 253:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLocalMAC'''
| width="90%" class="mtx-class-macrohead" | '''GetLocalMAC'''
|-
|-
| colspan="2" | Gets the local MAC address 
| colspan="2" | Gets the local MAC address 
Line 272: Line 272:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
|-
| colspan="2" | Initialises the SPI connection to the TCPIP module and sets up some initial values. Flashes the LEDs on and off twice to confirm SPI comms are active. LEDs are then configured to auto functionality. 
| colspan="2" | Initialises the SPI connection to the TCPIP module and sets up some initial values. Flashes the LEDs on and off twice to confirm SPI comms are active. LEDs are then configured to auto functionality. 
Line 286: Line 286:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadRegister'''
| width="90%" class="mtx-class-macrohead" | '''ReadRegister'''
|-
|-
| colspan="2" | Reads the value from a single register onboard the ENC28J60 module. 
| colspan="2" | Reads the value from a single register onboard the ENC28J60 module. 
Line 305: Line 305:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxDataAvailable'''
| width="90%" class="mtx-class-macrohead" | '''RxDataAvailable'''
|-
|-
| colspan="2" | Check if data has been received. A non-zero return value indicates that data is available. This macro should be called regularly as it also processess supporting network traffic. 
| colspan="2" | Check if data has been received. A non-zero return value indicates that data is available. This macro should be called regularly as it also processess supporting network traffic. 
Line 324: Line 324:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxDataSize'''
| width="90%" class="mtx-class-macrohead" | '''RxDataSize'''
|-
|-
| colspan="2" | This macro is used to detect the size of data collected by the Rx_data_available macro. 
| colspan="2" | This macro is used to detect the size of data collected by the Rx_data_available macro. 
Line 343: Line 343:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxFlushData'''
| width="90%" class="mtx-class-macrohead" | '''RxFlushData'''
|-
|-
| colspan="2" | Once data reception has been completed, this macro should be called to discard the data packet and allow other data packets to be read. 
| colspan="2" | Once data reception has been completed, this macro should be called to discard the data packet and allow other data packets to be read. 
Line 362: Line 362:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxMatchMyIP'''
| width="90%" class="mtx-class-macrohead" | '''RxMatchMyIP'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 381: Line 381:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxMatchMyMAC'''
| width="90%" class="mtx-class-macrohead" | '''RxMatchMyMAC'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 400: Line 400:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxMatch_2_Bytes'''
| width="90%" class="mtx-class-macrohead" | '''RxMatch_2_Bytes'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 429: Line 429:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxMatch_4_Bytes'''
| width="90%" class="mtx-class-macrohead" | '''RxMatch_4_Bytes'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 468: Line 468:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxMatch_6_Bytes'''
| width="90%" class="mtx-class-macrohead" | '''RxMatch_6_Bytes'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 517: Line 517:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxReadByte'''
| width="90%" class="mtx-class-macrohead" | '''RxReadByte'''
|-
|-
| colspan="2" | 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  
| colspan="2" | 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  
Line 536: Line 536:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxReadHeader'''
| width="90%" class="mtx-class-macrohead" | '''RxReadHeader'''
|-
|-
| colspan="2" | 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  
| colspan="2" | 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  
Line 560: Line 560:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxReadString'''
| width="90%" class="mtx-class-macrohead" | '''RxReadString'''
|-
|-
| colspan="2" | 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  
| colspan="2" | 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  
Line 584: Line 584:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxSkipBytes'''
| width="90%" class="mtx-class-macrohead" | '''RxSkipBytes'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 608: Line 608:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RxStart'''
| width="90%" class="mtx-class-macrohead" | '''RxStart'''
|-
|-
| colspan="2" | Move the received buffer read pointer back to the start 
| colspan="2" | Move the received buffer read pointer back to the start 
Line 627: Line 627:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetDestination'''
| width="90%" class="mtx-class-macrohead" | '''SetDestination'''
|-
|-
| colspan="2" | This is used in IP and UDP modes to set the destination of the intended data transfer. 
| colspan="2" | This is used in IP and UDP modes to set the destination of the intended data transfer. 
Line 656: Line 656:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetGateway'''
| width="90%" class="mtx-class-macrohead" | '''SetGateway'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 690: Line 690:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetLocalIP'''
| width="90%" class="mtx-class-macrohead" | '''SetLocalIP'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 724: Line 724:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetMACAddress'''
| width="90%" class="mtx-class-macrohead" | '''SetMACAddress'''
|-
|-
| colspan="2" | Allows the MAC Address specified in the component properties to be overridden. The MAC Address will revert back to the MAC specified in the component properties as part of the initialise macro. 
| colspan="2" | Allows the MAC Address specified in the component properties to be overridden. The MAC Address will revert back to the MAC specified in the component properties as part of the initialise macro. 
Line 768: Line 768:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetSubnetMask'''
| width="90%" class="mtx-class-macrohead" | '''SetSubnetMask'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 802: Line 802:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TCP_Close'''
| width="90%" class="mtx-class-macrohead" | '''TCP_Close'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 816: Line 816:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TCP_Connect'''
| width="90%" class="mtx-class-macrohead" | '''TCP_Connect'''
|-
|-
| colspan="2" | 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). 
| colspan="2" | 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). 
Line 840: Line 840:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TxEnd'''
| width="90%" class="mtx-class-macrohead" | '''TxEnd'''
|-
|-
| colspan="2" | Once the transmit buffer has been filled with data, call this macro to actually send the data. 
| colspan="2" | Once the transmit buffer has been filled with data, call this macro to actually send the data. 
Line 859: Line 859:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TxSendByte'''
| width="90%" class="mtx-class-macrohead" | '''TxSendByte'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 883: Line 883:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TxSendMyIP'''
| width="90%" class="mtx-class-macrohead" | '''TxSendMyIP'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 902: Line 902:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TxSendMyMAC'''
| width="90%" class="mtx-class-macrohead" | '''TxSendMyMAC'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 921: Line 921:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TxSendString'''
| width="90%" class="mtx-class-macrohead" | '''TxSendString'''
|-
|-
| colspan="2" | This macro fills the specified channel's transmit buffer with data.  It can fill the buffer with a string of information. 
| colspan="2" | This macro fills the specified channel's transmit buffer with data.  It can fill the buffer with a string of information. 
Line 950: Line 950:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TxStart'''
| width="90%" class="mtx-class-macrohead" | '''TxStart'''
|-
|-
| colspan="2" | 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. 
| colspan="2" | 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. 
Line 969: Line 969:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''WriteRegister'''
| width="90%" class="mtx-class-macrohead" | '''WriteRegister'''
|-
|-
| colspan="2" | Writes a value to a single register onboard the ENC28J60 module. 
| colspan="2" | Writes a value to a single register onboard the ENC28J60 module. 
Line 994: Line 994:
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | TCP IP Specifics
| width="90%" class="mtx-class-propfolder" | TCP IP Specifics
|-
|-
|-
|-
Line 1,011: Line 1,011:
| colspan="2" | Number of bytes to use for the transmit and receive buffer, we actually use this +1 to allow for a null termination. 8-bit PICs should set this to 255 to allow compilation to succeed. Other devices can have larger buffers. Default = 500 
| colspan="2" | Number of bytes to use for the transmit and receive buffer, we actually use this +1 to allow for a null termination. 8-bit PICs should set this to 255 to allow compilation to succeed. Other devices can have larger buffers. Default = 500 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | SPI Settings
| width="90%" class="mtx-class-propfolder" | SPI Settings
|-
|-
|-
|-
Line 1,060: Line 1,060:
| colspan="2" | When enabled the Initialisation will also include DHCP setup to auto configure settings.  
| colspan="2" | When enabled the Initialisation will also include DHCP setup to auto configure settings.  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | MAC Address
| width="90%" class="mtx-class-propfolder" | MAC Address
|-
|-
|-
|-
Line 1,094: Line 1,094:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | IP Address
| width="90%" class="mtx-class-propfolder" | IP Address
|-
|-
|-
|-
Line 1,118: Line 1,118:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Gateway IP
| width="90%" class="mtx-class-propfolder" | Gateway IP
|-
|-
|-
|-
Line 1,142: Line 1,142:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Subnet Mask
| width="90%" class="mtx-class-propfolder" | Subnet Mask
|-
|-
|-
|-
Line 1,166: Line 1,166:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
|-
|-
Line 1,180: Line 1,180:
| colspan="2" | 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. 
| colspan="2" | 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. 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | SPI Simulation
| width="90%" class="mtx-class-propfolder" | SPI Simulation
|-
|-
|-
|-

Latest revision as of 14:37, 13 July 2026

Author Matrix TSL
Version 2.3
Category E-blocks 2


TCP/IP component

A set of routines used to control a ENC28J60 TCP/IP Module. Required connections VCC, Reset, GND, SCK, MISO, MOSI, CS. Leave these pins disconnected CLKOUT, ENC_WOL, ENC_INT

Component Source Code

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

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

Detailed description

No detailed description exists yet for this component

Examples

No additional examples







Macro reference

ControlLEDs

ControlLEDs
Allows both the LEDs on the Ethernet socket to be controlled. Useful for checking if the SPI communications are functioning correctly. 
- BYTE Mode
0=Off, 1=On, 2=Auto 
- VOID Return


CreateIPSocket

CreateIPSocket
 
- 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_Setup

DHCP_Setup
 
- BYTE Return


DNS_Lookup

DNS_Lookup
Resolve the URL into an IP address via the DNS server. Returns non-zero if successful 
- STRING URL
URL address string 
- BYTE IP
Returned IPv4 address 
- BYTE Return


GetLocalIP

GetLocalIP
Gets the local IP address 
- BYTE IP
4-byte Array to store the IP address 
- VOID Return


GetLocalMAC

GetLocalMAC
Gets the local MAC address 
- BYTE MAC
6-byte Array to store the MAC address 
- VOID Return


Initialise

Initialise
Initialises the SPI connection to the TCPIP module and sets up some initial values. Flashes the LEDs on and off twice to confirm SPI comms are active. LEDs are then configured to auto functionality. 
- VOID Return


ReadRegister

ReadRegister
Reads the value from a single register onboard the ENC28J60 module. 
- BYTE Address
 
- BYTE Return


RxDataAvailable

RxDataAvailable
Check if data has been received. A non-zero return value indicates that data is available. This macro should be called regularly as it also processess supporting network traffic. 
- 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


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
 
- 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


RxStart

RxStart
Move the received buffer read pointer back to the start 
- BYTE Channel
 
- VOID Return


SetDestination

SetDestination
This is used in IP and UDP modes to set the destination of the intended data transfer. 
- BYTE Channel
Specifies the communications channel 0-3 
- BYTE IP
 
- UINT 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


SetLocalIP

SetLocalIP
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


SetMACAddress

SetMACAddress
Allows the MAC Address specified in the component properties to be overridden. The MAC Address will revert back to the MAC specified in the component properties as part of the initialise macro. 
- BYTE MAC0
MAC Address Parameter 
- BYTE MAC1
MAC Address Parameter 
- BYTE MAC2
MAC Address Parameter 
- BYTE MAC3
MAC Address Parameter 
- BYTE MAC4
MAC Address Parameter 
- BYTE MAC5
MAC Address Parameter 
- 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


TCP_Close

TCP_Close
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 Return


TCP_Connect

TCP_Connect
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). 
- STRING URL
URL or IPv4 address 
- UINT Dst_Port
Destination Port 
- BYTE 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


TxSendByte

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. 
- 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
 
- 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


WriteRegister

WriteRegister
Writes a value to a single register onboard the ENC28J60 module. 
- BYTE Address
 
- BYTE Data
 
- VOID Return


Property reference

Properties
TCP IP Specifics
Server Port
Sets the server's TCP/IP port address which is used to filter incoming TCP packets. 
Buffer Size
Number of bytes to use for the transmit and receive buffer, we actually use this +1 to allow for a null termination. 8-bit PICs should set this to 255 to allow compilation to succeed. Other devices can have larger buffers. Default = 500 
SPI Settings
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.  
Reset Pin
 
LED Flash
When enabled the socket LEDs will flash on/off 500ms. Useful for SPI check. 
Auto DHCP
When enabled the Initialisation will also include DHCP setup to auto configure settings.  
MAC Address
MAC0
 
MAC1
 
MAC2
 
MAC3
 
MAC4
 
MAC5
 
IP Address
IP0
 
IP1
 
IP2
 
IP3
 
Gateway IP
Gateway0
 
Gateway1
 
Gateway2
 
Gateway3
 
Subnet Mask
Subnet0
 
Subnet1
 
Subnet2
 
Subnet3
 
Simulation
Label
 
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. 
SPI Simulation
Scope Traces
Selects if the scope traces are automatically generated or not 
Console Data
Selects if the console data is automatically generated or not 
API