| Versions |
 |
|
| Author |
Topic  |
|
|
gpswk
France
31 Posts |
Posted - 09 juin 2009 : 23:23:03
|
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
|
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..... |
 |
|
|
Leif
Sweden
141 Posts |
Posted - 10 juin 2009 : 00:11:09
|
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?
|
 |
|
|
gpswk
France
31 Posts |
Posted - 10 juin 2009 : 23:17:41
|
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 |
 |
|
|
gpswk
France
31 Posts |
Posted - 10 juin 2009 : 23:20:26
|
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 |
 |
|
|
musky
USA
226 Posts |
Posted - 11 juin 2009 : 02:34:08
|
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 |
 |
|
|
gpswk
France
31 Posts |
Posted - 12 juin 2009 : 23:18:40
|
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
|
 |
|
|
TheDuze
Denmark
1 Posts |
Posted - 12 août 2009 : 07:50:10
|
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 |
 |
|
|
gpswk
France
31 Posts |
Posted - 12 août 2009 : 14:39:24
|
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 |
 |
|
|
seascan
1 Posts |
Posted - 27 sept. 2010 : 22:04:51
|
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.
|
 |
|
|
gpswk
France
31 Posts |
|
| |
Topic  |
|
|
|
| This page was generated in 0,38 seconds. |
 |
|