
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