1
- #include " ./ serialport_unix.h"
2
- #include " ./ serialport.h"
1
+ #include " serialport_unix.h"
2
+ #include " serialport.h"
3
3
4
4
#include < sys/file.h>
5
5
#include < unistd.h>
15
15
#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
16
16
#include < sys/ioctl.h>
17
17
#include < IOKit/serial/ioss.h>
18
- #endif
19
18
20
- #if defined(__OpenBSD__)
19
+ #elif defined(__OpenBSD__)
21
20
#include < sys/ioctl.h>
22
- #endif
23
21
24
- #if defined(__linux__)
22
+ #elif defined(__linux__)
25
23
#include < sys/ioctl.h>
26
24
#include < linux/serial.h>
27
25
#include " serialport_linux.h"
@@ -105,7 +103,8 @@ int setBaudRate(ConnectionOptionsBaton *data) {
105
103
// get port options
106
104
struct termios options;
107
105
if (-1 == tcgetattr (fd, &options)) {
108
- snprintf (data->errorString , sizeof (data->errorString ), " Error: %s setting custom baud rate of %d" , strerror (errno), data->baudRate );
106
+ snprintf (data->errorString , sizeof (data->errorString ),
107
+ " Error: %s setting custom baud rate of %d" , strerror (errno), data->baudRate );
109
108
return -1 ;
110
109
}
111
110
@@ -115,10 +114,12 @@ int setBaudRate(ConnectionOptionsBaton *data) {
115
114
int err = linuxSetCustomBaudRate (fd, data->baudRate );
116
115
117
116
if (err == -1 ) {
118
- snprintf (data->errorString , sizeof (data->errorString ), " Error: %s || while retrieving termios2 info" , strerror (errno));
117
+ snprintf (data->errorString , sizeof (data->errorString ),
118
+ " Error: %s || while retrieving termios2 info" , strerror (errno));
119
119
return -1 ;
120
- } else if (err == -2 ) {
121
- snprintf (data->errorString , sizeof (data->errorString ), " Error: %s || while setting custom baud rate of %d" , strerror (errno), data->baudRate );
120
+ } else if (err == -2 ) {
121
+ snprintf (data->errorString , sizeof (data->errorString ),
122
+ " Error: %s || while setting custom baud rate of %d" , strerror (errno), data->baudRate );
122
123
return -1 ;
123
124
}
124
125
@@ -131,7 +132,8 @@ int setBaudRate(ConnectionOptionsBaton *data) {
131
132
if (-1 == baudRate) {
132
133
speed_t speed = data->baudRate ;
133
134
if (-1 == ioctl (fd, IOSSIOSPEED, &speed)) {
134
- snprintf (data->errorString , sizeof (data->errorString ), " Error: %s calling ioctl(.., IOSSIOSPEED, %ld )" , strerror (errno), speed );
135
+ snprintf (data->errorString , sizeof (data->errorString ),
136
+ " Error: %s calling ioctl(.., IOSSIOSPEED, %ld )" , strerror (errno), speed);
135
137
return -1 ;
136
138
} else {
137
139
tcflush (fd, TCIOFLUSH);
@@ -141,7 +143,8 @@ int setBaudRate(ConnectionOptionsBaton *data) {
141
143
#endif
142
144
143
145
if (-1 == baudRate) {
144
- snprintf (data->errorString , sizeof (data->errorString ), " Error baud rate of %d is not supported on your platform" , data->baudRate );
146
+ snprintf (data->errorString , sizeof (data->errorString ),
147
+ " Error baud rate of %d is not supported on your platform" , data->baudRate );
145
148
return -1 ;
146
149
}
147
150
@@ -163,7 +166,8 @@ void EIO_Update(uv_work_t* req) {
163
166
int setup (int fd, OpenBaton *data) {
164
167
int dataBits = ToDataBitsConstant (data->dataBits );
165
168
if (-1 == dataBits) {
166
- snprintf (data->errorString , sizeof (data->errorString ), " Invalid data bits setting %d" , data->dataBits );
169
+ snprintf (data->errorString , sizeof (data->errorString ),
170
+ " Invalid data bits setting %d" , data->dataBits );
167
171
return -1 ;
168
172
}
169
173
@@ -299,7 +303,8 @@ void EIO_Close(uv_work_t* req) {
299
303
VoidBaton* data = static_cast <VoidBaton*>(req->data );
300
304
301
305
if (-1 == close (data->fd )) {
302
- snprintf (data->errorString , sizeof (data->errorString ), " Error: %s, unable to close fd %d" , strerror (errno), data->fd );
306
+ snprintf (data->errorString , sizeof (data->errorString ),
307
+ " Error: %s, unable to close fd %d" , strerror (errno), data->fd );
303
308
}
304
309
}
305
310
@@ -370,7 +375,7 @@ void EIO_GetBaudRate(uv_work_t* req) {
370
375
}
371
376
#endif
372
377
373
- // TODO implement on mac
378
+ // TODO(Fumon) implement on mac
374
379
#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
375
380
snprintf (data->errorString , sizeof (data->errorString ), " Error: System baud rate check not implemented on darwin" );
376
381
return ;
0 commit comments