473,382 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

.Net CF 2.0 SerialPort DataReceived

Hi all,

I'm writing a PocketPC / CE application which communicates with a
Bluetooth GPS reciever that is paired to a serial port but I'm
experiencing odd behaviour from the CF 2.0 SerialPort class.

Everything is fine first time around, but if I quit my application and
restart a few times, pretty soon (usuaully the second or third
restart) the DataReceived event stops firing on the SerialPort object.

I'm connecting with this code:-

_comPort = new SerialPort(comPortName, comBaud, comParity,
comDataBits, comStopBits);

_comPort.Encoding = Encoding.ASCII;
_comPort.Handshake = comHandshake;
_comPort.ReceivedBytesThreshold = 1;
_comPort.DataReceived += new
SerialDataReceivedEventHandler(DataReceived);
_comPort.Open();

My DataReceived handler contains the following code:-

string newData = _comPort.ReadExisting();

When the app exits, I'm disconnecting / closing with:-

if (_comPort != null)
{
if (_comPort.IsOpen) _comPort.Close();

_comPort.Dispose();
_comPort = null;
}

Everything works fine on the first run, but after a couple of restarts
DataReceived stops firing. Any ideas?

Many TIA,

Simon

Jun 8 '07 #1
7 3925
hi Simon,

sorry. it is not about the topic but do you have any gps data parser
written in c#?

Jun 8 '07 #2
There's a free one here:
http://www.opennetcf.com/sharedsource/serial.ocf
--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com


"Hakan Fatih YILDIRIM" <hf*********@gmail.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
hi Simon,

sorry. it is not about the topic but do you have any gps data parser
written in c#?

Jun 8 '07 #3
Hi,

I also have one written in C# in my book (see below) -- it isn't quite free,
but there is other code that you might find to be useful, too.

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.
Jun 9 '07 #4

"Dick Grier" <dick_grierNOSPAM@.msn.comschrieb im Newsbeitrag
news:ef**************@TK2MSFTNGP03.phx.gbl...
Hi,

I also have one written in C# in my book (see below) -- it isn't quite
free,
but there is other code that you might find to be useful, too.

Dick

Hi Dick,

did in your book are some code for Compactframwork ?
bye
Rainer
Jun 9 '07 #5
In this business I'd say the price of a book is free or even net positive,
as you gain way more than $50 if you learn much of anything from it.
--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
"Dick Grier" <dick_grierNOSPAM@.msn.comwrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
Hi,

I also have one written in C# in my book (see below) -- it isn't quite
free, but there is other code that you might find to be useful, too.

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.

Jun 9 '07 #6
Hi,

Yes, Chapter 9 covers serial communications using the Compact Framework.

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.
Jun 11 '07 #7
On Jun 8, 10:49 pm, Hakan Fatih YILDIRIM <hfysilis...@gmail.com>
wrote:
hi Simon,

sorry. it is not about the topic but do you have any gps data parser
written in c#?
I do, yes, but parsing the NMEA data is the interesting bit. Unless
you're *really* pushed for time, forget copy/paste development and
roll your own. There's pretty much everything you need on the
following page:-

http://www.kh-gps.de/nmea-faq.htm

Jun 13 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: LordHog | last post by:
Hello all, I would like to use the new SerialPort class in Visual C++ 2005 Express edition, but I am having problems adding my event handler to the DataReceived event. In the header file I have...
2
by: Andrea Judge | last post by:
Hi there, I'm developing an application to catch OBD sensors' data from my car. I connect it via a RS232 interface. Now. with HyperTerminal I can connect and send/receive data, but I'd like to...
0
by: no-one | last post by:
Hi Guys, I am fairly new to Dot Net and I am trying to write a program that listens to the serial port and displays the string in a text box or listbox. I am using VS 2005 and framework 2.0 ...
0
by: Tony Kwong | last post by:
I am using my mobile phone as modem to send some SMS using modem AT commands and have the SerialPort.DataReceived to get the "reply" from the Port using "m_SerialPort.ReadExisting();" private...
5
by: herbert | last post by:
back in 1978 (!) the VAX/VMS serial line driver offered everything a developer needs to develop protocols of all kinds: - read x bytes - read to end of line - read to special character - read...
4
by: Jamie Risk | last post by:
I'm trying to implement a protocol that has a concept of a GAP timer in the serial stream; if two properly framed characters are spaced in time by so many milliseconds or longer, there is an...
3
by: Jamie Risk | last post by:
What thread does the DataReceived event run on? I'm preparing a design that uses the DataReceived event to stimulate a protocol state machine (PSM). The ambition is to have the serial process...
0
by: =?Utf-8?B?TGVuIFdlbHRtYW4=?= | last post by:
I've created MySerialPort, which inherits from SerialPort, and want to set an internal flag when DataReceived is signalled. If I were firing the event myself, it would be a simple matter of flag...
0
by: cronusf | last post by:
I set up two virtual COM ports 3 and 4 using com0com. I tried to test it with the following program. However, the DataReceived event handlers never get called. Can anyone with SerialPort class...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.