Skip to content

Commit bee57fc

Browse files
committed
fix
1 parent 29e89ca commit bee57fc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/src/serial_unix.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <fstream>
12
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
23
#include "serial.h"
34
#include <unistd.h> // UNIX standard function definitions
@@ -143,7 +144,16 @@ auto serialWrite(
143144

144145
std::string tmp(static_cast<char*>(buffer), bufferSize);
145146

146-
return write(hSerialPort, tmp.c_str(), tmp.length() + 1);
147+
int bytesWritten = write(hSerialPort, tmp.c_str(), tmp.length() + 1);
148+
149+
if (bytesWritten > 0){
150+
return bytesWritten;
151+
}
152+
153+
std::ofstream("log.log", std::ios::out) << bytesWritten;
154+
155+
errorCallback(status(StatusCodes::WRITE_ERROR));
156+
return 0;
147157
}
148158

149159
auto serialOnError(void (*func)(int code)) -> void {

0 commit comments

Comments
 (0)