LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

UDP on realtime target

Hello i'm trying to use UDP to communicate client and host machines. I'm try to execute very simple example

 

 result =CreateUDPChannelConfig(60100, UDP_ANY_ADDRESS, 0, UDPCallback, NULL, &readerChannel);

 

 

 

int CVICALLBACK UDPCallback (unsigned channel, int eventType, int errCode, void *callbackData)
{

int linesCount = 0;
int error = 0,
size;
unsigned char *msg = NULL;
exit(0);
if (eventType == UDP_DATAREADY)
{
char srcAddr[16];
unsigned int srcPort;
char msgSourceString[16 + 10];

// Pass NULL as the input buffer to determine the size of the arrived data.
size = UDPRead(channel, NULL, 0, UDP_DO_NOT_WAIT, NULL, NULL);

msg = malloc(size);

// Read the waiting message into the allocated buffer.
size = UDPRead(channel, msg, size, UDP_DO_NOT_WAIT, &srcPort, srcAddr);

}


return 0;
}

 

 

in any case i have no UDPCallback calings. In other way if i sending packets from realtime target to host machine everything is okay. How can i resolve this problem?

0 Kudos
Message 1 of 2
(2,931 Views)

Hey qmor,

 

How are you registering the callback in the thread? This KnowledgeBase article talks about the UDP callback process for CVI Realtime:

 

http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/libref/cviudp_callback_mechanism/

 

As it says, when the system processes events, if data is available on a port for which a callback has been registered, the callback is called. Would it be possible to see that section of your code?

 

Also, you mentioned an example--are you basing your code on a specific example in CVI Realtime?

 

Thanks,

0 Kudos
Message 2 of 2
(2,922 Views)