Bugfix Arduino.cs

userHead Denaru 2017-03-14 16:45:52 3284 Views4 Replies
I have build up an Project for controlling an Fan for the LP cooling. All works fine but ...

During the Programming i saw that my Programm did not closed correctly AND had an CPU Usage from about 30% Oo. That was huge for only one 10 second timer

After several debuging i found the Problem.

We declare in C# an new Arduino like " Ardunio arduino = new Arduino();" Ok what now. This class generates in Background an new Thread with the name "processInput()". All fine ^^
But when i looked at this Thread i saw the Problem. Inside we have no Sleeps for the Taskswitching. Thats why we have over 30% CPU Usage.

Here the Fix:

Goto the end of "while (_serialPort.IsOpen)" and insert "Thread.Sleep(10);" inside the while.

Now my Program use 0% of the CPU because we give Windows Time for Taskswitching xD

if any one is interested in an Software controlled FAN based on the CPU Temperatures let me know i can upload all the sources. Currently i plan to include the whole OpenHardware lib.