Supporting Com3 and Com4 in QBasic 
Author Message
 Supporting Com3 and Com4 in QBasic

Is there any version of plain old vanilla flavoured QBasic that will
support the use of the Com3 and Com4 serial ports?  I have a small
microprocessor board that I want to communicate with using QBasic
programs BUT QBasic does not support Com3 and Com4!

Failing that, is there a way to communicate (input and output from my
PC) using something else?  Some other QBasic command?

Thank you for reading this.

Ron Ciren

Ontario, Canada



Fri, 01 Oct 1999 03:00:00 GMT  
 Supporting Com3 and Com4 in QBasic


Quote:
>Is there any version of plain old vanilla flavoured QBasic that will
>support the use of the Com3 and Com4 serial ports?  I have a small
>microprocessor board that I want to communicate with using QBasic
>programs BUT QBasic does not support Com3 and Com4!

No native support, but you can certainly use them.
Allow me to recite a previous posting of Nick Coons, made to this group:

---------------------------------
        Shouldn't be a problem.  Since QB can only use COM1 and COM2, we are
going to switch the port address of COM1 to that of COM3.  That way,
when we use OPEN "COM1..." in QB, it will REALLY be using COM3.

        Then, we're going to write directly to the port to set the BPS rate.
So it doesn't matter what we open it as since we're just going to change
it right away.  2400 is a good standard rate to use when opening.  

        The following example will open COM3 and lock the port at 115200
(standard for 28.8 and maximum for a serial port, requires 16550 -- but
anyone with a 28.8 better have a 16550):

        DECLARE SUB SetBPS (Port%, BPS&)

        DEF SEG = &40
        POKE &H0, &E8
        DEF SEG

        OPEN "COM1:2400,N,8,1" FOR RANDOM AS #1 LEN = 8192
            SetBPS 3, 115200
            ' Do your modem stuff
        CLOSE #1

        ' we need to put COM1's address back.
        DEF SEG = &H40
        POKE &H0, &F8
        DEF SEG

        END

        SUB SetBPS (Port%, BPS&)
            SELECT CASE Port%
                CASE IS = 1: Port% = &H3F8
                CASE IS = 2: Port% = &H2F8
                CASE IS = 3: Port% = &H3E8
                CASE IS = 4: Port% = &H2E8
            END SELECT
            Div& = 115200 \ BPS&: hi% = Div& \ 256: lo% = Div& AND 255
            OUT Port% + 3, INP(Port% + 3) OR 128
            OUT Port%, lo%
            OUT Port% + 1, hi%
            OUT Port% + 3, INP(Port% + 3) XOR 128
        END SUB

--
Marc van den Dikkenberg
-----------------------
The powerbasic Archives
http://pitel-lnx.ibk.fnt.hvu.nl/~excel/pb.html



Sat, 23 Oct 1999 03:00:00 GMT  
 Supporting Com3 and Com4 in QBasic

Quote:

> Is there any version of plain old vanilla flavoured QBasic that will
> support the use of the Com3 and Com4 serial ports?  I have a small
> microprocessor board that I want to communicate with using QBasic
> programs BUT QBasic does not support Com3 and Com4!

> Failing that, is there a way to communicate (input and output from my
> PC) using something else?  Some other QBasic command?

> Thank you for reading this.

> Ron Ciren

> Ontario, Canada

You could use the INP and OUT commands to access the ports directly.
You'll have to know which ports they use, of course and it's a lot more work than
a simple OPEN but it's possible.

Tom Lake



Sat, 23 Oct 1999 03:00:00 GMT  
 Supporting Com3 and Com4 in QBasic

Quote:

> Is there any version of plain old vanilla flavoured QBasic that will
> support the use of the Com3 and Com4 serial ports?  I have a small
> microprocessor board that I want to communicate with using QBasic
> programs BUT QBasic does not support Com3 and Com4!

You set up your board on com3 or com4, then swap it to either com1 or
com2.
SEG 40 in bios area contains the modem addresses. Starting with 40:00
and 40:01 for com1.  Backward storage is used so when you look at it
with Debug, you will see that the modem address is swapped.  02F8 will
be F802.

Here's how to look at the addresses from basic:

