Fixed borken read
This commit is contained in:
@@ -83,7 +83,12 @@ void grbl::tcp_transport::worker() {
|
|||||||
|
|
||||||
// anything to read?
|
// anything to read?
|
||||||
auto read_bytes = read(fd, buffer, 200);
|
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++) {
|
for (int i = 0; i < read_bytes; i++) {
|
||||||
auto is_eol = buffer[i] == '\r' || buffer[i] == '\n';
|
auto is_eol = buffer[i] == '\r' || buffer[i] == '\n';
|
||||||
if (is_eol) {
|
if (is_eol) {
|
||||||
@@ -98,7 +103,7 @@ void grbl::tcp_transport::worker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// give some time to others
|
// give some time to others
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user