First FWPPC App - Help :-)

First FWPPC App - Help :-)

Postby Jeff Barnes » Wed Jan 07, 2009 1:45 pm

Hi Everybody,

I am working on my first FWPPC app :-)


I have tested everything in FWH to make sure my code is good.

Then I changed the include from Fivewin.ch to FWCE.ch and build via the BuildCE.bat

I get the following errors:

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 1887, Functions/Procedures 4
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
NN9560.obj : error LNK2001: unresolved external symbol HB_FUN_HEX2STR
NN9560.obj : error LNK2001: unresolved external symbol HB_FUN_STR2HEX
NN9560.obj : error LNK2001: unresolved external symbol HB_FUN_HEXTODEC
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: 5 unresolved externals
Linking errors *


I tried looking at the \fwppc\manual section but it looks like it is the same manual as FWH.

Can you point me in the right direction.

The code I am playing with is below (very rough … just testing a new device)



Thanks
Jeff





#include "FWCE.ch"

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., cDCB, 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( "Com4", 1024, 128 )
Syswait(.01)
if ! BuildCommDcb( "COM4:9600,n,8,1", @cDcb )
lLoop := .f.
oDlg1:End()
RETURN NIL
endif
if ! SetCommState( nComm, cDcb )
lLoop := .f.
oDlg1:End()
RETURN NIL
endif
if FlushComm( nComm, 1 ) != 0
nError = GetCommError( nComm )
MsgInfo( "FlushComm Error: " + Str( nError ) )
endif

cDataread := space(1)
Do while Alltrim(STR(HexToDec( Str2Hex( cDataread )))) <> "6"
syswait(.1)
WRITECOMM( nComm, HEX2STR("027002020803"))
ReadComm( nComm , @cDataRead)
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()
if ReadComm( nComm , @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


if FlushComm( nComm, 1 ) != 0
nError = GetCommError( nComm )
MsgInfo( "FlushComm Error: " + Str( nError ) )
endif
if ! CloseComm( nComm )
nError = GetCommError( nComm )
MsgInfo( "CloseComm Error: " + Str( nError ) )
endif
Return Nil


Function Quitapp()
quit
Return .t.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Wed Jan 07, 2009 8:41 pm

Jeff,

We are testing your PRG to provide you our answer asap :-)
regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Wed Jan 07, 2009 11:16 pm

Jeff,

Please add this code to the bottom of your PRG. This solves these three unresolved externals: STR2HEX(), HEX2STR() and HEXTODEC().

Code: Select all  Expand view  RUN
#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

We will include this code in the next FWPPC build. Now we just have these functions to solve:
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
regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Jeff Barnes » Thu Jan 08, 2009 2:38 am

Thanks Antonio. I will wait you your reply...

Is there a manual just for FWPPC ??
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Thu Jan 08, 2009 8:44 am

Jeff,

Except for some missing Windows Mobile features like MDI windows, the taskbar, etc. Windows Mobile behaves quite similar to Windows for PC, so the same FWH manual is valid for FWPPC.

As FWPPC is evolving quickly, is good to review FWPPC\include\FWCE.ch to see what commands clauses are supported for FWPPC, but our target is to make it as much compatible with FWH as possible.

Anyhow, we are building a more specific documentation here:
http://wiki.fivetechsoft.com/doku.php?i ... umentation
regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Thu Jan 08, 2009 11:15 am

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  RUN
BuildCommDcb( "COM4:9600,n,8,1", @cDcb )
MemoWrit( "myDCB.txt", cDcb )
regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Thu Jan 08, 2009 11:17 am

Jeff,

With FWPPC we provide a samples\TestComm.prg that may be usefull for you.

Please review it and see if it may do what you need, thanks
regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Jeff Barnes » Fri Jan 09, 2009 2:23 am

Antonio,

Thanks for all the info. I am going to try an play with it this weekend.
I will let you know how it goes.

All I really need to do is open the com port, send and read data strings.
After a quick look at the TestComm.prg sample ... it looks like it has the functions I need.

An initial question about TestComm.prg:

In OpenCom() there is a setting or "liRMode" ... this one is new to me, can you give me a bit on info on this one.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Fri Jan 09, 2009 12:24 pm

Jeff,

> In OpenCom() there is a setting or "liRMode" ... this one is new to me, can you give me a bit on info on this one.

If I am not wrong, it stands for InfraRed mode.
regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Jeff Barnes » Sat Jan 10, 2009 2:59 am

I have made some changes in the test app to use the connection functions in TestComm.prg (code below).
The strange thing is I still get the error for BuildCommDbc and GetOverLappedResult.

Here is the error I get now when I try to build the file...
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 *



Code: Select all  Expand view  RUN
//#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


Just in case, here is the BuildCE.bat file I am using. I had to make some minor changes for paths etc to get it to build the initial test (tutor01.prg)
Code: Select all  Expand view  RUN
@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



Any Ideas?
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Sat Jan 10, 2009 6:55 am

Jeff,

As I have commented you on a previous post, BuildCommDCB() is not available in Windows Mobile. Microsoft does not provide it. But we can implement a replacement for it as it just fills a DCB structure:
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  RUN
BuildCommDcb( "COM4:9600,n,8,1", @cDcb )
MemoWrit( "myDCB.txt", cDcb )

regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Jeff Barnes » Sat Jan 10, 2009 9:28 pm

Antonio,

Please take a look at the code in my last post ... I do not make any calls to BuildCommDCB().
This is why I am confused.

I only used the functions that were used in TestComm.prg

If I compile TestComm.prg I do not get the BuildCommDBC or GetOverLappedResult errors.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Sat Jan 10, 2009 9:45 pm

Jeff,

Please insert these lines at the bottom of your code, just before the final #pragma
Code: Select all  Expand view  RUN
BOOL BuildCommDCB( LPCTSTR lpDef, LPDCB lpDCB )
{
   return FALSE;
}

BOOL GetOverlappedResult( HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait )
{
   return FALSE;
}

#pragma ENDDUMP
regards, saludos

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

Re: First FWPPC App - Help :-)

Postby Jeff Barnes » Sun Jan 11, 2009 1:38 am

Thanks Antonio. I can now compile the program.

Still issues with sending data to the comm port though.

It seems to completely lock up when I issue this command:

Code: Select all  Expand view  RUN
ComSend( hComm, Hex2Str("027002020803"))
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: First FWPPC App - Help :-)

Postby Antonio Linares » Sun Jan 11, 2009 7:04 am

Jeff,

What Windows Mobile emulator version are you using ? The one that we provide ?

We provide the WM2003 as it is light and fast, but if you use the WM 6.1 one, then you can open a console (msdos alike) window that is specifically usefull to trace serial communications, use OutputDebugString(), etc.

http://www.microsoft.com/downloads/deta ... laylang=en
regards, saludos

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

Next

Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 4 guests