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

From Flowcode Help
Jump to navigationJump to search
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

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


CreateIPSocket

Fc9-comp-macro.png CreateIPSocket
 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Protocol
Specifies which IP protocol to use 
Fc9-u8-icon.png - BYTE Broadcast
Allows broadcast type packets to be sent and received 
Fc9-u8-icon.png - BYTE Return


CreateMACSocket

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


CreateTCPSocket

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


CreateUDPSocket

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


DHCP_Setup

Fc9-comp-macro.png DHCP_Setup
 
Fc9-u8-icon.png - BYTE Return


DNS_Lookup

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


GetLocalIP

Fc9-comp-macro.png GetLocalIP
Gets the local IP address 
Fc9-u8-icon.png - BYTE IP
4-byte Array to store the IP address 
Fc9-void-icon.png - VOID Return


GetLocalMAC

Fc9-comp-macro.png GetLocalMAC
Gets the local MAC address 
Fc9-u8-icon.png - BYTE MAC
6-byte Array to store the MAC address 
Fc9-void-icon.png - VOID Return


Initialise

Fc9-comp-macro.png 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. 
Fc9-void-icon.png - VOID Return


ReadRegister

Fc9-comp-macro.png ReadRegister
Reads the value from a single register onboard the ENC28J60 module. 
Fc9-u8-icon.png - BYTE Address
 
Fc9-u8-icon.png - BYTE Return


RxDataAvailable

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxDataSize

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


RxFlushData

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


RxMatchMyIP

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxMatchMyMAC

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxMatch_2_Bytes

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Byte1
Specifies the value of the first byte 
Fc9-u8-icon.png - BYTE Byte2
Specifies the value of the second byte 
Fc9-u8-icon.png - BYTE Return


RxMatch_4_Bytes

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Byte1
Specifies the value of the first byte 
Fc9-u8-icon.png - BYTE Byte2
Specifies the value of the second byte 
Fc9-u8-icon.png - BYTE Byte3
Specifies the value of the third byte 
Fc9-u8-icon.png - BYTE Byte4
Specifies the value of the fourth byte 
Fc9-u8-icon.png - BYTE Return


RxMatch_6_Bytes

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Byte1
Specifies the value of the first byte 
Fc9-u8-icon.png - BYTE Byte2
Specifies the value of the second byte 
Fc9-u8-icon.png - BYTE Byte3
Specifies the value of the third byte 
Fc9-u8-icon.png - BYTE Byte4
Specifies the value of the fourth byte 
Fc9-u8-icon.png - BYTE Byte5
Specifies the value of the fifth byte 
Fc9-u8-icon.png - BYTE Byte6
Specifies the value of the sixth byte 
Fc9-u8-icon.png - BYTE Return


RxReadByte

Fc9-comp-macro.png 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  
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Return


RxReadHeader

Fc9-comp-macro.png 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  
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Idx
Specifies the byte index to return 
Fc9-u8-icon.png - BYTE Return


RxReadString

Fc9-comp-macro.png 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  
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Length
 
Fc9-string-icon.png - STRING Return


RxSkipBytes

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Count
Specifies how many bytes to skip 
Fc9-void-icon.png - VOID Return


RxStart

Fc9-comp-macro.png RxStart
Move the received buffer read pointer back to the start 
Fc9-u8-icon.png - BYTE Channel
 
Fc9-void-icon.png - VOID Return


SetDestination

Fc9-comp-macro.png SetDestination
This is used in IP and UDP modes to set the destination of the intended data transfer. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE IP
 
Fc9-u16-icon.png - UINT Port
Destination Port 
Fc9-u8-icon.png - BYTE Return


SetGateway

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE IP0
First Byte of IP address 
Fc9-u8-icon.png - BYTE IP1
Second Byte of IP address 
Fc9-u8-icon.png - BYTE IP2
Third Byte of IP address 
Fc9-u8-icon.png - BYTE IP3
Fourth Byte of IP address 
Fc9-void-icon.png - VOID Return


SetLocalIP

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE IP0
First Byte of IP address 
Fc9-u8-icon.png - BYTE IP1
Second Byte of IP address 
Fc9-u8-icon.png - BYTE IP2
Third Byte of IP address 
Fc9-u8-icon.png - BYTE IP3
Fourth Byte of IP address 
Fc9-void-icon.png - VOID Return


