g4klx / MMDVMHost

The host program for the MMDVM
GNU General Public License v2.0
378 stars 274 forks source link

fix UART setNonblock bug. #741

Closed cainbit closed 2 years ago

cainbit commented 2 years ago

According to the the man page of fcntl, we should use F_GETFL to get flags.

The flags for the F_GETFD and F_SETFD commands are as follows:

       FD_CLOEXEC   Close-on-exec; the given file descriptor will be automatically closed in the successor process image when one of the execv(2) or posix_spawn(2) family of
                    system calls is invoked.

The flags for the F_GETFL and F_SETFL commands are as follows:

       O_NONBLOCK   Non-blocking I/O; if no data is available to a read call, or if a write operation would block, the read or write call returns -1 with the error EAGAIN.

       O_APPEND     Force each write to append at the end of file; corresponds to the O_APPEND flag of open(2).

       O_ASYNC      Enable the SIGIO signal to be sent to the process group when I/O is possible, e.g., upon availability of data to be read.
g4klx commented 2 years ago

This code is specific to Apple MacOS. Are you sure this is correct on that platform?

cainbit commented 2 years ago

This code is specific to Apple MacOS. Are you sure this is correct on that platform?

Yes, I had checked the man page on MacOS 12.2.1, and the modified code works fine on my MacBook pro with a usb ttl adapter.

shawnchain commented 2 years ago

Thanks for the fix, this bug is introduced by a typo.