It depends on what kind of control over the serial port you want. Both Linux and MacOS / X allow you to access serial ports through a file descriptor (obtained by a simple open () call with the appropriate device address as an argument), so if all you have to do is read and / or write bytes to / from the serial port as if it were a socket, you shouldn't have much of a problem. If you have to do more complex things like turn handshaking on / off and the like, things get a little more proactive.
FWIW I wrote a simple serial port interface class ( w / header ) as part of my networking library ; it works under Linux, MacOS / X and Windows. You can take a look at it for inspiration if you like; note that the macOS / X and Linux implementation is pretty much the same, except for the (GetAvailableSerialPortNames ()) method, which lists the available serial devices.
source
to share