feat: Add DTR/RTS control for serial ports with GUI toggles
- Assert DTR/RTS after serial port open to prevent wireless modules (HC-12/HC-15/Bluetooth bridges) from entering AT command mode after the unavoidable Linux kernel DTR pulse on every open() call. - Add dtr/rts fields to TransportConfig::Serial (default: false). - Add set_dtr()/set_rts() on SerialTransport, Connection, SessionHandle. - Add SessionCmd::SetDtr/SetRts for live toggling via command channel. - Add DTR/RTS checkboxes to GUI session controls (visible when connected) and to config form for persistence. - Add test_plot_serial.c and test_text_serial.c — standalone C test tools for sending MixedTextPlot frames and plain text over serial. - Update AGENTS.md with build prerequisites, architecture map, testing conventions, env vars, and known quirks.
This commit is contained in:
@@ -138,6 +138,22 @@ impl SessionHandle {
|
||||
.map_err(|_| String::from("session closed"))
|
||||
}
|
||||
|
||||
pub async fn set_dtr(&self, state: bool) -> Result<(), String> {
|
||||
self.inner
|
||||
.cmd_tx
|
||||
.send(SessionCmd::SetDtr(state))
|
||||
.await
|
||||
.map_err(|_| String::from("session closed"))
|
||||
}
|
||||
|
||||
pub async fn set_rts(&self, state: bool) -> Result<(), String> {
|
||||
self.inner
|
||||
.cmd_tx
|
||||
.send(SessionCmd::SetRts(state))
|
||||
.await
|
||||
.map_err(|_| String::from("session closed"))
|
||||
}
|
||||
|
||||
pub async fn read(&self, timeout_ms: u64) -> Option<DecodedEntry> {
|
||||
let mut rx = self.inner.event_tx.subscribe();
|
||||
let deadline = Duration::from_millis(timeout_ms);
|
||||
@@ -304,6 +320,14 @@ impl Session {
|
||||
self.handle_reconfigure(config).await;
|
||||
true
|
||||
}
|
||||
Some(SessionCmd::SetDtr(state)) => {
|
||||
self.handle_set_dtr(state);
|
||||
true
|
||||
}
|
||||
Some(SessionCmd::SetRts(state)) => {
|
||||
self.handle_set_rts(state);
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
@@ -332,6 +356,28 @@ impl Session {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_set_dtr(&mut self, state: bool) {
|
||||
match self.conn.as_mut() {
|
||||
Some(conn) => {
|
||||
if let Err(err) = conn.set_dtr(state) {
|
||||
self.emit_error(format!("set_dtr: {err}"));
|
||||
}
|
||||
}
|
||||
None => self.emit_error(String::from("set_dtr: session not connected")),
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_set_rts(&mut self, state: bool) {
|
||||
match self.conn.as_mut() {
|
||||
Some(conn) => {
|
||||
if let Err(err) = conn.set_rts(state) {
|
||||
self.emit_error(format!("set_rts: {err}"));
|
||||
}
|
||||
}
|
||||
None => self.emit_error(String::from("set_rts: session not connected")),
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_read_result(
|
||||
&mut self,
|
||||
result: Result<Vec<DecodedEntry>, std::io::Error>,
|
||||
|
||||
Reference in New Issue
Block a user