The API help says,
By default, the ReadLine method will block until a line is received. If this behavior is undesirable, set the ReadTimeout property to any non-zero value to force the ReadLine method to throw a TimeoutException if a line is not available on the port.
... so, do that if you want to avoid it hanging.
Anyway:
- How do you know that the two devices/ports are connected to each other (via Bluetooth)?
- Are you setting the
SerialPort
properties (e.g.BaudRate
etc.) before you call the Open method? - Does it make any difference which you invoke first, the
ReadLine
or theWriteLine
? Instead of doing open/write/close and open/read/close, how about doing open/open/read/write/close/close instead? - What the receivers
BytesToRead
property return after the sender has invokedWriteLine
? - Have you looked at the serial port sample code, which exists (according to the Stonestreet One Bluetooth SDK FAQ)
If their SDK does have a sample program, then I suggest you use it (unaltered) to verify your test setup (e.g. to verify that your devices are connecting properly), before you alter the sample program and/or before you test your own software (using the same devices/test setup which you've already tested with their sample software).
ChrisW
2009-10-07 22:38:58