Skip to content

Commit

Permalink
[modbus] fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MK16kawai committed Jan 8, 2025
1 parent 77e1de4 commit 0c56ead
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions components/comm/src/maix_modbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ ::maix::err::Err Slave::set_timeout(uint32_t sec, uint32_t usec)
return ::maix::err::Err::ERR_RUNTIME;
// __error_and_throw__(msg);
}
if (::modbus_set_response_timeout(this->ctx_.get(), this->curr_timeout_sec_, this->curr_timeout_usec_) < 0) {
std::string msg(this->TAG()+" set timeout failed");
log::warn(msg.c_str());
return ::maix::err::Err::ERR_RUNTIME;
}
return ::maix::err::Err::ERR_NONE;
}

Expand Down Expand Up @@ -299,6 +304,8 @@ ::maix::err::Err Slave::__receive__()
}
return ::maix::err::Err::ERR_NONE;
}
/* flush */
::modbus_flush(this->ctx_.get());
if (this->debug_) {
log::warn("%s receive failed", this->TAG().c_str());
}
Expand Down

0 comments on commit 0c56ead

Please sign in to comment.