New Problem

If you have a question about the software please ask it here.

Re: New Problem

Postby cncdrive » Sun Feb 12, 2017 3:07 am

I don't think your conclusion is be correct.
I mean I don't know about any possible causes which could cause high CPU usage when a serial port is just opened and in idle.

Isn't it possible that you doing other things in your loop or thread and those things requires CPU time and those things happen more often when you not emitting anything,
because while the writting is happening you blocking the thread, but when you not writting anything then the thread loops more frequent, because the loop finishes faster.

Another idea is that the device you talking to maybe sending requests to communicate when you not transmitting data?
I mean if you've attached a Receive event to the serialport object then it may be loading the CPU too much if the external device sending data very frequently and if you have CPU time consuming code in that event handler which code then works with that data too frequently, for example converting the data and/or writting the data to the GUI somewhere making too frequent updates of screen items.

If you can show your code I would be happy to check to see if I can see any possible problem causes.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: New Problem

Postby Dan911 » Sun Feb 12, 2017 1:42 pm

I'm sure it's no surprise to anyone that you were a 100% correct, by adding a small wait() at end of loop fixed the problem. The Serial Port has no problems without any data being exchanged. I sent TP source code to help debug so hopefully when he's complete he will help me understand why it needed a wait() at end of loop.

Thank You,
Dan
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Re: New Problem

Postby cncdrive » Mon Feb 13, 2017 11:04 pm

Hi Dan,

OK, I'm sure Terry will find the problem for you.
And if you will need any help from me then please just let me know.
cncdrive
Site Admin
 
Posts: 4887
Joined: Tue Aug 12, 2014 11:17 pm

Re: New Problem

Postby Dan911 » Tue Feb 14, 2017 7:01 am

cncdrive wrote:Hi Dan,

OK, I'm sure Terry will find the problem for you.
And if you will need any help from me then please just let me know.


Thanks so much, and you already did help figure out the problem from previous post. I narrowed down the problem to the plugin 25hz loop by eliminating code/Threads and I knew the vars was set in loop and no calculating was happening, and the cpu usage still hit the roof. This is why my inexperience lead me to the Serial Port.

When you posted that its not the Serial Port along with quote below I added a Thread.Sleep to the end of loop and CPU usage dropped from 25% to 0%. Terry later pointed out this was caused by my loop within a loop and it's documented in the UCCNC manual that I now read.

cncdrive wrote:because while the writting is happening you blocking the thread, but when you not writting anything then the thread loops more frequent, because the loop finishes faster.

.
Thanks again for your great support, products and software.

Dan
Dan911
 
Posts: 613
Joined: Mon Oct 31, 2016 1:22 am
Location: USA

Previous

Return to Ask a question from support here

Who is online

Users browsing this forum: Majestic-12 [Bot] and 35 guests