General programming

Moderators: None (Apply to moderate this forum)
Number of threads: 1641
Number of posts: 2788

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
software and cpu loads Posted by Righteous on 8 Apr 2009 at 3:17 AM
Hiya all recently i have been making a program to read information from my cars ecu in vb 2008 it works via a serial port.....

Now my question is how come other programs can read the same information and process it and display it on the screen with out any cpu load ??

Because the serial data is incoming very fast its running 9600 bps proberly not that fast but for my program to keep up to date with it i have to use a loop basicly constanly reading the serial port which destroys the cpus speed and loads it up i tryed using timers on vb but they only go down to 1 ms !

So basicly how do other programs read that information quick enough with out drawing lots load on the cpu ???? do i need to use a diffrent langauge maybe because vb is not good enough ??

Cheers tom :)
Report
Re: software and cpu loads Posted by Lundin on 8 Apr 2009 at 4:24 AM
Yes, VB is very slow but that isn't the main reason in this case. For tasks like this you need to use multithreading. One main graphics thread and one that handles the communication with hardware.

Multithreading is rather advanced, you need to know the fundamentals of Windows API programming before attempting it.
Report
Re: software and cpu loads Posted by Righteous on 8 Apr 2009 at 4:35 AM
Yea i had used a background thread to constantly read the incoming data but that thread still takes huge amount of cpu resources since its in a constant loop was just wondering, the other software which does similar things must still have this loop but it doesnt use as much cpu recsources which i find confusing lol must be doin it using more effcient code eg not vb
Report
Re: software and cpu loads Posted by anthrax11 on 8 Apr 2009 at 5:01 AM
Instead of constantly polling the port, let the hardware recompose the data. That way you can set an event handler without the need for cpu utilization. This should do the trick: http://msdn.microsoft.com/en-us/library/ms364066.aspx

Moving away from VB is a good idea, though.
Report
Re: software and cpu loads Posted by Righteous on 8 Apr 2009 at 5:36 AM
ok cheers i was using a data recived event before but it was to slow repsonse thats why went to looping ill have a look into it anyways what programing langauge would u recommend then ???
Report
Re: software and cpu loads Posted by anthrax11 on 8 Apr 2009 at 11:51 AM
: what programing langauge would u recommend then ???

C is good for anything that needs to be as fast as possible. I have enough faith left in VB to think that it can handle a simple 9600bps serial connection, but who knows.. If you can't get it running properly, then you could try to use WinAPI directly and in C/C++, if necessary.

http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-vb/47290/ir-on-serial-port-vb-net-2005
http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/4fc63fd0-bf6a-4882-b602-59557a05621c/
Report
Re: software and cpu loads Posted by Righteous on 8 Apr 2009 at 4:36 AM
Yea i had used a background thread to constantly read the incoming data but that thread still takes huge amount of cpu resources since its in a constant loop was just wondering, the other software which does similar things must still have this loop but it doesnt use as much cpu recsources which i find confusing lol must be doin it using more effcient code eg not vb
Report
Re: software and cpu loads Posted by Righteous on 8 Apr 2009 at 4:36 AM
Whoops some how sent that a few times !!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.