Using COM ports above COM1 and COM2.
Using COM ports above COM1 and COM2.
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.
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.
Re: Using COM ports above COM1 and COM2.
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?
Re: Using COM ports above COM1 and COM2.
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.
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.
Re: Using COM ports above COM1 and COM2.
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?
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?
Re: Using COM ports above COM1 and COM2.
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.
Re: Using COM ports above COM1 and COM2.
Thanks phishguy. I don't know exactly when I'll get around to trying it, but I much appreciate the help.
Re: Using COM ports above COM1 and COM2.
Forgot to say thanks to everyone for the help...not just phishguy. Thanks.
Re: Using COM ports above COM1 and COM2.
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.
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.
Re: Using COM ports above COM1 and COM2.
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)
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)
Re: Using COM ports above COM1 and COM2.
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.
Re: Using COM ports above COM1 and COM2.
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
Re: Using COM ports above COM1 and COM2.
Ooops, sorry!. That was a typo in my post. Glad that you figured it out. My post has been corrected.
Re: Using COM ports above COM1 and COM2.
A good safety is always to use:
f = FreeFile
and this just before the opening instruction.
f = FreeFile
and this just before the opening instruction.