Writing and reading to COM ports in Basic/QBasic 
Author Message
 Writing and reading to COM ports in Basic/QBasic

Hi, I am trying to communicate with a control device attached to COM2,
but it is not working.  
My question is this: How does the OPEN COM command in basic know which
address to read/write from/to?  Is there a default, does it read it from
somewhere, or can it be configured with another line of code.  I have
set the address to 2F8 through 2FF via the control panel in win95.

Thks in advance for your help.

An email response would be greatly appreciated.


Devon at Cominco Engineering



Sat, 19 Feb 2000 03:00:00 GMT  
 Writing and reading to COM ports in Basic/QBasic

As I know, QuickBasic reads the port's address from BIOS data area =
(0040:0000).
Also, defaults are:
COM1: address=3D&h3F8, IRQ=3D4
COM2: address=3D&h2F8, IRQ=3D3
Unfortunately, QuickBasic cannot recognize standard COM3 or COM4 ports, =
but it is possible
to use them under the program. Furthermore, if PC has not COM1 port, but =
it has COM2 and/or
COM3 port(s), QuickBasic should assign wrong IRQs to them. In that =
situation it is necessary to
poke correct values in the BIOS data area.
Here is example for COM2/COM3 pair:
  DEF SEG =3D &H40
  POKE 0, &HE8: POKE 1, 3
  POKE 2, &HF8: POKE 3, 2
In this case COM1 is declared on address &h3E8 (original COM3) and COM2 =
is declared on it's
original address.
Furthermore, hardware doesn't allow more than one port using one IRQ. =
That means that if you
have mouse connected on COM1, you can not use COM3 (&h3E8) unless you =
unload the mouse
driver, i.e. release IRQ3.
It is obvious that you have COM2 under win95, so, if you don't have COM1 =
you have assigned wrong
IRQ in BIOS data area. Check resources in control panel->system->ports =
and see which COM
ports you have and do you have IRQ collision (maybe with COM4 or sound =
card).
I don't know how exactly works OPEN COM under Visual Basic, but I =
belleive that VB opens the
port through API and it doesn't use BIOS data area.
Hope this helps.

PS use email in sig for reply.
--=20
Branimir Petrovic, dipl. ing. el.
http://www.iridis.com/bps

Two beer or not two beer...
(Shakesbeer)



Quote:
> Hi, I am trying to communicate with a control device attached to COM2,
> but it is not working. =20
> My question is this: How does the OPEN COM command in basic know which
> address to read/write from/to?  Is there a default, does it read it =
from
> somewhere, or can it be configured with another line of code.  I have
> set the address to 2F8 through 2FF via the control panel in win95.
>=20
> Thks in advance for your help.
>=20
> An email response would be greatly appreciated.
>=20

>=20
> Devon at Cominco Engineering



Sun, 20 Feb 2000 03:00:00 GMT  
 Writing and reading to COM ports in Basic/QBasic

Hi Devon,

Qbasic uses the standard I/O port base address of Com2 (&H2F8) and
interrupt (IRQ 2).  Windows 95 actually "virtualizes" the I/O port and IRQ
for a DOS program, so it doesn't matter to the DOS program what you set in
Control Panel.

If the hardware is working correctly, and there are not conflicts with
other software or hardware, Qbasic should work OK.  What problem are you
seeing?

--
{*filter*} Grier
Author of:  Visual Basic Programmer's Guide to Serial Communications,
ISBN 1-890422-25-8.  Check my homepage at
http://www.*-*-*.com/
to order this book.
Contact me at:
Hard & Software
12962 West Louisiana Avenue
Lakewood, CO  80228
303-986-2179 (voice)
303-986-3143 (fax)



Sun, 20 Feb 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Write/Read COM Port in QBasic

2. reading and writing to COM ports

3. Read/Write to Com Port at 19200 Baud

4. Reading from Com port / writing to database

5. read/write from/to the com port

6. Reading and Writing to com ports????

7. COM-Port (read/write)

8. reading and writing to a port using Visual Basic

9. Reading/Writing from/to parallel port memory addresses with Visual Basic

10. Qbasic: Pre-written INI read/write routines?

11. QBasic & COM Ports

12. How to open a com port in qbasic

 

 
Powered by phpBB® Forum Software