Sniffer (COM ports)

Sniffer (COM ports)

Postby Maurilio Viana » Thu Apr 27, 2006 10:12 pm

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
User avatar
Maurilio Viana
 
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil

Postby tnhoe » Fri Apr 28, 2006 4:14 am

// 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. )
Regards

Hoe, email: easywin3@yahoo.com
User avatar
tnhoe
 
Posts: 83
Joined: Tue Nov 08, 2005 11:09 am
Location: Malaysia

Postby Maurilio Viana » Fri Apr 28, 2006 8:59 pm

I´ll try it!

Thanks a lot!!!

Regards
Maurilio
User avatar
Maurilio Viana
 
Posts: 252
Joined: Tue Oct 25, 2005 2:48 pm
Location: Garça/Garza/Heron City - Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 64 guests