Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Blue tooth port problem.

1 view
Skip to first unread message

tclancey

unread,
Apr 14, 2007, 3:36:40 PM4/14/07
to
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.


<ctacke/>

unread,
Apr 14, 2007, 5:04:11 PM4/14/07
to
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?

--
Chris Tacke - Embedded MVP
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--


"tclancey" <tu...@idcodeware.co.uk> wrote in message
news:uJT7Nxsf...@TK2MSFTNGP03.phx.gbl...

Dick Grier

unread,
Apr 16, 2007, 1:43:38 PM4/16/07
to
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.


0 new messages