Bluetooth serial port

Bluetooth serial port

Postby Jon Munro » Fri Dec 02, 2005 1:31 am

I need 2-way comms to a Bluetooth 'Flic' scanner (to handle the out of range protocol), but always get a port handle of -1 and no response. For testing I have added a 'read' section to sample program 'bluetoth' using code as earlier posts and am attempting to retrieve each character via Chr(bin2l( ReadByte( hIn ) ) )
The scanner works OK to other programs and also via keyboard wedge s/w.
Antonio, friends, can anyone offer any clues?
thanks
User avatar
Jon Munro
 
Posts: 42
Joined: Sun Oct 09, 2005 11:47 am
Location: Brisbane Australia

Postby Antonio Linares » Fri Dec 02, 2005 12:31 pm

Jon,

We discussed the bluetooth issue here, and finally got it working using CreateFile() function call. Is that the one you are using too ?
regards, saludos

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

Postby Jon Munro » Fri Dec 02, 2005 2:02 pm

Antonio,
Yes, I'm using the same method as used by Jose with the printer and in your 'bluetoth' sample. I have a variant 'blueread' :

// BlueRead
#include "FWCE.ch"
#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
#define OPEN_EXISTING 3
#define FILE_ATTRIBUTE_NORMAL 0x00000080

function Main()

local oWnd
local hOut := CreateFile( "COM2:",GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )

DEFINE WINDOW oWnd TITLE "BlueRead"

@ 2, 2 BUTTON "Read" ;
ACTION ReadText( hOut ) SIZE 80, 20

ACTIVATE WINDOW oWnd

CloseHandle( hOut )

return nil

function ReadText( hOut )

local nChr := 1
local cText := ""
local nLen := 0

msginfo(str(hOut))

do while nChr <> 0
nChr := bin2l( ReadByte( hOut ) )
cText := cText + Chr( nChr )
end do

msginfo( cText )

return nil

The port handle is displayed as -1 and then just blanks. I wondered if anyone has got this running in this mode. I will also need to write a response to the scanner, hence am using 'write' mode. Any help is gratefully received, thanks.
User avatar
Jon Munro
 
Posts: 42
Joined: Sun Oct 09, 2005 11:47 am
Location: Brisbane Australia

Postby Antonio Linares » Fri Dec 02, 2005 2:33 pm

Jon,

Please notice that you should use GENERIC_READ instead of GENERIC_WRITE.
regards, saludos

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

Postby Jon Munro » Mon Dec 05, 2005 12:32 pm

Antonio,
Some progress - after re-booting the emulator and using only COM1 I can get a port handle number like 230603634, which I assume is OK and similar to running on an Intermec 700C. I'm not able to retrieve characters from the buffer though and repeatedly only get asc(156). How should I read from the communication buffer and is it possible to clear it (like Telpathy tp_clearin())?
Thanks for any clues :-)

regards, saludos
User avatar
Jon Munro
 
Posts: 42
Joined: Sun Oct 09, 2005 11:47 am
Location: Brisbane Australia

Postby Jon Munro » Fri Jan 06, 2006 2:58 pm

Notes for newbies on Emulator Serial Ports (MSDN Forums - Device Emulator General 29 Nov 2005)
Serial Port 0: appears inside the emulator as COM1: that apps can use.
Serial Port 1: reserved for WinCE kernel, doesn't have a driver, do not use it. ie 'com2:' is not available.
Serial Port 2: the IRDA port and assigned the name COM3:

I've grafted fragments of FWPPC 'comm.c' into parts of Harbour Telepathy (port by Luiz Rafael Culik Guimaraes) and have a working FWPPC test program that reads from a barcode scanner and can send acks, etc. Nearly there...
Regards and happy and successful 2006 to all :-)
User avatar
Jon Munro
 
Posts: 42
Joined: Sun Oct 09, 2005 11:47 am
Location: Brisbane Australia

I testing all fwppc sources the available and did not run

Postby HATHAL » Fri Jan 06, 2006 5:00 pm

jon
I in need for the contact between the pocket pc from Bluetooth to computer
Sending a file represented or received a file
I testing all fwppc sources the available and did not run
Do there is solution
Best Regards
HATHAL
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Postby Jon Munro » Sat Jan 07, 2006 1:41 pm

Hathal,
Have you considered ActiveSync or other serial comms program with Bluetooth? Possibly less painful. I only need a few basic functions.
regards, saludos
User avatar
Jon Munro
 
