Am I doing something wrong ? 
Author Message
 Am I doing something wrong ?

Please tell me if I have made any mistakes in the following program. It
suppose to open COM3 and communicate and close after reply! Thanks to all
the people helping me with my COM problem before, it turns out we have bad
lines, so I had it right all along! COM2 works fine, but I would prefer to
get the modem on COM3, so I don't have to disable the COM2 port

Some code (Baudlatch and the POKEs) were from the Basic Gurus pages. I hope
they are public domain

Thanks in advance. Here's the program (Oh, for QB by the way) :

DECLARE SUB Delay (Td!)
DECLARE SUB KeyScan ()
COMMON SHARED ModemIn$

Cls
POKE &H400, &HE8     'change com1: to com3:

On COM(1) GoSub ComHandler
COM(1) ON

Close #1
Open "COM1:9600,N,8,1,DS0" For Random As #1
BaudNum% = 1
BaseAddr% = &H3F8
OldLSR% = INP(BaseAddr% + 3)
OUT (BaseAddr% + 3), (OldLSR% Or &H80)
OUT (BaseAddr%), (BaudNum% Mod &HFF)
OUT (BaseAddr% + 1), (BaudNum% \ &H100)
OUT (BaseAddr% + 3), OldLSR%

Print #1, "ATZ"
Delay (1.25)
Print #1, "ATS7=45 S0=0 C1"
Delay (1.25)

Do
        Delay (1)
        Print #1, "ATDT33"
        TimeDelay! = Timer + 40
        Do Until Timer > TimeDelay!
                Test = InStr(Right$(ModemIn$, 20), "CONNECT")
                If Test Then
                        Result = -1
                        Exit Do
                End If
                Test = InStr(Right$(ModemIn$, 5), "BUSY")
                If Test Then
                        Result = 0
                        Exit Do
                End If
                Test = InStr(Right$(ModemIn$, 12), "NO DIALTONE")
                If Test Then
                        Result = 0
                        Exit Do
                End If
                Test = InStr(Right$(ModemIn$, 11), "NO CARRIER")
                If Test Then
                        Result = 0
                        Delay (2)
                        Exit Do
                End If
        Loop
Loop Until Result
PLAY "ACDCE"
Print #1, "Hey! We got a connection" + Chr$(13) + Chr$(10)

Done = 0
Do
        KeyScan
        If InStr(Right$(ModemIn$, 4), "Hey back") And Done = 0 Then
                Done = 1
        End If
Loop Until INKEY$ = Chr$(27) Or Done = 1

Rem End Here
Print #1, "~~~+++~~~ATH0^M"
Close 1
POKE &H400, &HF8
Print "Success"
End

ComHandler:
        InStr$ = Input$(Loc(1), #1)
        ModemIn$ = RIGHT$(ModemIn$ + InStr$, 10240)
        PRINT (InStr$);
Return

Sub Delay(Td!)
        TimeDelay! = (Timer + Td!) Mod 86400
        While TimeDelay! > Timer
        Wend
End Sub

Sub KeyScan()
        A$ = INKEY$
        Print #1, A$;
End Sub



Tue, 08 Jan 2002 03:00:00 GMT  
 Am I doing something wrong ?

Quote:

> Please tell me if I have made any mistakes in the following program. It
> suppose to open COM3 and communicate and close after reply! Thanks to all
> the people helping me with my COM problem before, it turns out we have bad
> lines, so I had it right all along! COM2 works fine, but I would prefer to
> get the modem on COM3, so I don't have to disable the COM2 port

> Some code (Baudlatch and the POKEs) were from the Basic Gurus pages. I hope
> they are public domain

> Thanks in advance. Here's the program (Oh, for QB by the way) :

> DECLARE SUB Delay (Td!)
> DECLARE SUB KeyScan ()
> COMMON SHARED ModemIn$

> Cls
> POKE &H400, &HE8     'change com1: to com3:

> On COM(1) GoSub ComHandler
> COM(1) ON

> Close #1
> Open "COM1:9600,N,8,1,DS0" For Random As #1
> BaudNum% = 1
> BaseAddr% = &H3F8

Shouldn't this line refer to the Com3 port address, 3E8?

{The rest omitted}

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Tue, 08 Jan 2002 03:00:00 GMT  
 Am I doing something wrong ?
Vidar,

You need to use DEF SEG = 0 before that POKE! Otherwise,
you're poking right into the middle of BASIC's data
segment.

--Ethan

Quote:
> POKE &H400, &HE8     'change com1: to com3:



Tue, 08 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Am I doing something wrong...??

2. Am I doing something wrong...??

3. Bug in VB.Net or am I doing something wrong? *sigh*

4. form class bug, or am I doing something wrong?

5. Is this a bug or am I doing something wrong?

6. BUG??? or am I doing something wrong...

7. The Speed Of Access//Is it Slow or Am I doing something wrong!!!

8. Is this a memory leak or am I doing something wrong?

9. Are VB4 and MSIE5 incompatible... or am I doing something wrong?

10. Am I doing something wrong when I post here?

11. BUG??? or am I doing something wrong...

12. Missing MTXAS.DLL ? Or am I doing something wrong...

 

 
Powered by phpBB® Forum Software