Google
  Web www.gpspassion.com


GpsPasSion LIVE!
www.flickr.com
This is a Flickr badge showing public photos from GpsPasSion Live !. Make your own badge here.

www.NaviBlog.com



Versions

Links/Liens




Portal/Portail
Rechercher

- -

Polls/Sondages
Sondage
Pour vous guider sur la Route :
GPS Mobile (SEM)
GPS Intégré
Smartphone
Autre
Voter  -  Résultat des votes
Votes : 2250




Club GpsPasSion
Soutenez le site!

USA: (US$)
EUROPE: (€)
Guide Paypal


GpsPasSion Forums
Home | Profile | Register/Enregist. | Active Topics | Search/Recherche | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 GPS Programming
 Programming Hints and Tips
 Open() port raises exception
 New Topic  Reply/Répondre
 Printer Friendly
Author Previous Topic Topic Next Topic  

gpswk

France
31 Posts

Posted - 09 juin 2009 :  23:23:03  Show Profile  Visit gpswk's Homepage  Reply with Quote
Hi,

I’m trying to open the COM port of my GPS (Takara GP26) in order to read the GPS frames, but the Open() function fails with a System.Argument.Exception. (see source code below).

I heard about 'virtual ports' and things, but as I do not start the 'normal' GPS software when launching my test program, it shouldn’t be necessary to create virtual ports – or is it?

What else could make Open() fail ? Will wrong attributes of the Port object raise the exception ? (parity, data bits, … - I’m using defaults).

Other programs found on the net fail with the same message, while IGO runs fine and detects the port / baud rate I’m using.

Thanks in advance for any ideas,

Werner

WIN CE 5.0, .NET 2.0.50727

System.IO.Ports.SerialPort com;
com = new SerialPort();
com.PortName = "COM7"; // port COM on Takara GP26
com.BaudRate = 57600; // Takara GP26
com.Open(); // System.Argument.Exception in System.dll

'DeviceApplication1.exe' (Managed): Loaded 'System.dll', No symbols loaded.
'DeviceApplication1.exe' (Managed): Loaded 'System.Drawing.dll', No symbols loaded.
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
A first chance exception of type 'System.ArgumentException' occurred in System.dll
A first chance exception of type 'System.ArgumentException' occurred in System.dll
An unhandled exception of type 'System.ArgumentException' occurred in System.dll

http://werner.keilholz.free.fr/gps.html


Edited by - gpswk on 09 juin 2009 23:23:52

Ads


musky

USA
226 Posts

Posted - 09 juin 2009 :  23:43:05  Show Profile  Reply with Quote
Are you sure you have a COM7 available? Does this device have an internal GPS? Bluetooth?

First I would start by independently verifying that a COM7 is available.....
Go to Top of Page

Leif

Sweden
141 Posts

Posted - 10 juin 2009 :  00:11:09  Show Profile  Reply with Quote
Try "COM7:". The colon is required in device names on Windows CE. If it was C or C++ code it would also be required to convert the string to unicode by writing TEXT("COM7:") or one of the short hand variants. Don't know if it is nessesary on C# is it?
Go to Top of Page

gpswk

France
31 Posts

Posted - 10 juin 2009 :  23:17:41  Show Profile  Visit gpswk's Homepage  Reply with Quote
quote:
Originally posted by musky

Are you sure you have a COM7 available? Does this device have an internal GPS? Bluetooth?

First I would start by independently verifying that a COM7 is available.....



It has an internal GPS (no Bluetooth).
How would you go about verifying that COM7 is available?
(How could it not be COM7 if IGO runs fine using it?)

I'm out of ideas...

Thanks,

Werner
Go to Top of Page

gpswk

France
31 Posts

Posted - 10 juin 2009 :  23:20:26  Show Profile  Visit gpswk's Homepage  Reply with Quote
quote:
Originally posted by Leif

