Fixed borken read

This commit is contained in:
2023-04-27 16:00:42 +03:00
parent 1028f0dead
commit 99cbad2c28
+7 -2
View File
@@ -83,7 +83,12 @@ void grbl::tcp_transport::worker() {
// anything to read?
auto read_bytes = read(fd, buffer, 200);
if (read_bytes > 0) {
if (read_bytes == -1 && (errno == EWOULDBLOCK || errno == EAGAIN)) {
// do nothing
} else if (read_bytes == -1) {
std::cerr << "Failed while reading." << std::endl;
close();
} else {
for (int i = 0; i < read_bytes; i++) {
auto is_eol = buffer[i] == '\r' || buffer[i] == '\n';
if (is_eol) {
@@ -98,7 +103,7 @@ void grbl::tcp_transport::worker() {
}
// give some time to others
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
}