FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Pocket PC Bluetooth print and Special characters
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bluetooth print and Special characters
Posted: Sat Feb 17, 2007 09:00 AM
Richard,

Could you please try this:
HB_FUNC( WRITE233 ) // hComm --> lOk 
{ 
   DWORD cBytes; 
   unsigned char ch = 233; 
    
   hb_retl( ( BOOL ) WriteFile( ( void * ) hb_parnl( 1 ), &ch, 1, &cBytes, NULL ) ); 
}

Just to check if 233 ascii gets properly printed, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Bluetooth print and Special characters
Posted: Sat Feb 17, 2007 09:20 AM

Antonio

No it is not good

This is the sample i am using (just to check the syntax)

I had to remove the INT RC (compile error)

include "C:\FWPPC\INCLUDE\FWCE.ch"

define GENERIC_READ 0x80000000

define GENERIC_WRITE 0x40000000

define GENERIC_REWRITE 0xC0000000

define OPEN_EXISTING 3

define FILE_ATTRIBUTE_NORMAL 0x00000080

define FILE_FLAG_OVERLAPPED 0x40000000

define WriteByte _WriteByte

function Main()
LOCAL I := 0, ;
CTEXTE := SPACE(30), ;
HOUT

hOut := CreateFile( "COM5:",GENERIC_REWRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )

CTEXTE := "Désignation à suivre €"
SENDTEXT(hout,Ctexte)
CloseHandle( hOut )

RETURN Nil

function SendText( hOut, cText )

local n

for n = 1 to Len( cText )
WriteByte( hOut, Asc( SubStr( cText, n, 1 ) ) )
next

return nil

pragma BEGINDUMP

include <hbapi.h>

include <windows.h>

include <aygshell.h>

HB_FUNC( _WRITEBYTE ) // hComm, nChar --> lOk
{
DWORD cBytes;
unsigned char ch = 233;
// unsigned char ch = ( unsigned char ) hb_parnl( 2 );

hb_retl( ( BOOL ) WriteFile( ( void * ) hb_parnl( 1 ), &ch, 1, &cBytes, NULL ) );
}

pragma ENDDUMP

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bluetooth print and Special characters
Posted: Sat Feb 17, 2007 11:15 AM
Antonio Linares wrote:
HB_FUNC( WRITE233 ) // hComm --> lOk 
{ 
   DWORD cBytes; 
   unsigned char ch = 233; 
    
   hb_retl( ( BOOL ) WriteFile( ( void * ) hb_parnl( 1 ), &ch, 1, &cBytes, NULL ) ); 
}


Why the cast to void *? It should be to HANDLE. But this is surely not the problem.

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bluetooth print and Special characters
Posted: Sat Feb 17, 2007 02:51 PM

Enrico,

From Windows headers: typedef void *HANDLE;

Its quite strange why WriteFile() is not able to manage unsigned chars...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Bluetooth print and Special characters
Posted: Sun Feb 18, 2007 03:40 PM

Antonio

This is from Pocket pc Msdn

Does it make any sense in this case ?

You should note that the lpBuffer parameter of WriteFile is a LPCVOID (typedef for const void *).

That means the lpBuffer parameter is type-agnostic. You could make it point to an array of chars, or you can make it point to an array of WCHARs, an array of ints, array of doubles, array of Matrices, array of FileSystems, array of... you get the idea. The key to telling WriteFile what the data type is, is through the nNumberofBytesToWrite parameter.

If you want to write 2 WCHARs to the stream, the 3rd parameter to WriteFile should be 2*sizeof(WCHAR) (but make sure that the 2 WCHARs are next to each other in memory).

Note, that sending UNICODE across the serial port is only useful if the program on the other side of the port understands UNICODE.

// WriteFile(f, data, lstrlen(data) * sizeof(TCHAR), &bytesWritten, NULL); // RIGHT

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bluetooth print and Special characters
Posted: Sun Feb 18, 2007 06:07 PM

Richard,

It does not make a difference. We are placing an unsigned char into the buffer and WriteFile() should transmit an unsigned char.

Could you try to send the data to a different bluetooth device ? Maybe the difference comes from the receiver

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bluetooth print and Special characters
Posted: Sun Feb 18, 2007 06:08 PM

Richard,

Does that printer work with unicode chars ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Bluetooth print and Special characters
Posted: Sun Feb 18, 2007 07:39 PM

Antonio

The printer is OK There is no setting on it.

When i send the txt file to the printer via windows mobile (send via bluetooth), the printout is OK.

The problem is i the writefile function

Richad

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Bluetooth print and Special characters
Posted: Sun Feb 18, 2007 07:40 PM

I don't have the documentation of the printer available here, but i will take a look at it tomorrow morning.

My guess is "Yes" it takes Unicode, see my previous post.

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Bluetooth print and Special characters
Posted: Mon Feb 19, 2007 02:00 PM

Antonio

The printer works with Unicode

It is a brand new HP Deskjet 460

I tried it also on another BT printer (Epson), same problem.

Looks like we have a problem with accented characters.

I have a work around but can not find the appropriate C code for it. Maybe you can help ?

I want to print a txt file from fwppc by calling the file explorer, send via bluetooth function. This will temporarly fix my problem.

Thanks for the help,

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bluetooth print and Special characters
Posted: Mon Feb 19, 2007 06:46 PM
Richard,

Please try this:
HB_FUNC( WRITE233 ) // hComm --> lOk 
{ 
   DWORD cBytes; 
   WCHAR ch = 233; 
    
   hb_retl( ( BOOL ) WriteFile( ( void * ) hb_parnl( 1 ), &ch, sizeof( ch )
, &cBytes, NULL ) ); 
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Bluetooth print and Special characters
Posted: Tue Feb 20, 2007 07:42 AM

Same result

Bad character printed.

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bluetooth print and Special characters
Posted: Tue Feb 20, 2007 07:46 AM

Are you able to read what exactly comes out of the palmtop?

EMG

Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Bluetooth print and Special characters
Posted: Tue Feb 20, 2007 07:52 AM

Enrico

What do you mean by this ? i do not understand

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bluetooth print and Special characters
Posted: Tue Feb 20, 2007 07:55 AM

Till now you only know that the printer won't print what you expected. It would be useful to know what number(s) really comes out of the palmtop instead.

EMG