Fix: Don't throw const char* but std::runtime_erro
This commit is contained in:
parent
dd51803e15
commit
059dee7d4b
|
|
@ -98,8 +98,7 @@ void HumiReader::setCallback(std::function<bool(const HumiResult&)> cb) {
|
||||||
|
|
||||||
void HumiReader::run() {
|
void HumiReader::run() {
|
||||||
if (!setupDevice()) {
|
if (!setupDevice()) {
|
||||||
throw std::runtime_error("Can't setup device\n");
|
throw std::runtime_error("Can't setup device");
|
||||||
//throw "Can't setup device";
|
|
||||||
}
|
}
|
||||||
cancelLoop = false;
|
cancelLoop = false;
|
||||||
hasIResult = false;
|
hasIResult = false;
|
||||||
|
|
@ -108,17 +107,17 @@ void HumiReader::run() {
|
||||||
char buf[32+1];
|
char buf[32+1];
|
||||||
char outbuf[256];
|
char outbuf[256];
|
||||||
unsigned int outbufsiz =0;
|
unsigned int outbufsiz =0;
|
||||||
unsigned int sleepMax = 10000;
|
int sleepMax = 10000;
|
||||||
|
|
||||||
while(!cancelLoop) {
|
while(!cancelLoop) {
|
||||||
int siz = read(fd, buf, sizeof(buf)-1);
|
int siz = read(fd, buf, sizeof(buf)-1);
|
||||||
if (siz < 0) {
|
if (siz < 0) {
|
||||||
if (errno != EAGAIN) {
|
if (errno != EAGAIN) {
|
||||||
throw "Read failed";
|
throw std::runtime_error("Read failed");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (sleepMax <= 0) {
|
if (sleepMax <= 0) {
|
||||||
throw "Timeout";
|
throw std::runtime_error("Timeout");
|
||||||
}
|
}
|
||||||
usleep(10*1000);
|
usleep(10*1000);
|
||||||
sleepMax -= 10;
|
sleepMax -= 10;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue