mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
500000 baud support for osx (termios.h does not support 500000 on osx
This commit is contained in:
parent
1868ae2f16
commit
e7212210dc
1 changed files with 18 additions and 1 deletions
|
|
@ -12,6 +12,15 @@
|
|||
#include <node_buffer.h>
|
||||
#include <v8.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <AvailabilityMacros.h>
|
||||
#endif
|
||||
#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
|
||||
#include <sys/ioctl.h>
|
||||
#include <IOKit/serial/ioss.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define THROW_BAD_ARGS ThrowException(Exception::TypeError(String::New("Bad argument")))
|
||||
|
||||
|
|
@ -96,12 +105,20 @@ namespace node {
|
|||
// Set baud and other configuration.
|
||||
tcgetattr(fd, &options);
|
||||
|
||||
printf("Setting baud rate to %ld\n", Baud_Rate);
|
||||
#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
|
||||
speed_t speed = Baud_Rate;
|
||||
if ( ioctl( fd, IOSSIOSPEED, &speed ) == -1 )
|
||||
{
|
||||
printf( "Error %d calling ioctl( ..., IOSSIOSPEED, ... )\n", errno );
|
||||
}
|
||||
#else
|
||||
BAUD = GetBaudConstant(Baud_Rate);
|
||||
printf("Setting baud rate to %ld\n", BAUD);
|
||||
|
||||
/* Specify the baud rate */
|
||||
cfsetispeed(&options, BAUD);
|
||||
cfsetospeed(&options, BAUD);
|
||||
#endif
|
||||
|
||||
tcflush(fd, TCIFLUSH);
|
||||
tcsetattr(fd, TCSANOW, &options);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue