Functions
UDPCommFn_Cyclic
Cyclic function for managing UDP communications. This function internally handles calling UDPCommManage, UDPCommReceive, UDPCommSend.
Parameters
| Direction | Name | Type | Description |
|---|---|---|---|
| In / Out | t | UDPCommMgr_typ* | UDP Comm manager to manage |
| Return | Error | UINT | Returns 0 if okay, returns UDPCOMM_ERR_INVALIDINPUT if invalid input |
Usage
Call this function every scan for a given commMgr instance. It drives the connection state machine and internally calls UDPCommManage, UDPCommReceive, and UDPCommSend, so most applications only need this one call.
UDPCommMgr_typ commMgr;
UINT error;
// Call every scan while UDP communication should be active
error = UDPCommFn_Cyclic(commMgr);
UDPCommManage
Handle the open and close of UDP communication on the local interface.
Parameters
| Direction | Name | Type | Description |
|---|---|---|---|
| In / Out | t | UDPCommMgr_typ* | UDP Comm manager to manage |
| Return | Error | UINT | Returns 0 if okay, returns UDPCOMM_ERR_INVALIDINPUT if invalid input |
Usage
Opens the local socket on commMgr.IN.CFG.LocalInterface when commMgr.IN.CMD.Enable is set, and closes it when Enable is cleared. This is called automatically by UDPCommFn_Cyclic and only needs to be called directly if the manage/receive/send steps are being sequenced manually.
UINT error;
error = UDPCommManage(commMgr);
UDPCommReceive
Handles receiving UDP datagrams.
Parameters
| Direction | Name | Type | Description |
|---|---|---|---|
| In / Out | t | UDPCommMgr_typ* | UDP Comm manager to manage |
| Return | Error | UINT | Returns 0 if okay, returns UDPCOMM_ERR_INVALIDINPUT if invalid input |
Usage
Listens for an incoming datagram and copies it into commMgr.IN.PAR.pReceiveData when one arrives, setting commMgr.OUT.STAT.NewDataAvailable and commMgr.OUT.STAT.ReceivedDataLength. Called automatically by UDPCommFn_Cyclic.
UINT error;
error = UDPCommReceive(commMgr);
UDPCommSend
Handles sending UDP datagrams.
Parameters
| Direction | Name | Type | Description |
|---|---|---|---|
| In / Out | t | UDPCommMgr_typ* | UDP Comm manager to manage |
| Return | Error | UINT | Returns 0 if okay, returns UDPCOMM_ERR_INVALIDINPUT if invalid input |
Usage
Sends commMgr.IN.PAR.SendLength bytes from commMgr.IN.PAR.pSendData to commMgr.IN.CFG.RemoteInterface when commMgr.IN.CMD.Send is set (or continuously if AllowContinuousSend is set). Called automatically by UDPCommFn_Cyclic.
UINT error;
error = UDPCommSend(commMgr);