Comm port init

Comm port init

Postby pawelu » Sat Apr 15, 2006 3:26 pm

Antonio,

It's possible in FWPPC initiate comm port eg. baud=9600, parity=e, data=8, stop=1 before send data to port ?

Thanks
Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby Antonio Linares » Sat Apr 15, 2006 3:48 pm

Pawel,

You have to use the Windows API SetCommState() function.
regards, saludos

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

Postby Raymond Fischbach » Wed May 10, 2006 9:55 am

Antonio Linares wrote:Pawel,

You have to use the Windows API SetCommState() function.


Hello Antonio,

Could you please give us a small example on how to do it?
Where can I find doc on these functions?

Sorry for these basic questions but this is my first approach to Api and Dll calls.

Best regards,
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Antonio Linares » Fri May 12, 2006 5:18 pm

This is a sample:
Code: Select all  Expand view
#include "FWCE.ch"

#define GENERIC_WRITE   0x40000000
#define OPEN_EXISTING   3
#define FILE_ATTRIBUTE_NORMAL 0x00000080

function Main()

   local hComm := CreateFile( "COM1:",; // change the number as needed
                              GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )

   // baud=1200 parity=N data=8 stop=1
   MsgInfo( SetComm( hComm, 1200, .f., 8, 1 ) )

   CloseHandle( hComm )
   
return nil

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

HB_FUNC( SETCOMM )
{
   DCB dcb;
   
   GetCommState( ( HANDLE ) hb_parnl( 1 ), &dcb );
   
   dcb.BaudRate = hb_parnl( 2 );
   dcb.Parity = hb_parl( 3 );
   dcb.ByteSize = hb_parnl( 4 );
   dcb.StopBits = hb_parnl( 5 );
   
   hb_retl( SetCommState( ( HANDLE ) hb_parnl( 1 ), &dcb ) );
}

#pragma ENDDUMP   
regards, saludos

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

Postby Raymond Fischbach » Fri May 12, 2006 6:05 pm

Many thanks Antonio,

I will try it tomorrow.

Best Regards
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Raymond Fischbach » Wed May 17, 2006 9:56 am

Hi Antonio,

I tried it and it works like a charm :D

Many thanks again.
Raymond
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 3 guests