Function SerialTest(lIRmode)
local hComm, nChars, cRead
IF (hComm:=OpenCom(1, 9600,,,, lIRmode )) > 0
msginfo("Ok Com1: "+str(hComm) + ", lIRmode:"+if(lIRmode,".t.",".f."))
ComSend( hComm, "hi there" )
msginfo("ComSend(hithere) regreso .T.")
cRead:=ComRead( hComm, nChars )
msginfo("ComRead() regreso: "+cRead+ ",("+alltrim(str(len(cRead)))+" chs)")
//else
msginfo("ComSend(hithere) regreso .FALSO.")
//ENDIF
ComClose( hComm )
msginfo("puerto cerrado")
ENDIF
Return Nil
function SendBytes( hComm, cString )
local n
for n = 1 to Len( cString )
ComSend( hComm, SubStr( cString, n, 1 ) )
// a SysRefresh() call could be needed here
next
return nil // Len( cString )
Function ComSend( hComm, cString )
LOCAL nBytesend, nBytes:= Len( cString )
nByteSend := WriteComm( hComm, @cString, nBytes )
Return ( nByteSend == nBytes )
@ECHO OFF
CLS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ FiveWin for Pocket PC - October 2008 Harbour development power ³Ü
ECHO ³ (c) FiveTech, 1993-2008 for Microsoft Windows Pocket PC ³Û
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ECHO ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST
ECHO Compiling...
IF "%FWDIR%" == "" set FWDIR="c:\fwppc"
set hdir=c:\harbour_ce\
set hdirc=%hdir%\bin
set hdirl=%hdir%\lib
set fwppc=%FWDIR%
set vcdir=c:\vce
set include=%vcdir%\include\arm;%hdir%\include;%include%
set lib=%vcdir%\lib;%hdir%\lib;%lib%
set emulator_shared_folder=c:\pocketpc
%hdirc%\harbour %1 /n /i%fwppc%\include;%hdir%\include /p %2 %3 > clip.log
IF ERRORLEVEL 1 GOTO COMPILEERROR
@type clip.log
%vcdir%\bin\clarm -W3 -c /DARM /DUNICODE /I%hdir%\include /I%fwppc%\include %1.c
:ENDCOMPILE
IF EXIST %1.rc %vcdir%\bin\rc -r -d_CE %1
echo %1.obj > msvc.tmp
echo %fwppc%\lib\FiveCE.lib %fwppc%\lib\FiveCEC.lib >> msvc.tmp
echo %hdirl%\hbrtl.lib >> msvc.tmp
echo %hdirl%\hbvm.lib >> msvc.tmp
echo %hdirl%\gtgui.lib >> msvc.tmp
echo %hdirl%\hblang.lib >> msvc.tmp
echo %hdirl%\hbmacro.lib >> msvc.tmp
echo %hdirl%\hbrdd.lib >> msvc.tmp
echo %hdirl%\rddntx.lib >> msvc.tmp
echo %hdirl%\rddcdx.lib >> msvc.tmp
echo %hdirl%\rddfpt.lib >> msvc.tmp
echo %hdirl%\hbsix.lib >> msvc.tmp
echo %hdirl%\hbdebug.lib >> msvc.tmp
echo %hdirl%\hbcommon.lib >> msvc.tmp
echo %hdirl%\hbpp.lib >> msvc.tmp
echo %hdirl%\hbcpage.lib >> msvc.tmp
echo %hdirl%\hbw32.lib >> msvc.tmp
rem echo %hdirl%\tip.lib >> msvc.tmp
echo %hdirl%\hbpcre.lib >> msvc.tmp
echo %vcdir%\lib\arm\coredll.lib >> msvc.tmp
echo %vcdir%\lib\arm\corelibc.lib >> msvc.tmp
echo %vcdir%\lib\arm\aygshell.lib >> msvc.tmp
echo %vcdir%\lib\arm\ws2.lib >> msvc.tmp
echo %vcdir%\lib\arm\mfcce400.lib >> msvc.tmp
echo %vcdir%\lib\arm\ole32.lib >> msvc.tmp
echo %vcdir%\lib\arm\oleaut32.lib >> msvc.tmp
echo %vcdir%\lib\arm\olece400.lib >> msvc.tmp
echo %vcdir%\lib\arm\uuid.lib >> msvc.tmp
echo %vcdir%\lib\arm\ceshell.lib >> msvc.tmp
echo %vcdir%\lib\arm\commctrl.lib >> msvc.tmp
echo %vcdir%\lib\arm\wininet.lib >> msvc.tmp
IF EXIST %1.res echo %1.res >> msvc.tmp
%vcdir%\bin\link @msvc.tmp /nologo /SUBSYSTEM:WINDOWSCE,4.20 /MACHINE:ARM /ARMPADCODE:NO
IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * Application successfully built *
copy %1.exe %emulator_shared_folder%
GOTO EXIT
ECHO
rem delete temporary files
@del %1.c
@del %1.obj
@del %1.ppo
@del msvc.tmp
:COMPILEERROR
@type clip.log
ECHO * Compile errors *
GOTO EXIT
:LINKERROR
ECHO * Linking errors *
GOTO EXIT
:SINTAX
ECHO SYNTAX: Build [Program] {-- No especifiques la extensi¢n PRG
ECHO {-- Don't specify .PRG extension
GOTO EXIT
:NOEXIST
ECHO The specified PRG %1 does not exist
:EXIT
BOOL GetOverlappedResult( HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait )
{
MessageBox( 0, L"Inside GetOverlappedResult", L"Ok", 0 );
return FALSE;
}
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);
}
/////////////////////////////////////////////
//
// Funciones de comunicacion por Rs232
//
////////////////////////////////////////////
#include "Fwce.ch"
#define BUFF_IN 1024
#define BUFF_OUT 1024
#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
#define OPEN_EXISTING 3
#define FILE_ATTRIBUTE_NORMAL 0x00000080
#define NOPARITY 0
#define ODDPARITY 1
#define EVENPARITY 2
#define MARKPARITY 3
#define SPACEPARITY 4
#define ONESTOPBIT 0
#define ONE5STOPBITS 1
#define TWOSTOPBITS 2
///////////////////////////////////////////////
//
// OpenCom
// Abre el puerto especificado y lo configura
//////////////////////////////////////////////
Function OpenCom( nCom, nBauds, nParity, nDataByt, nStopBits, lIRmode )
LOCAL hComm, cComm
DEFAULT nCom := 1, nBauds := 2400, nParity := NOPARITY, nDataByt := 8, lIRmode := .f.
DEFAULT nStopBits := ONESTOPBIT
cComm := "Com"+ AllTrim( Str( nCom, 2 ) )+ ":"
hComm := CreateFile( cComm, nOr(GENERIC_WRITE, GENERIC_READ) , 0, 0, OPEN_EXISTING, 0,0 )
IF hComm ==-1
Msginfo("Fallo al abrir "+ cComm)
Return -1
ENDIF
IF lIRMode
IF !RAWIRON( hComm )
Msginfo( "Fallo al iniciar RAWIR")
ComClose( hComm )
RETURN -1
ENDIF
ENDIF
IF !SetComm( hComm, nBauds, nParity, nDataByt, nStopBits )
MsgInfo("Fallo al configurar "+ cComm)
ComClose( hComm )
RETURN -1
ENDIF
RETURN hComm
///////////////////////////////////
//
// ComSend( nHdlCom, cString )
//
////////////////////////////////////////////
Function ComSend( hComm, cString )
LOCAL nBytesend, nBytes:= Len( cString )
nByteSend := WriteComm( hComm, @cString, nBytes )
Return ( nByteSend == nBytes )
////////////////////////////////////
//
// ComRead( nHdlCom, nChars )
//
////////////////////////////////////////////
Function ComRead( nHdlCom, nChars )
LOCAL nBytes, cBuffIn := Space(BUFF_IN)
nBytes := ReadComm( nHdlCom, @cBuffIn, nChars )
RETURN if( nBytes >0, Left( cBuffIn, nBytes ),"" )
////////////////////////////////////
//
// ComClose( nHdlCom)
//
////////////////////////////////////////////
FUNCTION ComClose( hComm )
RAWIROFF( hComm )
CloseHandle( hComm )
RETURN .t.
#pragma BEGINDUMP
#include <windows.h>
#include <winbase.h>
#include <hbapi.h>
#include <aygshell.h>
HB_FUNC( SETCOMM )
{
DCB dcb;
COMMTIMEOUTS timeouts;
SetupComm(( HANDLE) hb_parnl( 1 ), BUFF_IN, BUFF_OUT ) ;
GetCommState( ( HANDLE ) hb_parnl( 1 ), &dcb );
dcb.BaudRate = hb_parnl( 2 );
dcb.Parity = hb_parni( 3 );
dcb.ByteSize = hb_parni( 4 );
dcb.StopBits = hb_parni( 5 );
dcb.fBinary = TRUE;
dcb.fParity = TRUE;
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fDsrSensitivity = FALSE;
dcb.fTXContinueOnXoff = FALSE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.fErrorChar = FALSE;
dcb.fNull = FALSE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fAbortOnError = FALSE;
GetCommTimeouts(( HANDLE) hb_parnl, &timeouts);
timeouts.ReadIntervalTimeout = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = 1000;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(( HANDLE) hb_parnl( 1 ), &timeouts );
hb_retl(SetCommState( ( HANDLE ) hb_parnl( 1 ), &dcb ));
}
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);
}
HB_FUNC( RAWIRON )
{
hb_retl( EscapeCommFunction( ( HANDLE ) hb_parnl( 1 ), SETIR ) );
}
HB_FUNC( RAWIROFF )
{
hb_retl( EscapeCommFunction( ( HANDLE ) hb_parnl( 1 ), CLRIR ) );
}
#pragma ENDDUMP
Return to FiveWin for Pocket PC
Users browsing this forum: No registered users and 3 guests