SetMACAddress

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE MAC0
MAC Address Parameter 
Fc9-u8-icon.png - BYTE MAC1
MAC Address Parameter 
Fc9-u8-icon.png - BYTE MAC2
MAC Address Parameter 
Fc9-u8-icon.png - BYTE MAC3
MAC Address Parameter 
Fc9-u8-icon.png - BYTE MAC4
MAC Address Parameter 
Fc9-u8-icon.png - BYTE MAC5
MAC Address Parameter 
Fc9-void-icon.png - VOID Return


SetSubnetMask

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE IP0
First Byte of IP address 
Fc9-u8-icon.png - BYTE IP1
Second Byte of IP address 
Fc9-u8-icon.png - BYTE IP2
Third Byte of IP address 
Fc9-u8-icon.png - BYTE IP3
Fourth Byte of IP address 
Fc9-void-icon.png - VOID Return


TCP_Close

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Return


TCP_Connect

Fc9-comp-macro.png 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). 
Fc9-string-icon.png - STRING URL
URL or IPv4 address 
Fc9-u16-icon.png - UINT Dst_Port
Destination Port 
Fc9-u8-icon.png - BYTE Return


TxEnd

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


TxSendByte

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-u8-icon.png - BYTE Data
Data byte to append to Tx buffer. 
Fc9-void-icon.png - VOID Return


TxSendMyIP

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


TxSendMyMAC

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


TxSendString

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


TxStart

Fc9-comp-macro.png 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. 
Fc9-u8-icon.png - BYTE Channel
Specifies the communications channel 0-3 
Fc9-void-icon.png - VOID Return


WriteRegister

Fc9-comp-macro.png WriteRegister
Writes a value to a single register onboard the ENC28J60 module. 
Fc9-u8-icon.png - BYTE Address
 
Fc9-u8-icon.png - BYTE Data
 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-conn-icon.png TCP IP Specifics
Fc9-type-21-icon.png Server Port
Sets the server's TCP/IP port address which is used to filter incoming TCP packets. 
Fc9-type-21-icon.png 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 
Fc9-conn-icon.png SPI Settings
Fc9-type-16-icon.png Channel
SPI Channel selector 
Fc9-type-16-icon.png Prescale
Prescale option selector 
Fc9-type-5-icon.png MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
Fc9-type-5-icon.png MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
Fc9-type-5-icon.png CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
Fc9-type-5-icon.png 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.  
Fc9-type-5-icon.png Reset Pin
 
Fc9-type-16-icon.png LED Flash
When enabled the socket LEDs will flash on/off 500ms. Useful for SPI check. 
Fc9-type-16-icon.png Auto DHCP
When enabled the Initialisation will also include DHCP setup to auto configure settings.  
Fc9-conn-icon.png MAC Address
Fc9-type-21-icon.png MAC0
 
Fc9-type-21-icon.png MAC1
 
Fc9-type-21-icon.png MAC2
 
Fc9-type-21-icon.png MAC3
 
Fc9-type-21-icon.png MAC4
 
Fc9-type-21-icon.png MAC5
 
Fc9-conn-icon.png IP Address
Fc9-type-21-icon.png IP0
 
Fc9-type-21-icon.png IP1
 
Fc9-type-21-icon.png IP2
 
Fc9-type-21-icon.png IP3
 
Fc9-conn-icon.png Gateway IP
Fc9-type-14-icon.png Gateway0
 
Fc9-type-14-icon.png Gateway1
 
Fc9-type-14-icon.png Gateway2
 
Fc9-type-14-icon.png Gateway3
 
Fc9-conn-icon.png Subnet Mask
Fc9-type-14-icon.png Subnet0
 
Fc9-type-14-icon.png Subnet1
 
Fc9-type-14-icon.png Subnet2
 
Fc9-type-14-icon.png Subnet3
 
Fc9-conn-icon.png Simulation
Fc9-type-10-icon.png Label
 
Fc9-type-16-icon.png 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. 
Fc9-conn-icon.png SPI Simulation
Fc9-type-7-icon.png Scope Traces
Selects if the scope traces are automatically generated or not 
Fc9-type-7-icon.png Console Data
Selects if the console data is automatically generated or not 
Fc9-type-16-icon.png API