LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Geometric position via UDP

Good day, does anyone have experience with sending logs via UDP to a CVI application?

I send one log via UDP 100 times per second and the buttons in the application are stuck (cannot be clicked), if I change the period to 0.05 (20 times per second), they already work normally.

 

Don't know where the problem might be?

 

I use UDPCALLBACK according to the UDP example in CVI.

Even if I delete everything in this function, the buttons also jam.

 

thank you for help

 

0 Kudos
Message 1 of 12
(1,616 Views)

Although I have a problem with another program, here it also makes me "at a speed of sending the log 0.01, the" Send "button does not work and as soon as I stop the program it works for a while.

If I have a value of 0.05 then it works normally.

 

Don't know how to treat it?

porucha.png

0 Kudos
Message 2 of 12
(1,565 Views)

With little or no experience on UDP I can only try guessing what's happening, but normally in case of unresponsiveness of the UI there are too much events to be handled in the UI thread. Considering that UPD callback is synchronous, this is very likely what you are facing at present: as a verification, with less events to handle you gain back UI sensitivity.

 

This problem is usually addressed by splitting the application in independent threads, in your case moving all the UDP stuff to a new thread.

 

Another, less efficient alternative is to optimize events handling; based on how you describe your application:

  • If you are logging to screen: are you sure you need to write down all the messages? I wonder which operator is able to discriminate something in a list that updates 100 times/sec!
  • If you are logging to file, keep the file open: do not open/close the file at 100 Hz

I know these tips are very generic and others may better suit your needs, but with very little details on the application I cannot give you more than this. Consider them as a conceptual framework to start with.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 12
(1,558 Views)

Hello Roberto,

thank you for the answer, i thought UDPCallback is synchronous and can it somehow be converted to asynchronous?

However, it also occurred to me to insert functions into a separate thread, but I still do not know how to implement.

 

Do you know what is special?

If I add the Synchronous timer and set the value to 0.01, the application runs normally with 100 times / sec logs without stuttering.

 

it's probably because it also runs synchronously with UDPcallback.

 

You don't know of an example where functions are used to create a separate thread.

 

Otherwise, I send logs with GPS from the company Novatel, which is able to send logs up to 200 times per second.

 

I apologize for my English.

 

Thank you

0 Kudos
Message 4 of 12
(1,554 Views)

When coming to multithreading you have a set of resources to address. On one hand, the online help comes with a full chapter on this argument: you can find it in Creating Applications >> Creating Multithreaded Applications tree section of the help window.

On the other hand, there are a number of examples that you can study: search for them in the Example Finder (Help >> Find Examples... menu function, Search tab and "Thread" keyword). There are examples both for a TCP server and a TCP client that are probably the closest you can find for your actual application. Take your time to look at the other examples too, which can be useful as well.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 12
(1,549 Views)

Great, thank you Roberto, I'll look into it and write here how I proceeded if I came up with a result.

0 Kudos
Message 6 of 12
(1,546 Views)

I tried to throw this program, which is above, into a separate thread, unfortunately I somehow fail. 😞

I can't separate UDPcallback, it probably has to stay there.

 

The example from CVI "MultiThreading.cws" is similar to UDP, but also retains the TCPCallback callback function.

0 Kudos
Message 7 of 12
(1,520 Views)

Well, as I told you I have no experience on UDP but in TCP it is important that the TCP callback is installed in the same thread that connects to the server, and the thread must be processing events for this to work: you can indeed see in MultiThreadingClient example that the thread callback is done this way:

 

/*---------------------------------------------------------------------------*/
/* TCP thread entry-point function.                         				 */
/*---------------------------------------------------------------------------*/
static int CVICALLBACK TCPThreadFunction (void *functionData)
{
	// Connect to the server and install the TCP callback tohandle events
	Connect ();

	//Process events to permit communications
	while (gRunning)
		{
		ProcessSystemEvents ();
		}

	// Disconnect fom the server
	Disconnect ();

	return 0;
}

 

 

In UDP environment things are very likely to work the same way, and this may be one problem for you (at least it was for me when I approached this scenario).



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 12
(1,515 Views)

Thanks for the reply.

I also found this feature, but I don't know how to put UDPcallback into it.

 

So that I should insert the entire UDPcallback function into the body of the "TCPThreadFunction" function?

 

Unfortunately, I don't have much experience with threads.

 

Thank you

0 Kudos
Message 9 of 12
(1,506 Views)

Well, as I told you I have no experience on UDP, but in my opinion if you can replicate the same structure as TCP using UDP functions it should work.

Can you post your code so that we can revise it? At least a minimum version that shows how you have set the system and threading up.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 10 of 12
(1,498 Views)