473,396 Members | 1,921 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,396 software developers and data experts.

GPS Erroring when using the Windows Mobile 6 SDK

20
Hi all (and Mark).

As I have posted a few times the last few weeks about my GPS application, I have got to the point of adding the GPS stuff in. I am using the Windows Mobile 6 SDk and used the Microsoft.WindowsMobile.Samples.Location project code for my project.

Now, the problem is I am getting an error, sometimes straight away (once the GPS is initialised) or during the use of it.

I get an "unexpected" error occuring and the only other information is ArgumentException Parameter Name chars.

Here are the full details of the Exception:
ArgumentException
ArgumentException
Parameter name: chars

at System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, UTF8Encoder encoder)
at System.Text.UTF8Encoding.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, UTF8Encoder encoder)
at System.Text.UTF8Encoding.UTF8Encoder.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at Microsoft.WindowsMobile.Samples.Location.Gps.GetPo sition(TimeSpan maxAge)
at Microsoft.WindowsMobile.Samples.Location.Gps.GetPo sition()
at Microsoft.WindowsMobile.Samples.Location.Gps.WaitF orGpsEvents()

Now, I know it isnt coming from my software as when I am debugging it (not emulator but connected the the WM6 device) it states the symbols cannot be loaded for debug. I am presuming it is something in the included DLL (the Microsoft.WindowsMobile.Samples.Location.dll) from theWindows Mobile 6 SDK.

When I am debugging, I can get the Gps.cs SDK file to show itself (different reason) and it states the DLL it is using compared to the cs file is different. I havent recompiled anything, but wondering if the DLL I am using is NOT the correct one and this error is fixed in a different DLL (Just thinking out loud here and trying to supply all information).

I have seen someone ask the same question in MSDN forums, but he was ignored.

Has anyone (Mark?) had the same error when using the SDK's DLL?

What is strange as it seems the Location Sample works fine. However, I am using the exact same code, in a class, within my application.

Please... Any ideas?

Thanks,
Rob
Jan 25 '10 #1
11 4522
RedSon
5,000 Expert 4TB
You can build and run the sample without any problems? You should compare your project files and see if you have some missing settings that the sample project does not.
Jan 25 '10 #2
rb0135
20
Hi Redson,

Thanks for the reply, but I have exactly the same code as per the example. It is very simple code as most of the work is done by the DLL. (I have double checked).

I have also created a new simple app, with the code from the example and I get the same error. The app doesnt display the values as per the sample (thats the only difference). I just load up a variable with the information, then display it when I push a button.

I actually found all the source in the SDK folder that created the DLL, so I have recompiled the DLL and will test with this DLL.

Rob
Jan 25 '10 #3
RedSon
5,000 Expert 4TB
Right, if it's simple and most of the work is done in the dll but you are having problems. Then the problem is likely in your project setup not your code.
Jan 25 '10 #4
rb0135
20
But, the DLL seems to be throwing the error in the routine when it is getting the information after the GPS event has fired. Would you say that is true (going by the error information provided)???

The app doesnt need to do anything other than call the gps.Open command, so I cant understand why anything in the app could cause this issue.

I will go over my stuff again.

Thanks,
Rob
Jan 25 '10 #5
rb0135
20
Ok, I think I might have found the issue, but as the error occurs randomly (usually within the first 5 minutes of operation), I have my fingers crossed as it has been running for a hour so far.

I found another sample using the same code. The original code (which I thought was from the SDK example, wasnt), had one of the routines (gps_LocationChanged) as public void. Thi other sample I found buried in the SDK folders had the same routine as protected void. I change my definition to protected and as mentioned, it didnt fall over within the first 5-10 minutes.

Here's hoping this was the issue.
Jan 26 '10 #6
RedSon
5,000 Expert 4TB
Oh strange, sometimes you run into those errors that just don't make any sense. Well I'm glad you found it.
Jan 26 '10 #7
rb0135
20
Yep, your right... I still cant see why they would make that much a difference, but I am no expert on this.

It seem to go OK with the test so far...I am not trusting it just yet until I have used the app a fair few more times, but so far, so good.

Thanks,
Rob
Jan 26 '10 #8
rb0135
20
Ok.. spoke too soon..

Tried it twice today and it failed the second time.

Tried the MS sample and it fails (just takes longer).

So, it isnt my code after all that (by the looks of it)...

Any ideas to check?

Thanks,
Rob
Jan 29 '10 #9
RedSon
5,000 Expert 4TB
Time to post your code....

Use [code] tags, or make a zip file, or use a paste bin.
Jan 29 '10 #10
rb0135
20
Redson,

Thanks for trying to help, and it would be easy if your saw the code, but are you following that ALL the code, and where the error is occuring is in the MS SDK Sample Code.

All I do is:

