mirror of
https://github.com/ratspeak/rsReticulum
synced 2026-11-27 13:52:16 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8c1446b93 |
No files matched your search
@@ -1677,7 +1677,9 @@
|
||||
"requirement": "~1.4.0",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"features": [
|
||||
"serial"
|
||||
],
|
||||
"sourceKind": "path"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1152,6 +1152,7 @@ impl rns_interface::serial::SerialConfig
|
||||
pub fn rns_interface::serial::SerialConfig::baud(self, u32) -> Self
|
||||
pub fn rns_interface::serial::SerialConfig::new(&str, &str) -> Self
|
||||
pub const rns_interface::serial::DEFAULT_BAUD: u32
|
||||
pub fn rns_interface::serial::open_port(serialport::SerialPortBuilder) -> serialport::Result<alloc::boxed::Box<dyn serialport::SerialPort>>
|
||||
pub fn rns_interface::serial::serial_params_from(u8, &str, u8) -> (serialport::DataBits, serialport::Parity, serialport::StopBits)
|
||||
pub async fn rns_interface::serial::spawn_serial_interface(rns_interface::serial::SerialConfig, rns_interface::traits::InterfaceId, tokio::sync::mpsc::bounded::Sender<rns_transport::messages::TransportMessage>) -> core::result::Result<rns_interface::traits::InterfaceHandle, rns_interface::traits::InterfaceError>
|
||||
pub mod rns_interface::socket_tuning
|
||||
|
||||
+2
-2
@@ -78,8 +78,8 @@
|
||||
"tier": "candidate-stable",
|
||||
"compatibility": "reviewed-snapshot",
|
||||
"snapshot": "api/snapshots/rns-interface.txt",
|
||||
"itemCount": 1440,
|
||||
"sha256": "2954226f79c76dd7f3e743d5a36e6895ef5e21dcd16b4fd5544be2932953e7a8"
|
||||
"itemCount": 1441,
|
||||
"sha256": "141d84e59832531aa63990634d6044f79ddb7ed9bdc41aaf2b95833f7b14e7cb"
|
||||
},
|
||||
{
|
||||
"name": "rns-runtime",
|
||||
|
||||
@@ -245,15 +245,16 @@ pub async fn spawn_ax25kiss_interface(
|
||||
|
||||
let (data_bits, parity, stop_bits) =
|
||||
crate::serial::serial_params_from(config.data_bits, &config.parity, config.stop_bits);
|
||||
let port = serialport::new(&config.port, config.baud_rate)
|
||||
.data_bits(data_bits)
|
||||
.parity(parity)
|
||||
.stop_bits(stop_bits)
|
||||
.timeout(Duration::from_millis(AX25_READ_TIMEOUT_MS))
|
||||
.open()
|
||||
.map_err(|e| {
|
||||
crate::traits::InterfaceError::SendFailed(format!("ax25kiss serial open: {}", e))
|
||||
})?;
|
||||
let port = crate::serial::open_port(
|
||||
serialport::new(&config.port, config.baud_rate)
|
||||
.data_bits(data_bits)
|
||||
.parity(parity)
|
||||
.stop_bits(stop_bits)
|
||||
.timeout(Duration::from_millis(AX25_READ_TIMEOUT_MS)),
|
||||
)
|
||||
.map_err(|e| {
|
||||
crate::traits::InterfaceError::SendFailed(format!("ax25kiss serial open: {}", e))
|
||||
})?;
|
||||
|
||||
tracing::info!(
|
||||
name = %config.name,
|
||||
|
||||
@@ -77,15 +77,14 @@ pub async fn spawn_kiss_interface(
|
||||
id: InterfaceId,
|
||||
transport_tx: mpsc::Sender<TransportMessage>,
|
||||
) -> Result<InterfaceHandle, crate::traits::InterfaceError> {
|
||||
let port = serialport::new(&config.port, config.baud_rate)
|
||||
.data_bits(config.data_bits)
|
||||
.parity(config.parity)
|
||||
.stop_bits(config.stop_bits)
|
||||
.timeout(Duration::from_millis(KISS_READ_TIMEOUT_MS))
|
||||
.open()
|
||||
.map_err(|e| {
|
||||
crate::traits::InterfaceError::SendFailed(format!("kiss serial open: {}", e))
|
||||
})?;
|
||||
let port = crate::serial::open_port(
|
||||
serialport::new(&config.port, config.baud_rate)
|
||||
.data_bits(config.data_bits)
|
||||
.parity(config.parity)
|
||||
.stop_bits(config.stop_bits)
|
||||
.timeout(Duration::from_millis(KISS_READ_TIMEOUT_MS)),
|
||||
)
|
||||
.map_err(|e| crate::traits::InterfaceError::SendFailed(format!("kiss serial open: {}", e)))?;
|
||||
|
||||
spawn_kiss_with_port(config, id, transport_tx, port).await
|
||||
}
|
||||
|
||||
@@ -2372,10 +2372,10 @@ impl RNodeStream {
|
||||
/// Open a serial device at `baud` with the shared read timeout.
|
||||
#[cfg(feature = "serial")]
|
||||
pub fn open_serial(path: &str, baud: u32) -> std::io::Result<Self> {
|
||||
let port = serialport::new(path, baud)
|
||||
.timeout(Duration::from_millis(RNODE_READ_TIMEOUT_MS))
|
||||
.open()
|
||||
.map_err(std::io::Error::other)?;
|
||||
let port = crate::serial::open_port(
|
||||
serialport::new(path, baud).timeout(Duration::from_millis(RNODE_READ_TIMEOUT_MS)),
|
||||
)
|
||||
.map_err(std::io::Error::other)?;
|
||||
Ok(Self {
|
||||
link: Box::new(SerialLink(port)),
|
||||
})
|
||||
|
||||
@@ -720,10 +720,11 @@ pub async fn spawn_rnode_multi_interface(
|
||||
}
|
||||
}
|
||||
|
||||
let port = serialport::new(&config.port, config.baud_rate)
|
||||
.timeout(Duration::from_millis(RNODE_READ_TIMEOUT_MS))
|
||||
.open()
|
||||
.map_err(|e| InterfaceError::SendFailed(format!("RNodeMulti open: {}", e)))?;
|
||||
let port = crate::serial::open_port(
|
||||
serialport::new(&config.port, config.baud_rate)
|
||||
.timeout(Duration::from_millis(RNODE_READ_TIMEOUT_MS)),
|
||||
)
|
||||
.map_err(|e| InterfaceError::SendFailed(format!("RNodeMulti open: {}", e)))?;
|
||||
|
||||
tracing::info!(
|
||||
name = %config.name,
|
||||
|
||||
@@ -17,6 +17,18 @@ pub const DEFAULT_BAUD: u32 = 9600;
|
||||
|
||||
const SERIAL_READ_TIMEOUT_MS: u64 = 100;
|
||||
|
||||
/// Open with DTR and RTS asserted, as POSIX `open()` and pyserial do. Windows
|
||||
/// otherwise leaves both low, and TinyUSB CDC (nRF52 RNodes) sends nothing
|
||||
/// until DTR is up. DTR rises first: RTS alone resets ESP32 auto-reset wiring.
|
||||
pub fn open_port(
|
||||
builder: serialport::SerialPortBuilder,
|
||||
) -> serialport::Result<Box<dyn serialport::SerialPort>> {
|
||||
let mut port = builder.dtr_on_open(true).open()?;
|
||||
// Best effort, like `dtr_on_open`: some adapters have no RTS line.
|
||||
let _ = port.write_request_to_send(true);
|
||||
Ok(port)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SerialConfig {
|
||||
pub name: String,
|
||||
@@ -84,13 +96,14 @@ pub async fn spawn_serial_interface(
|
||||
) -> Result<InterfaceHandle, crate::traits::InterfaceError> {
|
||||
let transport_tx = InterfaceTransportSender::new(id, transport_tx);
|
||||
let owner = transport_tx.owner();
|
||||
let port = serialport::new(&config.port, config.baud_rate)
|
||||
.data_bits(config.data_bits)
|
||||
.parity(config.parity)
|
||||
.stop_bits(config.stop_bits)
|
||||
.timeout(Duration::from_millis(SERIAL_READ_TIMEOUT_MS))
|
||||
.open()
|
||||
.map_err(|e| crate::traits::InterfaceError::SendFailed(format!("serial open: {}", e)))?;
|
||||
let port = open_port(
|
||||
serialport::new(&config.port, config.baud_rate)
|
||||
.data_bits(config.data_bits)
|
||||
.parity(config.parity)
|
||||
.stop_bits(config.stop_bits)
|
||||
.timeout(Duration::from_millis(SERIAL_READ_TIMEOUT_MS)),
|
||||
)
|
||||
.map_err(|e| crate::traits::InterfaceError::SendFailed(format!("serial open: {}", e)))?;
|
||||
|
||||
tracing::info!(
|
||||
name = %config.name,
|
||||
|
||||
@@ -14,7 +14,7 @@ hardware = ["dep:rns-ratkey"]
|
||||
|
||||
[dependencies]
|
||||
rns-runtime = { workspace = true, features = ["serial"] }
|
||||
rns-interface = { workspace = true }
|
||||
rns-interface = { workspace = true, features = ["serial"] }
|
||||
rns-identity = { workspace = true }
|
||||
rns-transport = { workspace = true }
|
||||
rns-crypto = { workspace = true, features = ["std"] }
|
||||
|
||||
@@ -331,10 +331,9 @@ pub(crate) fn main() -> ExitCode {
|
||||
return ExitCode::from(2);
|
||||
};
|
||||
|
||||
let port = match serialport::new(port_path.to_string_lossy(), 115200)
|
||||
.timeout(Duration::from_millis(250))
|
||||
.open()
|
||||
{
|
||||
let port = match rns_interface::serial::open_port(
|
||||
serialport::new(port_path.to_string_lossy(), 115200).timeout(Duration::from_millis(250)),
|
||||
) {
|
||||
Ok(port) => port,
|
||||
Err(e) => {
|
||||
eprintln!("rnodeconf-rs: could not open {}: {e}", port_path.display());
|
||||
|
||||
Reference in new issue
Block a user