Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

Automatically detect correct serial connection to Arduino device from macOS (Xcode)

I have this small app that I want to communicate with an Arduino device through the USB port. So far I managed to communicate with it using the open source ORSSerial framework.

However, I want this Arduino device to be plug and play, and the path to the serial port (/dev/cu.usbserial-XXX) will change depending on what USB-port I'm using on the Mac.

How would I solve this to be able to have "plug and play" capabilites? Is there some way that the Arduino can let my macOS app know when it get connected, and by this get the correct serial port path?

One possible way that might work (I have not tested):

  1. When Arduino is connected to computer, in the setup() function send a "special message" for the macOS to listen to and then reveal which serial port it came from.
  2. When macOS app starts, send a "special message" to all ports, and have the Arduino respond to this specific message, revealing its port.
question from:https://stackoverflow.com/questions/65601848/automatically-detect-correct-serial-connection-to-arduino-device-from-macos-xco

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...