serialport / bluetooth issues

조회 수: 12 (최근 30일)
John Whalen
John Whalen 2023년 6월 3일
댓글: John Whalen 2023년 6월 18일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2023년 6월 4일
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
Walter Roberson
Walter Roberson 2023년 6월 4일
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.
John Whalen
John Whalen 2023년 6월 18일
You'll want to use a bluetooth device that has Serial Port Profile (SPP). If you have an ESP32 or something similar you can setup SPP on that device. Basically it allows a bluetooth device to act like a serial device.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Serial and USB Communication에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by