Bluetooth print and Special characters

Postby Antonio Linares » Sat Feb 17, 2007 9:00 am

Richard,

Could you please try this:
Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41468
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Richard Chidiak » Sat Feb 17, 2007 9: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Enrico Maria Giordano » Sat Feb 17, 2007 11:15 am

Antonio Linares wrote:
Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8417
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Sat Feb 17, 2007 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41468
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Richard Chidiak » Sun Feb 18, 2007 3: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Antonio Linares » Sun Feb 18, 2007 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41468
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Feb 18, 2007 6:08 pm

Richard,

Does that printer work with unicode chars ?
regards, saludos

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

Postby Richard Chidiak » Sun Feb 18, 2007 7: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Richard Chidiak » Sun Feb 18, 2007 7: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Richard Chidiak » Mon Feb 19, 2007 2: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Antonio Linares » Mon Feb 19, 2007 6:46 pm

Richard,

Please try this:
Code: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41468
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Richard Chidiak » Tue Feb 20, 2007 7:42 am

Same result

Bad character printed.

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Enrico Maria Giordano » Tue Feb 20, 2007 7:46 am

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8417
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Richard Chidiak » Tue Feb 20, 2007 7: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
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Enrico Maria Giordano » Tue Feb 20, 2007 7: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
Last edited by Enrico Maria Giordano on Tue Feb 20, 2007 10:54 am, edited 1 time in total.
User avatar
Enrico Maria Giordano
 
Posts: 8417
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 7 guests