Fond a QB prog. for COM 115200 
Author Message
 Fond a QB prog. for COM 115200

Hi !

As I said before I'am not a programmer but I found a program to increase the
speed to 115200. I get it from a friend and I can not find why it does not
start.

First I try to :

DECLARE SUB BaudControl (1,1,28800,ErrCode%)

And when I try to start, QB ask  to put an  " = ". at the end. I only change
the 115200 for 28800 and in the syntax there is no " = " as you can see

Maybe we have to DEFINT or DIM something ?

If we can make this program working, I will show you another samll program
that gives access to COM 3 & 4 with QB45

Here is the prog :

OPEN "COM1:300" FOR RANDOM AS #10
BaudControl(1, 1, 28800, ErrCode%)

SUB BaudControl (Func%, Port%, X.Baud&, ErrCode%) STATIC
   'INPUT: Func%=0  -  return the current baud rate in BAUD
   '       Func%=1  -  set the baud rate from BAUD
   'See the Serial/Parallel Adapter TechRef for details
    baud& = X.Baud&
    ErrCode% = 0
   'the error trapping isn't necessary for most applications.
   'these errors should be found in the debug cycle
    IF (Port% < 1 OR Port% > 2) THEN  'bad port params
      ErrCode% = -1
    ELSEIF baud& < 100 THEN
      ErrCode% = -2
    ELSEIF Func% < 0 OR Func% > 1 THEN  'added error code completes
                                        'trapping
      ErrCode% = -3
    ELSE
      Addr% = &H4F8 - (&H100 * Port%)    ' base address of port reg's
      AddrLCR% = Addr% + 3               ' Line Control Register
      AddrDivLatchLSB% = Addr% + 0       ' Divisor Latch LSB & MSB
      AddrDivLatchMSB% = Addr% + 1       ' Divisor Latch LSB & MSB
      ValLCR% = INP(AddrLCR%)            ' get old LCR value
      OUT AddrLCR%, ValLCR% AND &H7F     ' Disable DLAB to get to inters
      ValInt% = INP(AddrDivLatchMSB%)    ' Get the int enable statuses
      OUT AddrDivLatchMSB%, 0            ' Disable all modem intertupts
      OUT AddrLCR%, ValLCR% OR &H80      ' Enable DLAB to gain access
      SELECT CASE Func%

        CASE 1  'set baud
          Divisor% = 28800 \ baud&       'magic number for baud rate
          MSB = Divisor% \ 256

          LSB = Divisor% MOD 256
          OUT AddrDivLatchMSB%, MSB
          OUT AddrDivLatchLSB%, LSB      ' put out the new baud rate
        CASE 0                           'get the current baud rate
          MSB = INP(AddrDivLatchMSB%)
          LSB = INP(AddrDivLatchLSB%)    'get old baud rate
          Divisor% = MSB * 256 + LSB
          X.Baud& = 28800 / Divisor%
      END SELECT
      OUT AddrLCR%, ValLCR% AND &H7F      'Disable DLAB to get to inters
      OUT AddrDivLatchMSB%, ValInt%       'Replace orig inter values
      OUT AddrLCR%, ValLCR%               'Replace orig LCR values
    END IF
END SUB



Mon, 04 Feb 2002 03:00:00 GMT  
 Fond a QB prog. for COM 115200


Quote:
> Hi !
Salut!!
> As I said before I'am not a programmer but I found a program to
increase the
> speed to 115200. I get it from a friend and I can not find why it
does not
> start.

> First I try to :

> DECLARE SUB BaudControl (1,1,28800,ErrCode%)

This is not how you declare a sub: you only tell the type of the
arguments and the internal name of each of them for the sub...
So, don't try to define the subs by yourself: just delete all DECLAREs
and save the file to another name...
Quote:
> And when I try to start, QB ask  to put an  " = ". at the end. I only
change
> the 115200 for 28800 and in the syntax there is no " = " as you can
see

> Maybe we have to DEFINT or DIM something ?

No, but you pointed the right problem: an integer can go up to 65536/2-1
So, you need a bigger type(long??)
Quote:
> If we can make this program working, I will show you another samll
program
> that gives access to COM 3 & 4 with QB45

Yeah, it's called assembly programming 8)
Quote:
> Here is the prog :

> OPEN "COM1:300" FOR RANDOM AS #10
> BaudControl(1, 1, 28800, ErrCode%)

> SUB BaudControl (Func%, Port%, X.Baud&, ErrCode%) STATIC


