mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 17:29:18 +02:00
(uart) change incorrect name "enumeration" -> "port finding"
This commit is contained in:
24
uart.cpp
24
uart.cpp
@@ -27,10 +27,10 @@ uart_input::uart_input()
|
|||||||
last_update = std::chrono::high_resolution_clock::now();
|
last_update = std::chrono::high_resolution_clock::now();
|
||||||
last_setup = std::chrono::high_resolution_clock::now();
|
last_setup = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
enumerate_ports();
|
find_ports();
|
||||||
}
|
}
|
||||||
|
|
||||||
void uart_input::enumerate_ports() {
|
void uart_input::find_ports() {
|
||||||
UartStatus *status = &Application.uart_status;
|
UartStatus *status = &Application.uart_status;
|
||||||
|
|
||||||
struct sp_port **ports;
|
struct sp_port **ports;
|
||||||
@@ -51,9 +51,9 @@ void uart_input::enumerate_ports() {
|
|||||||
}
|
}
|
||||||
sp_free_port_list(ports);
|
sp_free_port_list(ports);
|
||||||
} else {
|
} else {
|
||||||
WriteLog("uart: cannot enumerate serial ports");
|
WriteLog("uart: cannot read serial ports list");
|
||||||
}
|
}
|
||||||
last_enumeration = std::chrono::high_resolution_clock::now();
|
last_port_find = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uart_input::setup_port()
|
bool uart_input::setup_port()
|
||||||
@@ -61,7 +61,7 @@ bool uart_input::setup_port()
|
|||||||
UartStatus *status = &Application.uart_status;
|
UartStatus *status = &Application.uart_status;
|
||||||
|
|
||||||
if(!port) {
|
if(!port) {
|
||||||
enumerate_ports();
|
find_ports();
|
||||||
}
|
}
|
||||||
if (port) {
|
if (port) {
|
||||||
sp_close(port);
|
sp_close(port);
|
||||||
@@ -75,7 +75,7 @@ bool uart_input::setup_port()
|
|||||||
if(!error_notified) {
|
if(!error_notified) {
|
||||||
status->is_connected = false;
|
status->is_connected = false;
|
||||||
ErrorLog("uart: cannot find specified port '"+conf.port+"'");
|
ErrorLog("uart: cannot find specified port '"+conf.port+"'");
|
||||||
enumerate_ports();
|
find_ports();
|
||||||
}
|
}
|
||||||
error_notified = true;
|
error_notified = true;
|
||||||
return false;
|
return false;
|
||||||
@@ -85,7 +85,7 @@ bool uart_input::setup_port()
|
|||||||
if(!error_notified) {
|
if(!error_notified) {
|
||||||
status->is_connected = false;
|
status->is_connected = false;
|
||||||
ErrorLog("uart: cannot open port '"+status->port_name+"'");
|
ErrorLog("uart: cannot open port '"+status->port_name+"'");
|
||||||
enumerate_ports();
|
find_ports();
|
||||||
}
|
}
|
||||||
error_notified = true;
|
error_notified = true;
|
||||||
port = nullptr;
|
port = nullptr;
|
||||||
@@ -107,7 +107,7 @@ bool uart_input::setup_port()
|
|||||||
}
|
}
|
||||||
error_notified = true;
|
error_notified = true;
|
||||||
port = nullptr;
|
port = nullptr;
|
||||||
enumerate_ports();
|
find_ports();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ bool uart_input::setup_port()
|
|||||||
}
|
}
|
||||||
error_notified = true;
|
error_notified = true;
|
||||||
port = nullptr;
|
port = nullptr;
|
||||||
enumerate_ports();
|
find_ports();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,10 +241,10 @@ void uart_input::poll()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(!port && std::chrono::duration<float>(now - last_enumeration).count() > 1.0)
|
(!port && std::chrono::duration<float>(now - last_port_find).count() > 1.0)
|
||||||
|| (port && std::chrono::duration<float>(now - last_enumeration).count() > 5.0)
|
|| (port && std::chrono::duration<float>(now - last_port_find).count() > 5.0)
|
||||||
) {
|
) {
|
||||||
enumerate_ports();
|
find_ports();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!status->enabled) {
|
if(!status->enabled) {
|
||||||
|
|||||||
4
uart.h
4
uart.h
@@ -84,7 +84,7 @@ private:
|
|||||||
using inputpin_sequence = std::vector<input_pin_t>;
|
using inputpin_sequence = std::vector<input_pin_t>;
|
||||||
|
|
||||||
bool setup_port();
|
bool setup_port();
|
||||||
void enumerate_ports();
|
void find_ports();
|
||||||
|
|
||||||
// members
|
// members
|
||||||
sp_port *port = nullptr;
|
sp_port *port = nullptr;
|
||||||
@@ -93,7 +93,7 @@ private:
|
|||||||
std::array<std::uint8_t, 16> old_packet; // TBD, TODO: replace with vector of configurable size?
|
std::array<std::uint8_t, 16> old_packet; // TBD, TODO: replace with vector of configurable size?
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> last_update;
|
std::chrono::time_point<std::chrono::high_resolution_clock> last_update;
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> last_setup;
|
std::chrono::time_point<std::chrono::high_resolution_clock> last_setup;
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> last_enumeration;
|
std::chrono::time_point<std::chrono::high_resolution_clock> last_port_find;
|
||||||
conf_t conf;
|
conf_t conf;
|
||||||
bool data_pending = false;
|
bool data_pending = false;
|
||||||
bool error_notified = false;
|
bool error_notified = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user