Complete macOS + PN532 UART support

This commit is contained in:
Samy Kamkar 2021-01-16 11:59:46 -08:00
parent 9f3c859c3b
commit 8c1bf6f56f
4 changed files with 25 additions and 7 deletions

View File

@ -201,13 +201,6 @@ them in a modprobe conf file. This file is provided within libnfc archive:
sudo cp contrib/linux/blacklist-libnfc.conf /etc/modprobe.d/blacklist-libnfc.conf sudo cp contrib/linux/blacklist-libnfc.conf /etc/modprobe.d/blacklist-libnfc.conf
PN532 UART on macOS:
--------------------
- Receiving error: "Unable to set serial port speed to 115200 baud. Speed value must be one of those defined in termios(3)."
- The PN532 High Speed UART (HSU) requires a baud rate of 115200, however macOS may use the incorrect `termios.h` (valid path: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/termios.h) preventing the detection of the `B115200` definition producing the error above.
- Solution: Either add `-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/termios.h` as an include path before the rest of your includes or manually add `#define B115200 115200`.
FEITIAN bR500 and R502: FEITIAN bR500 and R502:
----------------------- -----------------------

View File

@ -47,7 +47,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#ifdef __APPLE__
#include <sys/termios.h>
#else
#include <termios.h> #include <termios.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>

View File

@ -49,7 +49,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#ifdef __APPLE__
#include <sys/termios.h>
#else
#include <termios.h> #include <termios.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <nfc/nfc.h> #include <nfc/nfc.h>

View File

@ -47,7 +47,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#ifdef __APPLE__
#include <sys/termios.h>
#else
#include <termios.h> #include <termios.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
@ -95,6 +99,19 @@ const char *serial_ports_device_radix[] = { "ttyUSB", "ttyS", "ttyACM", "ttyAMA"
// Work-around to claim uart interface using the c_iflag (software input processing) from the termios struct // Work-around to claim uart interface using the c_iflag (software input processing) from the termios struct
# define CCLAIMED 0x80000000 # define CCLAIMED 0x80000000
// If macOS and still haven't detected required baud rates, set them as we do have support for some
#ifdef __APPLE__
#ifndef B57600
#define B57600 57600
#endif
#ifndef B115200
#define B115200 115200
#endif
#ifndef B230400
#define B230400 230400
#endif
#endif
struct serial_port_unix { struct serial_port_unix {
int fd; // Serial port file descriptor int fd; // Serial port file descriptor
struct termios termios_backup; // Terminal info before using the port struct termios termios_backup; // Terminal info before using the port