CLS
PRINT "Modem addresses, Com1-Com4"
DEF SEG = &H40
FOR i = 0 TO 7 STEP 2:
PRINT TAB(8); HEX$(PEEK(i)); HEX$(PEEK(i + 1)); " "; : NEXT
DEF SEG  'don't forget this or you will probably crash

Be sure to save your old parameters so you can restore them when you
finish with your board routines.

Just peek value from the com port your board is using, and poke it into
whatever com port you want to use it on.  Reverse the process when you
finish, to restore your addresses.

Quote:

> Ron Ciren

> Ontario, Canada

--
     Delhi, La.,  Gateway to:   Poverty Point  Archaeological Center
     Site of the oldest  pre-historic  civilization in North America



Sat, 23 Oct 1999 03:00:00 GMT  
 Supporting Com3 and Com4 in QBasic

-> >
-> > Is there any version of plain old vanilla flavoured QBasic that will
-> > support the use of the Com3 and Com4 serial ports?  I have a small
-> > microprocessor board that I want to communicate with using QBasic
-> > programs BUT QBasic does not support Com3 and Com4!

-> You set up your board on com3 or com4, then swap it to either com1 or
-> com2.
-> SEG 40 in bios area contains the modem addresses. Starting with 40:00
-> and 40:01 for com1.  Backward storage is used so when you look at it
-> with Debug, you will see that the modem address is swapped.  02F8 will
-> be F802.

-> Here's how to look at the addresses from basic:

-> CLS
-> PRINT "Modem addresses, Com1-Com4"
-> DEF SEG = &H40
-> FOR i = 0 TO 7 STEP 2:
-> PRINT TAB(8); HEX$(PEEK(i)); HEX$(PEEK(i + 1)); " "; : NEXT
-> DEF SEG  'don't forget this or you will probably crash

-> Be sure to save your old parameters so you can restore them when you
-> finish with your board routines.

-> Just peek value from the com port your board is using, and poke it into
-> whatever com port you want to use it on.  Reverse the process when you
-> finish, to restore your addresses.

-> >
-> > Ron Ciren

-> > Ontario, Canada

I think one of the problems with this would be those who have a bios
with sliding positions of comports. With those if it will slide a com3
listing for example into the comport 2 area if no comport 2 existed.
With such a bios it seems that looking at the value would pick up the
wrong comport. This was shown in I believe PCMag awhile back and if I
remember correctly the fix was to pad the position missing.

However I don't think basic would be able to detect this easily and the
user would have to do so manually.

Perry



Sun, 24 Oct 1999 03:00:00 GMT  
 Supporting Com3 and Com4 in QBasic

Quote:

>> Is there any version of plain old vanilla flavoured QBasic that will
>> support the use of the Com3 and Com4 serial ports?
>You set up your board on com3 or com4, then swap it to either com1 or
>com2.

On Tue, 06 May 1997 13:28:16 -0500, Charles Godard

Quote:

>SEG 40 in bios area contains the modem addresses. Starting with 40:00
>and 40:01 for com1.  Backward storage is used so when you look at it
>with Debug, you will see that the modem address is swapped.  02F8 will
>be F802.

>Here's how to look at the addresses from basic:

>CLS
>PRINT "Modem addresses, Com1-Com4"
>DEF SEG = &H40
>FOR i = 0 TO 7 STEP 2:
>PRINT TAB(8); HEX$(PEEK(i)); HEX$(PEEK(i + 1)); " "; : NEXT
>DEF SEG  'don't forget this or you will probably crash

Why not just change the print statement line to:
PRINT TAB(8); HEX$(PEEK(i + 1); HEX$(PEEK(i)); " "; : NEXT
--  
J.W.Dare



Mon, 25 Oct 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Supporting Com3 and Com4 in QBasic

2. PDS (Qbasic 7.1) and com3: & com4:

3. Ports COM3,COM4 in Qbasic.

4. COM3 and COM4 in QuickBasic

5. COM3 & COM4 in Quickbasic

6. Com3 and Com4 from QuickBasic 4.5

7. problem whith com3, com4

8. VBDOS and COM3 & COM4

9. Accessing COM3 and COM4

10. Open COM4 port at 14400bps with QBasic

11. Q: Controlling COM3 w/ QBASIC?

12. Sound Blaster support in QBasic 4.0 - 7.1

 

 
Powered by phpBB® Forum Software