I want to open a COM4 port and want to send
- Code: Select all Expand view
- ++++.ATH0.ATZ.$10110000B8CF9D.
Than I have to wait for
- Code: Select all Expand view
- $0511
I try with this code
- Code: Select all Expand view
- function test()
local cDcb, nBytes
local nComm := OpenComm( 'COM4', 2400, 128 )
local nError
msginfo('1')
if ! BuildCommDcb( "COM4:2400,n,8,1", @cDcb )
nError = GetCommError( nComm )
Msgwait( " BuildCommDcb Error: " + Str( nError ),'',.3 )
endif
msginfo('2')
if ! SetCommState( cDcb )
nError = GetCommError( nComm )
Msgwait( "SetCommState Error: " + Str( nError ),'',.3 )
return .t.
endif
msginfo('3')
if ( nBytes := WriteComm( nComm, '++++.ATH0.ATZ.$10110000B8CF9D.') ) < 0
nError = GetCommError( nComm )
Msgwait( "WriteComm Error: " + Str( nError ),'',.1 )
else
Msgwait('Sent !!!',.1 )
endif
msginfo('4')
if FlushComm( nComm, 0 ) != 0
nError = GetCommError( nComm )
Msgwait( " FlushComm Error: " + Str( nError ),'',.01 )
endif
msginfo('5')
if ! CloseComm( nComm )
nError = GetCommError( nComm )
Msgwait( "CloseComm Error: " + Str( nError ),'',.01 )
endif
return nil
But the programs hangs after msginfo('2')
What can there be wrong?
Regards,
Marc