6.2 ENet Module: Ethernet TCP/UDP Communication
Using the general-purpose Ethernet port of the Hi6 Controller makes it possible to transmit or receive a string with an external device through Ethernet TCP or UDP communication. It is required to create an ENet object after importing the ENet module to use this function, as shown below.
In the following example, the selection of protocol is needed by passing "udp" or "tcp" as a parameter of the ENet constructor. The default is "udp," so like in the example, it can be omitted when UDP communication is performed.
Communication must be performed in the following order:
Create an ENet object with the constructor.
Set an IP address and port number with the member variable.
Open the communication connection with the open member procedure, and check the state with the state() member variable.
(In the case of TCP communication, the connect procedure should also be performed after opening).
Perform transmission/reception with the send and receive member procedures.
Close the communication connection with the close member procedure.
Last updated
Was this helpful?