Expand|Select|Wrap|Line Numbers
  1. using Microsoft.WindowsMobile.Samples.Location;
  2.  
  3. .....
  4.  
  5. Gps mygps = new Gps();
  6.  
  7.  
I then setup the handlers and open the GPS as per the MS example

Expand|Select|Wrap|Line Numbers
  1.  
  2. mygps.DeviceStateChanged += new DeviceStateChangedEventHandler(gps_DeviceStateChanged);
  3. mygpsLocationChanged += new LocationChangedEventHandler(gps_LocationChanged);
  4. mygps.Open();
  5.  
The handlers are coded as such (I update some variables in these routines)

Expand|Select|Wrap|Line Numbers
  1.  
  2. public void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args)
  3.         {
  4.             GpsDeviceState device = args.DeviceState;
  5.  
  6.             _GPSStatus = device.DeviceState.ToString();
  7.             _GPSDeviceName = device.FriendlyName;
  8.             _GPSDeviceState = device.DeviceState.ToString();
  9.             _GPSServiceState = device.ServiceState.ToString();
  10.         }
  11.  
  12. public void gps_LocationChanged(object sender, LocationChangedEventArgs args)
  13.         {
  14.             GpsPosition position = args.Position;
  15.  
  16.             if (position.LatitudeValid)
  17.                 _CurrentLatitude = position.Latitude;
  18.             if (position.LongitudeValid)
  19.                 _CurrentLongitude = position.Longitude;
  20.             if (position.HeadingValid)
  21.                 _CurrentHeading = position.Heading;
  22.             if (position.SatellitesInViewCountValid)
  23.                 _Satellites = position.SatellitesInViewCount;
  24.  
  25.         } // End gps_LocationChanged
  26.  
  27.  

Thats all I do.

Regards,
Rob
Feb 4 '10 #11
I have experienced the SDK device error (null exception) that happens at randomn intervals. I think this may be when no satellites are visible. In GetSatellitesInSolution() it does a for loop which references inViewSatellites.Length but if inViewSatellites is null then this would go bang. So I have wrapped this in a null check and so far so good.

I saw this in the code on http://gpstracka.codeplex.com/

Hope this helps...

Code
====
public Satellite[] GetSatellitesInSolution()
{
Satellite[] inViewSatellites = GetSatellitesInView();
ArrayList list = new ArrayList();
for (int index = 0; index < dwSatelliteCount; index++)
{
Satellite found = null;
//check whether any satellites were inView
if (inViewSatellites != null)
{
for (int viewIndex = 0; viewIndex < inViewSatellites.Length && found == null; viewIndex++)
{
if (rgdwSatellitesUsedPRNs[index] == inViewSatellites[viewIndex].Id)
{
found = inViewSatellites[viewIndex];
list.Add(found);
}
}
}
}

return (Satellite[])list.ToArray(typeof(Satellite));
}
Sep 10 '10 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tarren | last post by:
Hi: The problem I am having is when I validate an xml file to a schema, it is erroring out every element. I think this has something to do with me defining/referencing the namespaces. I have...
0
by: Nick White [MSFT] | last post by:
Hello fellow Microsoft Windows Mobile and Embedded enthusiasts: I invite you to peruse the list below of upcoming technical chats and Webcasts offered by the Windows Mobile and Embedded Devices...
4
by: Sacha Korell | last post by:
First of all, sorry for cross-posting, but this newsgroup is much busier than "aspnet.mobile". I'm trying to create a portal page that redirects depending on the device that is connecting. ...
7
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do...
1
by: sakurasyi | last post by:
hi everyone... i have some questions about windows ce. Can anybody tell me, what are the differences between widows ce, windows mobile and posket pc? I have read about windows ce from some...
3
by: Ilkka Maatta | last post by:
I test Opera 8.60 for Windows Mobile, Pocket PC becouse i need JAVA script and sound in my www-page. My mobile PC is Ipaq 3850 / Pocket PC 2003 and browser is Opera 8.60 for Windows Mobile,...
1
by: Sharky Ward | last post by:
We have a C# windows mobile form application designed for PockedtPC 2003 developed in VS2003.NET with .NET 1.0/1.1. Some of the mobile devices have been replaced with Windows Mobile 5.0. As a...
1
by: =?Utf-8?B?V29vZGdub21l?= | last post by:
Hi, I have use the following code to transmit a file back to the browser that worked fine on a HTC_TTyN device running windows mobile 5.0. The code executes in the onclick event of a mobilelist...
7
by: JayaseelanVaiyapuri | last post by:
Hi all, I have done with Symbian and Blackberry for retrieving Mobile Country Code(MCC) from my mobile using my app.. Now i want to know how to get the MCC for Windows Mobile using Win32...
2
by: bolineni | last post by:
Hi i developed a windows mobile application in .net cf3.5. when i am trying to deploy this application on palm os device by using "Palm One quick install", it is giving 'Incompatible HandHeld...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.