Bluetooth IOException

M

Malc

Hi, when I try and open the Bluetooth serial port using Compact Framework
2.0's System.IO.Ports library I get an IOException, however the same code
works fine with the regular serial port. Anyone know a solution?


outPort = new SerialPort("COM8:", 4800, Parity.None, 8,StopBits.One);
outPort.Handshake = Handshake.None;
outPort.Encoding = Encoding.ASCII;

outPort.ReceivedBytesThreshold = 7;
outPort.ReadBufferSize = 7;
outPort.WriteBufferSize = 8;

outPort.ReceivedEvent+=new
SerialReceivedEventHandler(outPort_ReceivedEvent);
try
{
outPort.Open();
}
catch (Exception e) { Console.WriteLine(e.Message);}

This occurs on a iPAQ 5550 and 4150, and the exception occurs after the
Bluetooth browser pops up and I choose the device providing the serial
service. Note it works fine when I do the same thing using
OpenNetCF.IO.Serial. The reason for trying CF 2.0 is OpenNetCF serial
stutters on Bluetooth connections. I mean sometimes it just pauses and no
data received events are thrown for a while. Then when it continues the
data has been buffered and the application lags behind with old data. The
solution was to increase the priority of OpenNetCF's internal data
received thread, but if someone knows how to get past the IOException
under CF 2.0 that would be great.
 
P

PeterB

Which version of the OpenNETCF.org Serial API are you using? I had some
problems with data-clogging with the earlier versions (retrieving data from
a BT GPS), but the new version works great (should mention I have removed
some of the, for me, unneccessary parts of the API).

There have been some significant improvements during the last months of that
API, and a performance study made indicated that OpenNETCF's API was faster
than a commercial Serial API in most cases.

/ Peter
 
M

Malc

Thanks for the respose.

I was using the version from the source browser on 12th of August. I'll
take a look closer at the source and see if I can see anything that might
cause the clogging. Also if you could perhaphs mail me your version so I
could compare them that would be excellent.


Which version of the OpenNETCF.org Serial API are you using? I had some
problems with data-clogging with the earlier versions (retrieving data
from
a BT GPS), but the new version works great (should mention I have removed
some of the, for me, unneccessary parts of the API).

There have been some significant improvements during the last months of
that
API, and a performance study made indicated that OpenNETCF's API was
faster
than a commercial Serial API in most cases.

/ Peter
 
P

PeterB

What's the data transmission speed you are trying to achieve?

The things I changed, which was also changed in the newer versions of
OpenNETCF's Serial API, was:

1. The data read into the buffer (CommAPI.ReadFile(...) ) in the port object
was increased to a variable amount from the static1 byte at a time. The
newer serial API (which you have if you downloaded it 12th of August) should
have this.

2. Removed Line Status Checking since I didn't use that and it included a
bunch of if-statements in the performance critical thread loop.

I am not sure 2. helped that much, the major bottleneck was 1.

Have a look at the code section mentioned in 1. and see if there is anything
you can do there. I would also recommend trying different ReceiveBuffer
sizes. 7 sounds a bit small to me.. have you tried catching any overflow
exceptions etc?

I could send you my code, the problem is I use a hybrid of the old version
of OpenNETCF's API and the new one.... (one day I'll clean up my mess :) ).
For instance, I am not using the FIFO-structures but instead the old byte[]
buffer for caching my received data. Let me know if you want the hack anyway
;-)

Anyway, I am receiving data from a BT GPS, and the transmission speed isn't
that fast so I don't have any experience with super fast BT connections...

regards,

Peter
 
Joined
Oct 5, 2006
Messages
1
Reaction score
0
The same problem here.. I've tried this code on a [font=arial,sans-serif][size=-1]hp ipaq hx4705 and it worked fine.
When i tried in a hp ipaq h5500 it is thrown an IOException
Just Don't know what is the problem...
[/size][/font] this.Port = new SerialPort("COM8",4800);
this.Port.Handshake = Handshake.None;
this.Port.Parity = Parity.None;
this.Port.StopBits = StopBits.One;
this.Port.DataReceived += new SerialDataReceivedEventHandler(Port_DataReceived);
while (!OK)
{
try
{
this.OK = false;
this.Port.Open();
this.OK = true;
}
catch (Exception ex){}
}


PLEASE HELP!!!!!!!!!!!!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top