Using COM ports above COM1 and COM2.

For issues with communication ports, protocols, etc.
Post Reply
fb_099
Posts: 4
Joined: Dec 19, 2011 10:16

Using COM ports above COM1 and COM2.

Post by fb_099 »

I'm trying to use my laptop at work to communicate with various pieces of test equipment over RS232--beginning with a digital multimeter. I wrote a FB program that worked fine using COM1 and COM2, but when I changed to COM4, COM5, etc., it did not work--I kept getting garbage characters sent back from the meter. The program is QB-like code. I'm sorry I don't have the code to show.

I got COM4 and beyond from plugging in a Quatech USB to serial box: this box provides 4 COM ports through one USB connection.

Can anyone suggest some code where I might start? Something that would show how to "set up" COM ports higher than COM3 and provide hints/tips on such COM port use?

Thanks.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Using COM ports above COM1 and COM2.

Post by MichaelW »

Are the serial ports that you can access provided by the USB device, or by the laptop? And doesn’t the USB device require a device driver of some sort?
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Using COM ports above COM1 and COM2.

Post by marcov »

I had some strange problems with USB serial devices. I don't like them, but on a laptop you often have no choice.

I did note that setting the speed in the device manager tabs of the device sometimes helps. I assume most attempt some auto-baud solution that sometimes fails.
fb_099
Posts: 4
Joined: Dec 19, 2011 10:16

Re: Using COM ports above COM1 and COM2.

Post by fb_099 »

I believe the USB ports are provided by the USB device. I believe the needed driver is installed properly and working since, if I go to the Device Manager and look for the COM ports, I see them only after plugging in the USB cable. (Unplug the cable and look via Device Manager and they go away.) The laptop itself only has 3 (I think) COM ports, 1 is a DB9 port, one is an internal modem, one is a IR in/out port. (If there is a 4th COM port, I don't recall what it is. I'm doing this from memory as the laptop is at work.)

I've tried setting the baud rate through the device manager as suggested here, but it doesn't help.

From what I've read, FB is supposed to support "higher" COM ports as long as they're properly configured. If this is true, can someone please direct me to some help/sample code where I might start?
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Re: Using COM ports above COM1 and COM2.

Post by phishguy »

There shouldn't be any problems using higher port numbers. Here is a very simple terminal program example.

Code: Select all

'very simple terminal
Dim a As String

'open com 5 - baud 9600 - no parity - 8 data bits - 1 stop bit
'modem contol lines disabled
Open com "com5:9600,n,8,1,cs0,cd0,ds0,rs" As #1 

Do
    
    While Loc(1) > 0 'checks for characters in com buffer
        Print Input$(Loc(1),1); 'displays the characters
    Wend
    
    a = Inkey 'get key to send
    
    If a <> "" Then
        Print #1,a; 'send character to port
    End If
    
    Sleep 1
    
Loop Until Multikey(01) 'quit on escape character
Last edited by phishguy on Jul 31, 2013 14:21, edited 1 time in total.
fb_099
Posts: 4
Joined: Dec 19, 2011 10:16

Re: Using COM ports above COM1 and COM2.

Post by fb_099 »

Thanks phishguy. I don't know exactly when I'll get around to trying it, but I much appreciate the help.
fb_099
Posts: 4
Joined: Dec 19, 2011 10:16

Re: Using COM ports above COM1 and COM2.

Post by fb_099 »

Forgot to say thanks to everyone for the help...not just phishguy. Thanks.
Cosmic
Posts: 1
Joined: Mar 02, 2013 4:05

Re: Using COM ports above COM1 and COM2.

Post by Cosmic »

If you didn't solve it yet.

That device is supposed to be transparent to the computer and work just like a serial card is installed with the stated ports, even tho it is sitting out there on a USB link. But I would guess the problem is it is a laptop and they do strange stuff, especially when things USB are involved.

So I would try it on another computer, hopefully a desktop. Probably work perfect.

I just had that experience with a wireless mouse and keyboard. Got one cheap on sale, wanted to see how it worked. Tried it on a laptop, complete bummer. Nothing worked right. Easy to assume the new hardware is bad. Put it on an older desktop, worked perfect.

Laptops are just too strange in so many areas. I never use one for anything very serious. Too many strange results.
DamageX
Posts: 130
Joined: Nov 21, 2009 8:42

Re: Using COM ports above COM1 and COM2.

Post by DamageX »

I tried the example program posted by phishguy but it only sends data, never receives it. Any thoughts?

I tried on both a cardbus serial port card and a USB-serial adaptor (FTDI) which are verified to be working with other programs (including hypertrm)
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Re: Using COM ports above COM1 and COM2.

Post by phishguy »

No clue. This test program has always worked for me. Haven't tried it with the latest compiler version though. As a quick test, jump pin 2 to 3 on your serial cable (not hooked up to another device) and see if what you type is returned. If so, you have some issue with what your hooking it up to. Maybe it is baud rate or a required handshake signal is missing. If testing to another PC with HyperTerminal, make sure that handshaking is turned off.
DamageX
Posts: 130
Joined: Nov 21, 2009 8:42

Re: Using COM ports above COM1 and COM2.

Post by DamageX »

I was able to get communication between two PCs by changing this line:

Code: Select all

While Loc(0) > 0 'checks for characters in com buffer

Code: Select all

While Loc(1) > 0 'checks for characters in com buffer
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Re: Using COM ports above COM1 and COM2.

Post by phishguy »

Ooops, sorry!. That was a typo in my post. Glad that you figured it out. My post has been corrected.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Using COM ports above COM1 and COM2.

Post by fxm »

A good safety is always to use:
f = FreeFile
and this just before the opening instruction.
Post Reply