#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
static far BYTE bChar[] = "0123456789ABCDEF";
HB_FUNC( STR2HEX )
{
LONG wHex = 0, w = 0;
LONG wLen = hb_parclen( 1 );
if( wLen > 0 )
{
char * pBuffer = ( char * ) hb_xgrab( wLen );
char * pBufferHex = ( char * ) hb_xgrab( wLen * 2 );
BYTE bByte ;
memcpy( pBuffer, hb_parc( 1 ), wLen );
while( w < wLen )
{
bByte = pBuffer[ w++ ] ;
pBufferHex[ wHex++ ] = bChar[ bByte / 16 ];
pBufferHex[ wHex++ ] = bChar[ bByte % 16 ];
}
hb_retclen( pBufferHex, wLen * 2 );
hb_xfree( pBuffer );
hb_xfree( pBufferHex );
}
else
hb_retclen( "", 0 );
}
HB_FUNC( HEX2STR )
{
LONG wHex = 0, w = 0;
LONG wLen = hb_parclen( 1 );
if( wLen > 0 )
{
char * pBuffer = ( char * ) hb_xgrab( wLen );
char * pBufferStr = ( char * ) hb_xgrab( wLen / 2 );
BYTE b1 ;
BYTE b2 ;
memcpy( pBuffer, hb_parc( 1 ), wLen );
while( w < wLen )
{
b1 = pBuffer[ w++ ] ;
if( b1 < 65 )
b1 = b1 - 48; // number 0..9
else
if( b1 > 96 )
b1 = b1 - 87; // lower case lettre a..f
else
b1 = b1 - 55; // capital letter A..F
b2 = pBuffer[ w++ ] ;
if( b2 < 65 )
b2 = b2 - 48; // number 0..9
else
if( b2 > 96 )
b2 = b2 - 87; // lower case lettre a..f
else
b2 = b2 - 55; // capital letter A..F
pBufferStr[ wHex++ ] = b1 * 16 + b2 ;
}
hb_retclen( pBufferStr, wLen / 2 );
hb_xfree( pBuffer );
hb_xfree( pBufferStr );
}
else
hb_retclen( "", 0 );
}
static LONG power( LONG nBase, LONG nPower )
{
LONG n = 0, nResult = 1;
while( n++ < nPower )
nResult *= nBase;
return nResult;
}
HB_FUNC( HEXTODEC ) // ( cHexNumber ) --> nDecNumber
{
char * pString = hb_parc( 1 );
LONG w = 0, wLen = hb_parclen( 1 );
BYTE bChar;
LONG nHex = 0;
while( w < wLen )
{
bChar = pString[ w ] ;
if ( bChar >= 97 ) bChar -= 39; // lowercase
if ( bChar >= 65 ) bChar -= 7 ; // uppercase
bChar -= 48;
nHex += bChar * power( 16, wLen - w - 1 );
w++;
}
hb_retnl( nHex );
}
#pragma ENDDUMP
FiveCEC.lib(COMM.obj) : error LNK2019: unresolved external symbol BuildCommDCB referenced in function HB_FUN_BUILDCOMMDCB
FiveCEC.lib(COMM.obj) : error LNK2019: unresolved external symbol GetOverlappedResult referenced in function listenThread
test.exe : fatal error LNK1120: 2 unresolved externals
BuildCommDcb( "COM4:9600,n,8,1", @cDcb )
MemoWrit( "myDCB.txt", cDcb )
Compiling...
Harbour 1.0.1dev Intl. (Rev. 9361)
Copyright (c) 1999-2008, http://www.harbour-project.org/
Compiling 'nn9560.prg' and generating preprocessed output to 'nn9560.ppo'...
Lines 2093, Functions/Procedures 8
Generating C source output to 'nn9560.c'... Done.
Microsoft (R) C/C++ Optimizing Compiler Version 12.20.9615 for ARM
Copyright (C) Microsoft Corp 1984-2002. All rights reserved.
nn9560.c
FiveCEC.lib(COMM.obj) : error LNK2019: unresolved external symbol BuildCommDCB r
eferenced in function HB_FUN_BUILDCOMMDCB
FiveCEC.lib(COMM.obj) : error LNK2019: unresolved external symbol GetOverlappedR
esult referenced in function listenThread
nn9560.exe : fatal error LNK1120: 2 unresolved externals
* Linking errors *
//#include "Fivewin.ch"
#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
STATIC oMainWnd
Function Main()
Define window oMainWnd title "TEST NN9560"
Activate window oMainWnd on init Connect() VALID QUITAPP()
Return nil
Function Connect()
Local oFontTime, oFopntBig, oFontNorm, oFontMed, oFontSmall
PRIVATE cSat, cHR, cSatMin, cSatMax, cHRMin, cHRMax, lFirstRun := .t., cDataread
PRIVATE oTimerWalk, oDlg1, oBtn1Stop, oSay1, oSay2
DEFINE FONT oFontTime NAME "ARIAL" SIZE 9, 18 BOLD
ACTIVATE FONT oFontTime
DEFINE FONT oFontBig NAME "ARIAL" SIZE 50, 75 BOLD
ACTIVATE FONT oFontBig
DEFINE FONT oFontNorm NAME "ARIAL" SIZE 15, 25 BOLD
ACTIVATE FONT oFontNorm
DEFINE FONT oFontMed NAME "ARIAL" SIZE 7, 14 BOLD
ACTIVATE FONT oFontMed
DEFINE FONT oFontSmall NAME "ARIAL" SIZE 5, 10 BOLD
ACTIVATE FONT oFontSmall
cSat := "Turn on oximeter"
cHR := "** ** "
cSatMin := "---"
cSatMax := "---"
cHRMin := "---"
cHRMax := "---"
DEFINE DIALOG oDlg1 FROM 5,0 TO 31, 45 TITLE "Test" COLOR RGB(0,0,0),RGB(230,225,172) STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION) of oMainWnd
@ 8,10 BUTTON oBtn1Stop PROMPT "ABORT" SIZE 50,25 of oDlg1 FONT oFontSmall Action (lLoop:=.f., oDlg1:End())
@ 5,1 say oSay1 VAR alltrim(cSat)+" sat " SIZE 360,50 FONT oFontMed of oDlg1 UPDATE COLOR RGB(0,0,0),RGB(230,225,172)
@ 5,21 say oSay2 VAR alltrim(cHr )+" hr " SIZE 360,50 FONT oFontMed of oDlg1 UPDATE COLOR RGB(0,0,0),RGB(230,225,172)
if lFirstrun
DEFINE TIMER oTimerWalk interval 500 ACTION CollectStart(oDlg1)
ACTIVATE TIMER oTimerWalk
endif
ACTIVATE DIALOG oDlg1 CENTER
RETURN NIL
Function CollectStart( oDlg1 )
if ! empty( oTimerWalk )
oTimerWalk:Deactivate()
endif
lFirstRun := .t.
// WinExec("\EzSat\DLL\SetComm4.bat",0)
nComm:= OpenComm( 4, 9600,0,8,1,.f. )
cDataread := space(1)
Do while Alltrim(STR(HexToDec( Str2Hex( cSat )))) <> "6"
syswait(.1)
ComSend( nComm, HEX2STR("027002020803"))
cSat := ComRead( nComm , 8)
// cSat = STR(HexToDec( Str2Hex( cDataread )))
oDlg1:Update()
Enddo
lLoop := .t.
DataRead := ""
lconnect := .f.
nData := 1
cData := ""
cPrevData := 0
use \ezsatbt\oxdata
go top
zap
do while lLoop = .t.
Memory(-1)
SysRefresh()
cDataRead := ComRead( nComm , 8)
if cDataRead <> 0
oDlg1:Update()
nData := HexToDec( Str2Hex( cDataread ) )
if cData = "SAT"
OxData->SAT := STR(nData)
cData := "XXX"
cSat := ALLTRIM(STR(nData))
endif
if cData = "HR"
APPEND BLANK
OxData->HR := STR(nData)
cData := "SAT"
cHR := ALLTRIM(STR(nData))
endif
If nData >= 128
cData := "HR"
ENDIF
endif
SysWait(.01)
lLoop := lLoop
Memory(-1)
oDlg1:Update()
enddo
ComClose( nComm )
Return Nil
Function Quitapp()
quit
Return .t.
////////////////////////////////////////////////////////////////////////////////////////////////////
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("Failed to open "+ cComm)
Return -1
ENDIF
IF lIRMode
IF !RAWIRON( hComm )
Msginfo( "Failed to Start RAWIR")
ComClose( hComm )
RETURN -1
ENDIF
ENDIF
IF !SetComm( hComm, nBauds, nParity, nDataByt, nStopBits )
MsgInfo("Failed to configure "+ cComm)
ComClose( hComm )
RETURN -1
ENDIF
RETURN hComm
Function ComRead( nHdlCom, nChars )
LOCAL nBytes, cBuffIn := Space(BUFF_IN)
nBytes := ReadComm( nHdlCom, @cBuffIn, nChars )
RETURN if( nBytes >0, Left( cBuffIn, nBytes ),"" )
Function ComSend( hComm, cString )
LOCAL nBytesend, nBytes:= Len( cString )
nByteSend := WriteComm( hComm, @cString, nBytes )
Return ( nByteSend == nBytes )
FUNCTION ComClose( hComm )
RAWIROFF( hComm )
CloseHandle( hComm )
RETURN .t.
//////////////////////////////////////////////////////////////////////////////////////////////
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <winbase.h>
#include <aygshell.h>
static far BYTE bChar[] = "0123456789ABCDEF";
HB_FUNC( STR2HEX )
{
LONG wHex = 0, w = 0;
LONG wLen = hb_parclen( 1 );
if( wLen > 0 )
{
char * pBuffer = ( char * ) hb_xgrab( wLen );
char * pBufferHex = ( char * ) hb_xgrab( wLen * 2 );
BYTE bByte ;
memcpy( pBuffer, hb_parc( 1 ), wLen );
while( w < wLen )
{
bByte = pBuffer[ w++ ] ;
pBufferHex[ wHex++ ] = bChar[ bByte / 16 ];
pBufferHex[ wHex++ ] = bChar[ bByte % 16 ];
}
hb_retclen( pBufferHex, wLen * 2 );
hb_xfree( pBuffer );
hb_xfree( pBufferHex );
}
else
hb_retclen( "", 0 );
}
HB_FUNC( HEX2STR )
{
LONG wHex = 0, w = 0;
LONG wLen = hb_parclen( 1 );
if( wLen > 0 )
{
char * pBuffer = ( char * ) hb_xgrab( wLen );
char * pBufferStr = ( char * ) hb_xgrab( wLen / 2 );
BYTE b1 ;
BYTE b2 ;
memcpy( pBuffer, hb_parc( 1 ), wLen );
while( w < wLen )
{
b1 = pBuffer[ w++ ] ;
if( b1 < 65 )
b1 = b1 - 48; // number 0..9
else
if( b1 > 96 )
b1 = b1 - 87; // lower case lettre a..f
else
b1 = b1 - 55; // capital letter A..F
b2 = pBuffer[ w++ ] ;
if( b2 < 65 )
b2 = b2 - 48; // number 0..9
else
if( b2 > 96 )
b2 = b2 - 87; // lower case lettre a..f
else
b2 = b2 - 55; // capital letter A..F
pBufferStr[ wHex++ ] = b1 * 16 + b2 ;
}
hb_retclen( pBufferStr, wLen / 2 );
hb_xfree( pBuffer );
hb_xfree( pBufferStr );
}
else
hb_retclen( "", 0 );
}
static LONG power( LONG nBase, LONG nPower )
{
LONG n = 0, nResult = 1;
while( n++ < nPower )
nResult *= nBase;
return nResult;
}
HB_FUNC( HEXTODEC ) // ( cHexNumber ) --> nDecNumber
{
char * pString = hb_parc( 1 );
LONG w = 0, wLen = hb_parclen( 1 );
BYTE bChar;
LONG nHex = 0;
while( w < wLen )
{
bChar = pString[ w ] ;
if ( bChar >= 97 ) bChar -= 39; // lowercase
if ( bChar >= 65 ) bChar -= 7 ; // uppercase
bChar -= 48;
nHex += bChar * power( 16, wLen - w - 1 );
w++;
}
hb_retnl( nHex );
}
HB_FUNC( SETCOMM )
{
DCB dcb;
COMMTIMEOUTS timeouts;
SetupComm(( HANDLE) hb_parnl( 1 ), 1024, 1024 ) ;
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( RAWIRON )
{
hb_retl( EscapeCommFunction( ( HANDLE ) hb_parnl( 1 ), SETIR ) );
}
HB_FUNC( RAWIROFF )
{
hb_retl( EscapeCommFunction( ( HANDLE ) hb_parnl( 1 ), CLRIR ) );
}
#pragma ENDDUMP
@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
Jeff,
Windows Mobile does not provide a function BuildCommDCB(). But we could use a replacement for it, as it just fills a DCB structure:
http://msdn.microsoft.com/en-us/library/aa363143(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa363214(VS.85).aspx
Are you always going to call BuildCommDCB() with the same parameters ? If yes, then you could generate the cDCB string from FWH and use it with FWPPC:
In FWH:
- Code: Select all Expand view
BuildCommDcb( "COM4:9600,n,8,1", @cDcb )
MemoWrit( "myDCB.txt", cDcb )
BOOL BuildCommDCB( LPCTSTR lpDef, LPDCB lpDCB )
{
return FALSE;
}
BOOL GetOverlappedResult( HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait )
{
return FALSE;
}
#pragma ENDDUMP
ComSend( hComm, Hex2Str("027002020803"))
Return to FiveWin for Pocket PC
Users browsing this forum: No registered users and 9 guests