?
Solved

Faster serial port responce in VB6

Posted on 2009-12-29
9
Medium Priority
?
284 Views
Last Modified: 2012-05-08
I have run into an issue with the time it takes my PC to respond to a byte received over the RS232 port. I am communicating with a device over RS-232 at 1200 baud. I am rewriting an application which was written over 10 years ago in C++ for Win95. The original program waits for a 'go ahead' byte from a device and then responds with a byte telling the device what routine to run. The time from the end of the 'go ahead' byte to the start of the PC's response is about 1.5ms. I have tried using the mscomm control in VB6 to no avail. The PC's response takes approximately 35ms, whether I poll the buffer or use the OnComm event. This is too long, the device times out and does not run its routine. Is there any way to get my response out quicker?
0
Comment
Question by:DBad
  • 4
  • 4
9 Comments
 
LVL 41

Expert Comment

by:graye
ID: 26141586
This is kinda an off-topic comment, but....
Why on earth are you writing an application in vb6 in 2009 (soon to be 2010)? !?!?!
... sorry
0
 
LVL 10

Expert Comment

by:3_S
ID: 26142065
I must agree on this.
C++ was always faster than VB, so maybe a rewrite on Visual C++ can do the trick? Is there a special reason why you want to do a rewrite in VB6.  VB6 is getting obsolete. So it would be wise to choose an other programming language to do the rewrite. Any programming language you preferer to do the rewrite? Then I would be happy to help?
I've done a couple of program integrating serial communication.
0
 

Author Comment

by:DBad
ID: 26145631
I'm using VB6 because that is what I know. Sometime this year I plan to learn a newer language to write our software in, but right now we want to add this functionality into a VB6 program I already wrote. If VB6 isn't fast enough, perhaps I can write a small program in another language which is called from my main one, though I've never done anything like that. I have VS2008 on my machine. Any advise on 1, how to get this functionality into my current program, and 2, what language I should start learning?

As far as my next language, I was thinking that C# would be easy to learn, but since that is using .NET it might be slow at RS232 as well, so maybe C++?  We are also interested in the possibility of supporting Macs in the future. I don't know anything about that, but I have discovered Mono for .NET languages, as well as cross platform GUI frameworks which I can use with C++. So it looks like either can be cross-platform. Do you know which option might be easier to make cross platform in the future?

Thank you.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 41

Expert Comment

by:graye
ID: 26146018
Sorry for the snob-ish tone of my original comment...
Yes, C# would be a good language to learn...  however there will be a rather large learning curve, and that takes time.
I would suspect that the performance under C# would be not quite as fast, but comparable to a "native" C/C++ application.  I would also say that it would be faster than VB6 by a large margin.
Recall, that modern PCs don't have descrete UART chips to handle serial I/O... it's just not that important anymore.  So, a lot of the hardware vendors emplement the serial I/O interfaces via emulation.   That might be contributing to the performance isssues you're seeing.
0
 

Author Comment

by:DBad
ID: 26146626
So I assume I should write the RS232 communications routine in C#. I picked up a C# book a while ago, I guess I'll start reading it. Do you have any suggestions on how I can have my VB6 program call it and pass data? If you can point me to some good resources on this topic I would greatly appreciate it.

Also, that is an interesting point about the UART. I didn't know we don't have a hardware UART anymore. It's possible that could explain why the old software responded so much faster despite running it on an old Win98 laptop I dug up just to test it.
0
 
LVL 41

Expert Comment

by:graye
ID: 26148002
Well, i was thinking that you'd write the whole thing in C#... but you certainly can break it up into a C# piece and a VB piece.  Writing a COM-based DLL from C# is fairly straight-forward.
0
 

Author Comment

by:DBad
ID: 26148231
I am planing to rewrite my program in C# eventually, but there are people looking for this feature now, so I'm trying to find a temporary fix.

I've never worked with DLLs before. I checked my C# book and it does not cover that. Can you recommend any good sites or books about writing/using DLLs?
0
 
LVL 41

Accepted Solution

by:
graye earned 2000 total points
ID: 26148738
Well, if you're in a hurry, then I'd recommend that you just stick to what  you're familar with.
One quick solution might be to use the software that you've got now with a dedicated Serial I/O card.  You can probably find one for about $20.
Othewise, take a look at the following:
http://msdn.microsoft.com/en-us/library/3707x96z(VS.80).aspx 
http://www.c-sharpcorner.com/UploadFile/mahesh/dll12222005064058AM/dll.aspx 
0
 

Author Closing Comment

by:DBad
ID: 31670919
That should get me on my way. Thank you for your advice.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question