Reputation: 107
I am using Windows7 with 32feet.net libraries for the windows application development. I get the COM ports after I scan and pair the device. When I open the port and try to send the data in the COM port, I am getting two types of exceptions and they are given below
Error Code Exception
121 The semaphore timeout has expired 1168 Element not found.
I also tried with a workaround given in the below link, http://zachsaw.blogspot.in/2010/07/serialport-ioexception-workaround-in-c.html but nothing fruitful. Lastly my suspicion revolves around the Bluetooth driver.
Any insights on how to find an approach for this exceptions.
Regards, Gibson
Upvotes: 1
Views: 995
Reputation: 2349
I had simular issue with this. My issue was resolved with .net 4.7.1. Also I needed to make sure I had the latest microsoft bluetooth driver for the bluetooth device i was using
SerialPort streams no longer terminate the process when exceptions occur on the background thread. This can happen when removing a USB serial port while in use. This new behavior is controlled by the Switch.System.IO.Ports.DoNotCatchSerialStreamThreadExceptions AppContext switch. This switch is set to truetf get by default when targeting .NET 4.7 or below. [428461, System.dll, Bug]
Update: Actually it appears to be 2 issues in one. .net bug and a firmware issue where the device was never turning back on the bluetooth module.
Upvotes: 1
Reputation: 107
I used a RN-42 chip for Bluetooth operations and studied few things from the below link, https://electronics.stackexchange.com/questions/38113/does-bluetooth-range-increase-with-lower-baud-rate
The culprit was the baud rate!!!! I tried using the standard baud rate of 9600 but surprisingly some data transfers were proved to be successful, alas the COM port got disconnected despite the Bluetooth device state being connected to the windows application. During this state, the application threw exceptions after few data transfers like "Element not found" and " The semaphore timeout period has expired". Changing the baud rate suggested by the manufacturer seems to be more stable. Workaround : Align to the same baud rate in the windows application and the Bluetooth device.
Upvotes: 0