FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Serial port
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Serial port
Posted: Tue Apr 21, 2009 04:33 PM
Hi,

I want to open a COM4 port and want to send
Code (fw): Select all Collapse
++++.ATH0.ATZ.$10110000B8CF9D.


Than I have to wait for
Code (fw): Select all Collapse
$0511



I try with this code
Code (fw): Select all Collapse
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
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 109
Joined: Sun Nov 13, 2005 12:40 AM
Re: Serial port
Posted: Tue Apr 28, 2009 05:30 AM

if ! SetCommState( nComm, cDcb )

'cDcb' function check SetCommState.

FWH User

FWPPC User

FWLinux User

Continue the discussion