Skip to content

Commit 824ad47

Browse files
committed
fix
1 parent 1130e27 commit 824ad47

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/src/serial_unix.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
int hSerialPort;
1616
termios2 tty;
1717

18+
std::ofstream log("log.log", std::ios::out);
19+
1820
void (*errorCallback)(int errorCode);
1921
void (*readCallback)(int bytes);
2022
void (*writeCallback)(int bytes);
@@ -29,12 +31,11 @@ void serialOpen(
2931
char *portName = static_cast<char*>(port);
3032
// Open new serial connection
3133
hSerialPort = open(portName, O_RDWR);
34+
35+
log << strerror(errno);
3236

3337
// Error if open fails
3438
ioctl(hSerialPort, TCGETS2, &tty);
35-
// if (tcgetattr(hSerialPort, &tty) != 0) {
36-
// returnStatus(StatusCodes::INVALID_HANDLE_ERROR);
37-
// }
3839

3940
tty.c_cflag &= ~PARENB; // Clear parity bit, disabling parity (most common)
4041
tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication (most common)
@@ -152,7 +153,7 @@ auto serialWrite(
152153
return bytesWritten;
153154
}
154155

155-
std::ofstream("log.log", std::ios::out) << strerror(errno);
156+
log << strerror(errno);
156157

157158
errorCallback(status(StatusCodes::WRITE_ERROR));
158159
return 0;

0 commit comments

Comments
 (0)