; Query modem parameter using the AT commands
:MAIN
answer
; each AT command is terminated by <CRLF><LINE FEED>
$CR = chr(13)
$NL = chr(10)
; Opens COM1 where the voice modem is expected
; Baud rate is set as 9600
; N81 - No Parity, 8 data bits, 1 Stop bit
if ComOpen("COM1", "9600 N81 none")
; Issue the AT&V command to modem
ComWrite("at&v")
ComWrite($CR)
ComWrite($NL)
; Get the size of data returned by modem
$size = ComReadSize()
; Read the data streamed by the modem
while $size > 0
; Modem is a slow device.
; So wait for 2000 milliseconds for the data to arrive in the port
$buffer = ComReadLine(2000)
display $buffer
log $buffer
Sleep 1000
;See for pending data size to be read
$size = ComReadSize()
endwhile
; Done. Close the port and quit
ComClose()
endif
hangup
goto MAIN
:ONSYSTEMERROR
log $error
hangup
goto MAIN
See also ComOpen(), ComReadSize() ComReadLine(), ComWrite(), ComClose().