advertisement
from the engineering department...
Visual basic: port number
Communications systems and equipment. topic
Posted by doronk on 16 September, 2009 - 4:54 am
Hi,

I'm not visual basic programmer, but I need to solve problem that the former programmer had left behind.

Some background about my system:
The PC has VB program.
The VB (running over XP operation system) communicates through USB to RS232 and communicates with electronic board.

I found out the when the XP allocate port number more then (estimation) 16, the VB program have problem to communicate with the board. (The problem disappears when the XP allocate port number less then 16).

* Is VB can handle port number that have high number (like com 45 etc')? and how...

* Can I force the XP to automatic allocate port number less then specific value?

Thanks
Doron


Posted by Robert Scott on 16 September, 2009 - 8:50 am
I assume you are talking about the COM port number assigned to the virtual COM port established by the USB-serial converter module.

No, you cannot force XP to use a lower COM port number if all the lower COM port numbers have been assigned to other drivers.

But here is how I was able to specify an arbitrary COM port number in a C++ program. Instead of COM45, for example, call it out as:

\\.\COM45

Or, if Visual Basic treats\as an escape character, you have to double them up:

\\\\.\\COM45

Robert Scott
Real-Time Specialties
Embedded Systems Consulting


Posted by Yeasir Rahul on 17 September, 2009 - 2:14 am
Answers to your questions:

1. VB6 comes with an ActiveX control named MSCOMM which will not recognize any comm port above COM16.

2. You cannot enforce XP to assign any particular port id to the virtual comm ports, if lower ids are already taken.

Observations:

It seems that you have too many virtual serial ports in your system. Please, check if you have installed multiple drivers of USB based serial ports. Remove the unnecessary drivers. This may solve your problem right now.

If you really need many serial ports in the computer (forty-six seems way too many), then use a serial IO card that sits on your motherboard, not on your USB port.
Comtrol has such cards:

http://www.comtrol.com

If you have the source code of your original VB6 program, then you can use MCScomm control (from MCS electronics). It has many desirable features over the default MSCOMM control. And it supports many serial ports. Their site is:

http://www.mcselec.com/index.php?option=com_docman&task=doc_det ails&gid=151&Itemid=54

The suggestion of using "\\.\COM46" as port name is not applicable to your VB6 program. Because usual VB6 programs use MSCOMM, that doesn't access serial ports as "files". MCScomm does that, however.

Regards
Yeasir Rahul
http://www.voltsmith.com

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2010 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.


Fortune
Optimization hinders evolution.
Advertise here
advertisements
Control.com is the largest Automation community on the web. Learn how to advertise here now...
Servo, stepping motor control, analog & web HMI in one system!
Learn from those who do, and become the expert today. Training Levels 1, 2, and 3 are available. Register Now!
Servo, steppers, analog, digital & web HMI - Fully Integrated!
Time to incorporate data handling, web HMI and motion in one system!
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive