How can i query my modem?

  • Thread starter Thread starter Mota
  • Start date Start date
M

Mota

Hi;
I want to send an AT command (one of a Hayes Command set) to my
modem(installed on Com3)and verify its returned answer,and if the answer is
OK(in ready-to-use condition the answer is ok) ,ask it to dial a
number,using this command:ATDT12345678.
When i use: Open "Com3" For Random As #1 ,a "Device I/O Error" occures,and
in addition,i dont know how to read the returning answer from com3.
Using Windows HyperTerminal,I do this simply and it shows there is no
problem in hardware.
So my problem is to connect to com3 directly and without MSComm Activex
control(that has in turn some limitations in properties and methods),and
reading the answer from it,after sending a command.
Can anyone please help me to do that?
I will be so grateful to you and thank you so much in advance
 
I answered this same question question on 7th April. Did my suggestions
work ?

Copy:

Its fairly tricky to do this without using something like the MsComm
control, but doable.

First you need the right syntax for the Open command:

Open"Com3:" for random as #1 ' you need the colon.

'then all i/o has to be done with Put and Get, 1 byte at a time
'UNTESTED CODE:
Dim ch as byte
Dim k as long
Dim strOut as string
Dim strIn as string

strOut = "ATI" 'Hayes command to return an "OK"

for k = 1 to len(strOut)
ch = asc(mid(strOut,k,1) 'get each character in string
put#1, ,ch 'send out port, note the two commas !
next k

do until ch = 13 'loop waiting for reply, assumes end with a <CR>
Get#1, ,ch
strIn = strIn & chr(ch) 'concat into a string
loop

debug.print strIn 'do whatever with the return

In a working program, of course, you would put all this low level stuff in
subroutines.

Hope this helps.


--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Back
Top