Try "COM7:". The colon is required in device names on Windows CE. If it was C or C++ code it would also be required to convert the string to unicode by writing TEXT("COM7:") or one of the short hand variants. Don't know if it is nessesary on C# is it?




I tried with and without the colon, none works...
C# doesn't require explicit encoding for all I know.
This is a nightmare!

Anyway, thanks for your suggestion, I appreciate it.

Werner
Go to Top of Page

musky

USA
226 Posts

Posted - 11 juin 2009 :  02:34:08  Show Profile  Reply with Quote
gpswk:

Well, when I was developing a GPS app for WinCE, I had some issues, so I used one of these little GPS utilities to verify the COM port. These utilities allow you to set the COM Port, so you can see which one is functional. I was using an iPAQ 310, and the little app was GPSViewer.

So, I would get a small GPS utility, start it up, choose COM7, and make sure it works.

BTW, my iPAQ has iGO too, and it actually uses a different COM port than my custom app.

Have you tried just simply going through all the com ports in your app, going COM0, COM1, COM2 ?

Maybe these are dumb suggestions, but you say it's a nightmare, so....

Here's my C++ code for opening the port FWIW:

TCHAR szPort[15];
wsprintf(szPort,_T("COM%d:"),nPort); // nPort is port#
m_hComDev=CreateFile(szPort,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);

Edited by - musky on 11 juin 2009 02:37:51
Go to Top of Page

gpswk

France
31 Posts

Posted - 12 juin 2009 :  23:18:40  Show Profile  Visit gpswk's Homepage  Reply with Quote
musky,

I can see nothing dumb in your suggestions - they are BRILLIANT!

I tried all ports backwards & forwards, with and without colon - nothing worked.
But your C snippled gave me the idea to just try it out in C - and the frames flow right in! Yessss!

Now this is weired and I still don't know what's wrong with the .NET framework on my device (I wrote a quite complete GUI and everything but the port opening works...), but at least I have a case now. At the worst, I'll put this functionality into a C DLL which I can call from C# (it is so much easier to write the GUI in C#...).

THANKS FOR YOUR SUPPORT!

Werner
Go to Top of Page

TheDuze

Denmark
1 Posts

Posted - 12 août 2009 :  07:50:10  Show Profile  Visit TheDuze's Homepage  Reply with Quote
Hi

I have the exact same problem with the small program Im making.

I have a Globalsat BU-353. When i call port.Open(); it fails with an IOException. The settings are setup according to specifications. COM3 (4800, N, 8, 1). I have an accelerometer on COM1, which works perfectly.

I use .Net and C#.

Did you manage to get i working with C#?

C# programmer
Go to Top of Page

gpswk

France
31 Posts

Posted - 12 août 2009 :  14:39:24  Show Profile  Visit gpswk's Homepage  Reply with Quote
Hi,

No, it never worked in C# for me. I made a DLL in C which can be called from C#.

Its not a nice solution, as it causes some interoperability problems between C and C# (I finally passed characters one-by-one).

Werner
Go to Top of Page

seascan

1 Posts

Posted - 27 sept. 2010 :  22:04:51  Show Profile  Reply with Quote
I had the same problem using VB.net. After beating my head against the wall, I tried re-booting and NOT using the test program that came with the GlobalSat reciever... and then it worked!

It seems there is something that is in their test program that hangs the port after the program is closed.

Go to Top of Page

gpswk

France
31 Posts

Posted - 27 sept. 2010 :  23:17:00  Show Profile  Visit gpswk's Homepage  Reply with Quote
In my case it wasn't the test program, as I wrote my own test program...

For those interested, I published the solution which finally worked for me here:
http://www.codeproject.com/KB/windows/GpsDll.aspx

And the application I made with it there:
www.maplorer.com

Werner
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply/Répondre
 Printer Friendly
Jump To:
GpsPasSion Forums © 2002-2014_GpsPasSion/Manzanite Go To Top Of Page
This page was generated in 0,58 seconds. Powered By: Snitz Forums 2000 Version 3.4.05