Posts: 42
Joined: Sun Oct 09, 2005 11:47 am
Location: Brisbane Australia

Postby HATHAL » Sat Jan 07, 2006 8:14 pm

Jon Munro wrote:Hathal,
Have you considered ActiveSync or other serial comms program with Bluetooth? Possibly less painful. I only need a few basic functions.
regards, saludos

jon
I want function with Fwppc source
Best Regards
HATHAL
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Postby Jon Munro » Sun Jan 08, 2006 3:22 pm

Hathal,
Define a single port with mode 0xC0000000 to get 'read-write'. You may find that 'nChr := bin2l( ReadByte( hIn ) )' will return single characters (as asc value) from data received. 'BillSerialMonitor' (freeware) from www.symcod.com is very useful for testing. Still testing comms functions...
regards
User avatar
Jon Munro
 
Posts: 42
Joined: Sun Oct 09, 2005 11:47 am
Location: Brisbane Australia

Postby Raymond Fischbach » Mon May 01, 2006 7:06 pm

Jon Munro wrote:I've grafted fragments of FWPPC 'comm.c' into parts of Harbour Telepathy (port by Luiz Rafael Culik Guimaraes) and have a working FWPPC test program that reads from a barcode scanner and can send acks, etc. Nearly there...
Regards and happy and successful 2006 to all :-)


Hello Jon,

I need to read a bluetooth GPS receiver from a pocket PC.
Having used the sample code that you posteed earlier, i reach the same point as you were : I get a handle but cannot receive any message.

Could you please share your experience and tell me what I still need to do. A code snippet would be greatly appreciated.

Many thanks in advance.
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Jon Munro » Tue May 02, 2006 12:50 pm

Raymond,
The FWPPC comms functions work well, for example:

#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
#define GENERIC_REWRITE 0xC0000000
#define OPEN_EXISTING 3
#define FILE_ATTRIBUTE_NORMAL 0x00000080
...
...
...
STATIC FUNCTION OPENCOMM( nPort )
// Open port for read/write
local hPort
hPort := CreateFile( "COM"+ltrim(str(nPort))+":",;
GENERIC_REWRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )
if hPort == -1
MSGALERT("Cannot open port")
return -1
endif
Return hPort

...
...
// Read a character from comm port handle hPort
cChr := Chr(ReadByte( hPort ))

...
...
// Write a character to comm port handle hPort
WriteByte( hPort, Asc(cChr))

Please see my other posts on related issues with available ports via the emulator and faults with PPC2003 emulator. Antonio's code is the best! I use it to read and talk to a bluetooth barcode and possibly RFID scanners.
Just one character at a time.
hth
User avatar
Jon Munro
 
Posts: 42
Joined: Sun Oct 09, 2005 11:47 am
Location: Brisbane Australia

Postby Raymond Fischbach » Tue May 02, 2006 1:40 pm

Many thanks, I will give it a try.
I need to read complete messages but I am sure this is not a problem as long as I can read a character.


Best Regards,
Raymond
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Raymond Fischbach » Wed May 10, 2006 9:42 am

Thanks for the info.
Based on it I have been able to get the data from a Btooth GPS.

I still have a problem to get the data from a serial one. I can read the serial GPS but I only get invalid data.

Here is my com port opening :
Code: Select all  Expand view
STATIC FUNCTION OPENCOMM(nPort)
// Ouvrir le port en lecture
LOCAL hPort

hPort := CreateFile( "COM"+ltrim(str(nPort))+":",;
            GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL )
IF hPort == -1
   MSGALERT("Impossible d'ouvrir le port")
ENDIF

RETURN hPort


nPort comtains 8 for a Btooth and 1 or 2 for the serial port.

I wonder if the problem is not due to a bad com port setting (like a bad baud rate).

I could not find the documentation of the "CreateFile" function. Can you tell me where to look ?

Many thanks,
Raymond Fischbach
www.mouches.org
User avatar
Raymond Fischbach
 
Posts: 48
Joined: Sun Oct 30, 2005 9:29 am
Location: Belgium

Postby Enrico Maria Giordano » Wed May 10, 2006 9:44 am

Raymond Fischbach wrote:I could not find the documentation of the "CreateFile" function. Can you tell me where to look ?


On the MSDN.

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


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 3 guests