Is possible scan COM1 / COM2 ports with FW or xHarbour and create a log of scanned data thart these ports receive?
If isn´t possible, does anybody know any program that scan com ports and generate a log file?
Thanks a lot
Maurilio
Sniffer (COM ports)
- Maurilio Viana
- Posts: 252
- Joined: Tue Oct 25, 2005 2:48 pm
- Location: Garça/Garza/Heron City - Brazil
- Contact:
// modified fivewn sample to read continuos data from laser diameter reader, you can use a timer to call it .
function fReadPort
local cDcb, lError, nError
cErrCode := space( 16 )
if !( gnComm := OpenComm( 'COM1', 1024, 10 ) ) == 0
if !(BuildCommDcb( "COM1:2400,N,8,1", @cDcb ) .and. SetCommState( @cDcb ) )
nError := GetCommError( gnComm, @cErrCode )
MsgAlert( "Error "+ str( nError ) + CRLF + cErrCode)
RETURN( .f. )
endif
endif
cBlock=space(1024)
nTry=0
do while nTry<50 // can remove this nTry if not applicable
if ( nBytes := readComm( gnComm, @cBlock) ) > 0
msgwait('Got it ... '+str(nTry,5),'',1)
exit
else
nTry++
msgwait('Reading ... '+str(nTry,5),'',1)
endif
enddo
msginfo(cBlock) // can append data into dbf or text log (fwrite) here
if FlushComm( gnComm, 0 ) != 0
nError = GetCommError( gnComm )
Msgwait( 'FlushComm Error:' ,'',.01 )
endif
if ! CloseComm( gnComm )
nError = GetCommError( gnComm )
Msgwait( 'CloseComm Error: ' ,'',.01 )
endif
RETURN( .t. )
function fReadPort
local cDcb, lError, nError
cErrCode := space( 16 )
if !( gnComm := OpenComm( 'COM1', 1024, 10 ) ) == 0
if !(BuildCommDcb( "COM1:2400,N,8,1", @cDcb ) .and. SetCommState( @cDcb ) )
nError := GetCommError( gnComm, @cErrCode )
MsgAlert( "Error "+ str( nError ) + CRLF + cErrCode)
RETURN( .f. )
endif
endif
cBlock=space(1024)
nTry=0
do while nTry<50 // can remove this nTry if not applicable
if ( nBytes := readComm( gnComm, @cBlock) ) > 0
msgwait('Got it ... '+str(nTry,5),'',1)
exit
else
nTry++
msgwait('Reading ... '+str(nTry,5),'',1)
endif
enddo
msginfo(cBlock) // can append data into dbf or text log (fwrite) here
if FlushComm( gnComm, 0 ) != 0
nError = GetCommError( gnComm )
Msgwait( 'FlushComm Error:' ,'',.01 )
endif
if ! CloseComm( gnComm )
nError = GetCommError( gnComm )
Msgwait( 'CloseComm Error: ' ,'',.01 )
endif
RETURN( .t. )
- Maurilio Viana
- Posts: 252
- Joined: Tue Oct 25, 2005 2:48 pm
- Location: Garça/Garza/Heron City - Brazil
- Contact: