Compare commits

..

No commits in common. "774f4a9f9e18fdb80a5aeb33f5acbd58d62bea5a" and "1a7f8c4ab18a49bb2808f8700db5b594daa65c0b" have entirely different histories.

3 changed files with 1 additions and 38 deletions

7
Cargo.lock generated
View File

@ -42,11 +42,6 @@ name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hex"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -138,7 +133,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "rn2903"
version = "0.2.0"
dependencies = [
"hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serialport 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -198,7 +192,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
"checksum libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe"

View File

@ -14,5 +14,4 @@ categories = ["api-bindings", "embedded", "hardware-support"]
[dependencies]
serialport = "3.3"
quick-error = "1"
hex = "0.4.2"

View File

@ -32,7 +32,6 @@
// a `Result<T, rn2903::Error>`.
#[macro_use]
extern crate quick_error;
use hex;
use std::io;
quick_error! {
@ -81,16 +80,6 @@ quick_error! {
description(err.description())
from()
}
TransmissionUnsuccessful {
description("the radio transmission was unsuccessful")
display("if transmission was unsuccessful (interrupted by radio Watchdog Timer time-out)")
}
InvalidParam {
description("the parameter is not valid")
display("the parameter is not valid")
}
}
}
@ -214,8 +203,7 @@ impl Rn2903 {
pub fn new(port: Box<dyn SerialPort>) -> Result<Self> {
let mut new = Self::new_unchecked(port);
let version = new.system_version()?;
// RN2483 and RN2903 are the same, just EU and US chip, but talk the same
if &version[0..6] != "RN2903" && &version[0..6] != "RN2483" {
if &version[0..6] != "RN2903" {
Err(Error::WrongDevice(version))
} else {
Ok(new)
@ -477,23 +465,6 @@ impl Rn2903 {
)),
}
}
pub fn radio_tx(&mut self, send: String) -> Result<Option<Vec<u8>>> {
let result = self.transact(&format!("radio tx {}", hex::encode(send)).into_bytes())?;
match &result[..] {
b"ok" => {
let sresult = self.read_line()?;
match &sresult[..] {
b"radio_tx_ok" => return Ok(None),
b"radio_err" => return Err(Error::TransmissionUnsuccessful),
v => return Err(Error::bad_response("nok", bytes_to_string(v))),
}
}
b"invalid_param" => return Err(Error::InvalidParam),
b"busy" => return Err(Error::TransceiverBusy),
v => return Err(Error::bad_response("ok | busy", bytes_to_string(v))),
};
}
}
/// # MAC API Functions