
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.