Blue tooth port problem.

  • Thread starter Thread starter tclancey
  • Start date Start date
T

tclancey

Hi All.

I have a customer requirement to capture bar code data from a blue tooth
scanner on a PA600 Windows Mobile 5.0 device.

I was getting on ok, the scanner connects and all looks fine until I try to
'get' the data from the associated com port.

I've set up the handler and the code to capture the incoming data is simply:
Dim dat as String = port.ReadLine

This is where I get a load of error info, basically it's a null reference
exception. How can there be a null value if data is being received?

I was getting a different error until I upgraded the CF to SP2, but I can't
remember what the error was.

Someone must have got around this before, any information gratefully
received.

Cheers,
Tull.
 
My first recommendation is to abandon ReadLine. It often leads to flawed
behavior with partial reads, especially on slow serial devices. Use a Read
and look for the end of line yourself.

The Port is open and set to an instance?
 
Hi,

I suggest:

Do not use ReadLine. This will cause a null-reference error if you close
the port before (or while) data are being read. Use ReadExisting, and test
for the terminator.

Make sure that you don't close the port until your application ends -- and
even then, if you use ReadLine you are asking for pain. So...

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Back
Top