serialport / bluetooth issues
11 views (last 30 days)
Show older comments
There seems to be a lot of bluetooth issues with Matlab and MacOS. I connect to various ESP32's with bluetooth and I have to use "serialport" in order to communicate with them. blelist, bluetoothlist, etc. will crash matlab but I have this in a different post ( https://www.mathworks.com/matlabcentral/answers/1870442-macos-bluetoothlist-command-hangs-up-busy ). There was a suggestion that this would be fixed for 2023a but doesn't appear that it was.
At any rate, the problem I'm having with serialport() is that I have to quit Matlab completely and forget all my bluetooth pairing's every time before I open my .mlapp . On Mac this is requires a lot of mouse clicks and is tedious when you have to "forget" and reconnect a lot of bluetooth pairs. I tried to delete the ports before I close out my .mlapp but this doesn't seem to help. Looking at this post ( https://www.mathworks.com/matlabcentral/answers/886269-how-do-i-close-serialport-objects ) it suggests the ability to drop the handles was intentionally removed. Does anyone know if there is a way to drop the handles?
Does anyone out there have a reliable way to connect a Mac to a bluetooth device via matlab to send and receive serial data?
0 Comments
Answers (1)
Walter Roberson
on 4 Jun 2023
What that second post is telling you is that serialport() has an internal onCleanup that is invoked when serialport() detects the device is no longer reachable (because it is unplugged), so when the device gets unplugged, all of the internal MATLAB records of the port are removed -- there are no more handle objects left to drop when this situation occurs.
At the moment, I do not have any ideas why you need to re-pair the devices, so I cannot address that -- but it is not because of left-over handles.
3 Comments
Walter Roberson
on 4 Jun 2023
I am running Catalina on the system I am using at the moment. I have three paired bluetooth devices. The only cu.* and tty.* in my /dev are /dev/cu.Bluetooth-Incoming-Port and /dev/tty.Bluetooth-Incoming-Port and there is nothing in /dev that looks like a device file for the paired bluetooth entities.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!