Skip to content

Commit

Permalink
Driver: fix opening serial on Mac OS X
Browse files Browse the repository at this point in the history
tcsetattr returns an error if the speed is not.
CLOCAL must be set otherwise usb - serial adapter will never get ready
  • Loading branch information
Alexander Duda authored and Alexander Duda committed Dec 16, 2016
1 parent 45509c0 commit fd82a86
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,12 @@ int Driver::openSerialIO(std::string const& port, int baud_rate)

struct termios tio;
memset(&tio, 0, sizeof(termios));
tio.c_cflag = CS8 | CREAD; // data bits = 8bit and enable receiver
tio.c_iflag = IGNBRK; // don't use breaks by default

tio.c_cflag = (CS8 | CREAD | CLOCAL); // data bits = 8bit, enable reading
// and ignore modem status line
tio.c_iflag = IGNBRK; // don't use breaks by default
cfsetispeed(&tio, B9600); // set baud rate to something
cfsetospeed(&tio, B9600); // otherwise tcsetattr complains on Mac OS

// Commit
if (tcsetattr(fd, TCSANOW, &tio)!=0)
Expand Down

0 comments on commit fd82a86

Please sign in to comment.