out inj the online help
Quote:
>    'INPUT: Func%=0  -  return the current baud rate in BAUD
>    '       Func%=1  -  set the baud rate from BAUD
>    'See the Serial/Parallel Adapter TechRef for details
>     baud& = X.Baud&
>     ErrCode% = 0
>    'the error trapping isn't necessary for most applications.
>    'these errors should be found in the debug cycle
>     IF (Port% < 1 OR Port% > 2) THEN  'bad port params
>       ErrCode% = -1
>     ELSEIF baud& < 100 THEN
>       ErrCode% = -2
>     ELSEIF Func% < 0 OR Func% > 1 THEN  'added error code completes
>                                         'trapping
>       ErrCode% = -3
>     ELSE
>       Addr% = &H4F8 - (&H100 * Port%)    ' base address of port reg's
>       AddrLCR% = Addr% + 3               ' Line Control Register
>       AddrDivLatchLSB% = Addr% + 0       ' Divisor Latch LSB & MSB
>       AddrDivLatchMSB% = Addr% + 1       ' Divisor Latch LSB & MSB
>       ValLCR% = INP(AddrLCR%)            ' get old LCR value
>       OUT AddrLCR%, ValLCR% AND &H7F     ' Disable DLAB to get to
inters
>       ValInt% = INP(AddrDivLatchMSB%)    ' Get the int enable statuses
>       OUT AddrDivLatchMSB%, 0            ' Disable all modem
intertupts
>       OUT AddrLCR%, ValLCR% OR &H80      ' Enable DLAB to gain access
>       SELECT CASE Func%

>         CASE 1  'set baud
>           Divisor% = 28800 \ baud&       'magic number for baud rate
>           MSB = Divisor% \ 256

>           LSB = Divisor% MOD 256
>           OUT AddrDivLatchMSB%, MSB
>           OUT AddrDivLatchLSB%, LSB      ' put out the new baud rate
>         CASE 0                           'get the current baud rate
>           MSB = INP(AddrDivLatchMSB%)
>           LSB = INP(AddrDivLatchLSB%)    'get old baud rate
>           Divisor% = MSB * 256 + LSB
>           X.Baud& = 28800 / Divisor%
>       END SELECT
>       OUT AddrLCR%, ValLCR% AND &H7F      'Disable DLAB to get to
inters
>       OUT AddrDivLatchMSB%, ValInt%       'Replace orig inter values
>       OUT AddrLCR%, ValLCR%               'Replace orig LCR values
>     END IF
> END SUB

Ow... A sub is a SUBPROGRAM: it does not return a value... a function
does

The programmer doesn't seem to know that: it uses ErrCode% to return an
error code that will never be returned...
I mean, why would you want to getan error code as an argument???
I don't get it! 8)

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Tue, 05 Feb 2002 03:00:00 GMT  
 Fond a QB prog. for COM 115200

writes:

Quote:
>As I said before I'am not a programmer but I found a program to increase the
>speed to 115200. I get it from a friend and I can not find why it does not
>start.

>First I try to :

>DECLARE SUB BaudControl (1,1,28800,ErrCode%)

>And when I try to start, QB ask  to put an  " = ". at the end. I only change
>the 115200 for 28800 and in the syntax there is no " = " as you can see

When you DECLARE a SUB your parameters ( the stuff inside
the parentheses) must be variables, not numbers.  The IDE won't
let you type it in as shown. From the rest of the code you show,
the syntax would be:

DECLARE SUB BaudControl (func%, port%, X.Baud&, ErrCode%)

OPEN "COM1:300" FOR RANDOM AS #10
BaudControl(1, 1, 28800, ErrCode%)

SUB BaudControl (Func%, Port%, X.Baud&, ErrCode%) STATIC
   'INPUT: Func%=0  -  return the current baud rate in BAUD
     ....

etc.
     ....

HTH
Mike A.



Tue, 05 Feb 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Exiting a QB prog with errorlevels

2. Detecting prog run from QB IDE?

3. Need advice on getting out of prog to a .com file

4. qbasic Com prog Question

5. COM objects on ASP communicating with running prog

6. Can MSComm32.ocx support baud rates to 115,200 ?

7. A QB SUB for OPEN COM 1,2,3,4

8. QB com port followup

9. QB com port modes & commmands

10. Com port speed and QB

11. USE COM 1-4 up to 115200bps in qb 4.5, qbpsd, and vbdos

 

 
Powered by phpBB® Forum Software