-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] UART #173
base: master
Are you sure you want to change the base?
[WIP] UART #173
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello!
What's the plan with this class, except wrapping IDF functions into a class with added logging?
UART::UART(uart_port_t port, int baud_rate, uart_word_length_t data_bits, uart_parity_t parity, uart_stop_bits_t stop_bits, uart_hw_flowcontrol_t flow_control, gpio_num_t tx_pin, gpio_num_t rx_pin, gpio_num_t rts_pin, gpio_num_t cts_pin, uart_mode_t mode) | ||
: port_(port) | ||
{ | ||
this->config_ = uart_config_t{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this->
and also from The contributing.md document:
Do not use Hungarian notation for variables, i.e. warts m_
void UART::log_error(const std::string msg, esp_err_t err) | ||
{ | ||
std::stringstream ss; | ||
ss << "UART Error for port '" << static_cast<int>(port_) << "', " << msg << ": " << esp_err_to_name(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You never print out the error. There's also this: https://github.com/PerMalmberg/Smooth/blob/master/lib/smooth/include/smooth/core/logging/log.h
uart_port_t port_; | ||
|
||
uart_config_t config_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above, no warts please :)
/// Log an error message. | ||
/// \param msg The error message | ||
/// \param err The error code | ||
void log_error(const std::string msg, esp_err_t err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void log_error(const std::string msg, esp_err_t err); | |
void log_error(const std::string& msg, esp_err_t err); |
No reason to pass this function a copy of the string, no use of move-semantics that I can see?
bool UART::get_word_length(uart_word_length_t &data_bit) | ||
{ | ||
const auto res = uart_get_word_length(this->port_, &data_bit); | ||
if(res != ESP_OK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use positive logic as per contributing.md
|
||
bool UART::set_word_length(const uart_word_length_t &data_bit) | ||
{ | ||
auto res = uart_set_word_length(this->port_, data_bit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're meticulous with const elsewhere, but missed this one.
Not ready for merge yet. I am just adding it already now, so that I can get feedback as soon as possible and don't have to refactor later.
I need this to support a finger print sensor, for which I will add code later.