MacOS: programmatically finding serial ports?

2020-04-07 19:47发布

问题:

Is there a library call in MacOS to list the available serial ports and the settings of each? Hopefully something that might port to iOS at some time with minimal difficulty.

I would prefer not to system("ls /dev/tty.*") and system("stty ...") if possible.

回答1:

You use IOKit calls to find serial ports.

See: Documentation and Sample Code