Implement Serial Console app & more (#239)
- Implemented new app: Serial Console - `Uart::writeString()`: fixed 2 mutex bugs - `AlertDialog::start()` with default "OK" button added - Created `tt::lvgl::defaultLockTime` for re-use - Removed various usages of deprecated `lvgl::obj_set_style_no_padding()` - Implemented `hal::uart::getNames()` to list all interface names
This commit is contained in:
committed by
GitHub
parent
83a82be901
commit
13d7e84ef3
@@ -19,13 +19,13 @@ bool UartPosix::start() {
|
||||
lock.lock();
|
||||
|
||||
if (device != nullptr) {
|
||||
TT_LOG_E(TAG, "(%s) Starting: Already started", configuration.name.c_str());
|
||||
TT_LOG_E(TAG, "[%s] Starting: Already started", configuration.name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto file = fopen(configuration.name.c_str(), "w");
|
||||
if (file == nullptr) {
|
||||
TT_LOG_E(TAG, "(%s) failed to open", configuration.name.c_str());
|
||||
TT_LOG_E(TAG, "[%s] Open device failed", configuration.name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,18 +33,16 @@ bool UartPosix::start() {
|
||||
|
||||
struct termios tty;
|
||||
if (tcgetattr(fileno(file), &tty) < 0) {
|
||||
printf("(%s) tcgetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
printf("[%s] tcgetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cfsetospeed(&tty, (speed_t)configuration.baudRate) == -1) {
|
||||
TT_LOG_E(TAG, "(%s) failed to set output speed", configuration.name.c_str());
|
||||
return false;
|
||||
TT_LOG_E(TAG, "[%s] Setting output speed failed", configuration.name.c_str());
|
||||
}
|
||||
|
||||
if (cfsetispeed(&tty, (speed_t)configuration.baudRate) == -1) {
|
||||
TT_LOG_E(TAG, "(%s) failed to set input speed", configuration.name.c_str());
|
||||
return false;
|
||||
TT_LOG_E(TAG, "[%s] Setting input speed failed", configuration.name.c_str());
|
||||
}
|
||||
|
||||
tty.c_cflag |= (CLOCAL | CREAD); /* ignore modem controls */
|
||||
@@ -63,13 +61,13 @@ bool UartPosix::start() {
|
||||
tty.c_cc[VTIME] = 1;
|
||||
|
||||
if (tcsetattr(fileno(file), TCSANOW, &tty) != 0) {
|
||||
printf("(%s) tcsetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
printf("[%s] tcsetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
device = std::move(new_device);
|
||||
|
||||
TT_LOG_I(TAG, "(%s) Started", configuration.name.c_str());
|
||||
TT_LOG_I(TAG, "[%s] Started", configuration.name.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -78,13 +76,13 @@ bool UartPosix::stop() {
|
||||
lock.lock();
|
||||
|
||||
if (device == nullptr) {
|
||||
TT_LOG_E(TAG, "(%s) Stopping: Not started", configuration.name.c_str());
|
||||
TT_LOG_E(TAG, "[%s] Stopping: Not started", configuration.name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
device = nullptr;
|
||||
|
||||
TT_LOG_I(TAG, "(%s) Stopped", configuration.name.c_str());
|
||||
TT_LOG_I(TAG, "[%s] Stopped", configuration.name.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -141,7 +139,7 @@ void UartPosix::flushInput() {
|
||||
uint32_t UartPosix::getBaudRate() {
|
||||
struct termios tty;
|
||||
if (tcgetattr(fileno(device.get()), &tty) < 0) {
|
||||
printf("(%s) tcgetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
printf("[%s] tcgetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
return false;
|
||||
} else {
|
||||
return (uint32_t)cfgetispeed(&tty);
|
||||
@@ -156,17 +154,17 @@ bool UartPosix::setBaudRate(uint32_t baudRate, TickType_t timeout) {
|
||||
|
||||
struct termios tty;
|
||||
if (tcgetattr(fileno(device.get()), &tty) < 0) {
|
||||
printf("(%s) tcgetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
printf("[%s] tcgetattr failed: %s\n", configuration.name.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cfsetospeed(&tty, (speed_t)configuration.baudRate) == -1) {
|
||||
TT_LOG_E(TAG, "(%s) failed to set output speed", configuration.name.c_str());
|
||||
TT_LOG_E(TAG, "[%s] Failed to set output speed", configuration.name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cfsetispeed(&tty, (speed_t)configuration.baudRate) == -1) {
|
||||
TT_LOG_E(TAG, "(%s) failed to set input speed", configuration.name.c_str());
|
||||
TT_LOG_E(TAG, "[%s] Failed to set input speed", configuration.name.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user