FlushComm()

FlushComm()

Postby Jeff Barnes » Sat Feb 27, 2010 11:29 pm

Hi,

A while back Antonio helped me get some serial communication issues sorted out with FWPPC.

Basically to get ReadComm() and WriteComm() to work he had me add the following code to the end of my .prg file. I now need the same type of thing for FlushComm().

Code: Select all  Expand view
HB_FUNC( READCOMM )
{
  DWORD dw = 0;
  ReadFile( ( HANDLE ) hb_parnl( 1 ), ( LPVOID ) hb_parc( 2 ), ( DWORD ) hb_parni( 3 ), &dw, NULL );

  hb_retni( ( int ) dw ? dw : -1 );
}

HB_FUNC( WRITECOMM )
{
  DWORD dw = 0;
  WriteFile( (HANDLE ) hb_parnl( 1 ), ( LPVOID ) hb_parc( 2 ), ( DWORD ) hb_parni( 3 ), &dw, NULL );
  hb_retni( ( int ) dw ? dw : -1);
}


I have done some searching and found that the windows API uses PurgeComm in place of FlushComm but I do not know how to set it up as above.

Can someone please help me out on this :?
Thanks,
Jeff Barnes

(FWH 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Jeff Barnes
 
Posts: 920
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: FlushComm()

Postby Antonio Linares » Sun Feb 28, 2010 3:12 pm

Jeff,

Code: Select all  Expand view

HB_FUNC( FLUSHCOMM )
{
  hb_retl( PurgeComm( ( HANDLE ) hb_parnl( 1 ), ( DWORD ) hb_parnl( 2 ) ) );
}
 

The second parameter can be one or a combination of the following values:
http://msdn.microsoft.com/en-us/library/aa363428(VS.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 7 guests