Once again Problems with SerialPort class
Hi,
we were thinking (hoping) that with SerialPort we get a class solving the problems with the Serial Communications on PocketPCs.
But instead it works worse than our own implementation via PInvoke.
On thing I allready showed there:http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=9794
Now we got a new one!
On an IPAQ we have a bluetooth barcode reader. The serial port for BT is Com8 in this case.
With our handmade Serial it is no problem to get strings form the BCR.
When I use SerialPort an try to open Com8 (no Data from the BCR - just open) I get an "IOException" stating the following:
StackTrace "at SerialStream.WinIOError()\r\nat SerialStream.WinIOError()\r\nat SerialStream.CheckResult()\r\nat SerialStream.SetBufferSizes()\r\nat SerialPort.Open()\r\nat Form1.btnOpen_Click()\r\nat Control.OnClick()\r\nat Button.OnClick()\r\nat ButtonBase.WnProc()\r\nat Control._InternalWnProc()\r\nat EVL.EnterMainLoop()\r\nat Application.Run()\r\nat Program.Main()\r\n" string
HRESULT: -2146232800
So whats the problem here? We open the port as any other one and it works.
Or in other words.
With our SerialClass we read GPS data from Com1 - it works.
With our SerialClass we read Barcode data from Com8 - it works.
We use SerialPort to read GPS data from Com1 - it works.
We use SerialPort to read barcode from Com8 it fails.
In both cases we use the exact same settings (excpet the portnumber) but SerialPort has a problem.
Any suggestions what could cause that error?
Cheers
Manfred
[1651 byte] By [
ManniAT] at [2008-1-27]
Hi Manfred,
Thanks for your information. We have been able to reproduce the issue you mentioned and we are investigating for a fix to the issue. The issue seems to be that the Bluetooth driver is returning us an error when we are setting the buffer sizes.
Can you verify that the error code -2146232800 you reported is correct? I was not able to locate the error message corresponding to the code.
Thanks,
Anthony
Hi
I have experienced exactly the same problem.
I use the try-catch to filter out the IOExeception.
After that I just start using (reading/writing) the port and everything works fine, without any problems.
I use a HP IPaq 2210.
So until the final version of VS2005 arrives maybe you can do the same ?
try
{
serial->Open();
}
catch(FileNotFoundException ^e){
logFejl(e->Message);
}
// temporary fix for PDA
catch(IOException ^e){ logFejl(e->Message);
}
// Port allready in use by another app. catch(UnauthorizedAccessException ^e){ logFejl(e->Message);
}
if (serial->IsOpen){ serial->DiscardInBuffer();
serial->DiscardOutBuffer();
SetupPort(LineMode::Serial);
}
Hi,
thanks for that!!
I didn't event try to do it in this way since I thought this error is fatal.
On the other hand I missunderstood a thing wrong - the thing was that CF 2.0 is running on Smartphones (2003) also.
Since this was an error we had to rethink our design goals.
Our app must run on PPC and SP - and the documentation stated (for an example at SerialPort) that it is available on Windows Mobile 2003 for Smartphone.
But since there is no project for SPs an .NET 2.0 this stays nothing more than a wish.
The same wish as with SQL-Mobile.
So we have to
a.) use furtheron our "hand written" serial port class
b.) look for another database than SQL-Mobile
But maybe we have another project where we need no support for SPs - than your "work arround" would help me a lot!
Thanks
Manfred