-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CONSULT-469] - add more PGN definitions and create sensors #413
base: main
Are you sure you want to change the base?
Changes from 9 commits
22e1b5e
f730299
ac5bd6f
a9c9a84
1cac35a
aea8df0
4d915ee
f286014
9fd3969
db1363a
bdf6d45
fecc351
0cbe95f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ publish = false | |
name = "micrordk" | ||
crate-type = ["staticlib"] # Creates static lib | ||
|
||
[features] | ||
viamboat = ["dep:micro-rdk-nmea"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the intended use for this feature. Is this feature gate just to keep the nmea stuff disabled for now and will be removed down the line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Also we need a better story when we figure out cloud builds on including modules when using micro-rdk as an IDF component |
||
|
||
[target.'cfg(not(target_os = "espidf"))'.dependencies] | ||
env_logger.workspace = true | ||
local-ip-address.workspace = true | ||
|
@@ -26,6 +29,7 @@ embedded-hal.workspace = true | |
embedded-svc.workspace = true | ||
futures-lite.workspace = true | ||
micro-rdk = { workspace = true, features = ["esp32", "data", "data-upload-hook-unstable"], default-features = true } | ||
micro-rdk-nmea = { workspace = true, features = ["esp32"], optional = true } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is |
||
|
||
[dependencies] | ||
base64.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ use micro_rdk::common::{ | |
exec::Executor, | ||
log::initialize_logger, | ||
provisioning::server::ProvisioningInfo, | ||
registry::{ComponentRegistry, Dependency}, | ||
registry::{ComponentRegistry, Dependency, RegistryError}, | ||
sensor::{SensorError, SensorType}, | ||
webrtc::certificate::Certificate, | ||
}; | ||
|
@@ -35,6 +35,21 @@ extern "C" { | |
pub static g_spiram_ok: bool; | ||
} | ||
|
||
macro_rules! generate_register_modules { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love duplicating this, but I agree we don't have a better way right now. Could you please file a follow-up ticket to revisit the module registration system and hopefully eliminate the duplication of this macro and the |
||
($($module:ident),*) => { | ||
#[allow(unused_variables)] | ||
fn register_modules(registry: &mut ComponentRegistry) -> Result<(), RegistryError> { | ||
$( | ||
log::info!("registering micro-rdk module '{}'", stringify!($module)); | ||
$module::register_models(registry)?; | ||
)* | ||
Ok(()) | ||
} | ||
} | ||
} | ||
|
||
include!(concat!(env!("OUT_DIR"), "/modules.rs")); | ||
|
||
/// Creates a new Viam server context | ||
/// | ||
/// Use the returned pointer to register your own components using the C API | ||
|
@@ -43,6 +58,8 @@ extern "C" { | |
#[no_mangle] | ||
pub extern "C" fn init_viam_server_context() -> *mut viam_server_context { | ||
let registry = Box::<ComponentRegistry>::default(); | ||
#[cfg(target_os = "espidf")] | ||
initialize_logger::<micro_rdk::esp32::esp_idf_svc::log::EspLogger>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What prompted moving this here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we missed uploading some logs because we were previously initializing the logger too late |
||
let mut provisioning_info = ProvisioningInfo::default(); | ||
provisioning_info.set_manufacturer("viam".to_owned()); | ||
provisioning_info.set_model("ffi-provisioning".to_owned()); | ||
|
@@ -239,7 +256,7 @@ pub unsafe extern "C" fn viam_server_start(ctx: *mut viam_server_context) -> via | |
return viam_code::VIAM_INVALID_ARG; | ||
} | ||
|
||
let ctx = unsafe { Box::from_raw(ctx) }; | ||
let mut ctx = unsafe { Box::from_raw(ctx) }; | ||
|
||
#[cfg(not(target_os = "espidf"))] | ||
{ | ||
|
@@ -248,7 +265,6 @@ pub unsafe extern "C" fn viam_server_start(ctx: *mut viam_server_context) -> via | |
#[cfg(target_os = "espidf")] | ||
{ | ||
micro_rdk::esp32::esp_idf_svc::sys::link_patches(); | ||
initialize_logger::<micro_rdk::esp32::esp_idf_svc::log::EspLogger>(); | ||
micro_rdk::esp32::esp_idf_svc::sys::esp!(unsafe { | ||
micro_rdk::esp32::esp_idf_svc::sys::esp_vfs_eventfd_register( | ||
µ_rdk::esp32::esp_idf_svc::sys::esp_vfs_eventfd_config_t { max_fds: 5 }, | ||
|
@@ -333,6 +349,10 @@ pub unsafe extern "C" fn viam_server_start(ctx: *mut viam_server_context) -> via | |
storage | ||
}; | ||
|
||
if let Err(e) = register_modules(&mut ctx.registry) { | ||
log::error!("couldn't register modules {:?}", e); | ||
} | ||
|
||
let mut builder = ViamServerBuilder::new(storage); | ||
builder | ||
.with_provisioning_info(ctx.provisioning_info) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ pub(crate) enum UnitConversion { | |
PascalToBar, | ||
RadianToDegree, | ||
RadPerSecToDegPerSec, | ||
MetersPerSecToKnots, | ||
MetersToNauticalMiles, | ||
} | ||
|
||
impl TryFrom<&str> for UnitConversion { | ||
|
@@ -26,6 +28,8 @@ impl TryFrom<&str> for UnitConversion { | |
"C" => Ok(Self::KelvinToCelsius), | ||
"deg" => Ok(Self::RadianToDegree), | ||
"deg/s" => Ok(Self::RadPerSecToDegPerSec), | ||
"knots" => Ok(Self::MetersPerSecToKnots), | ||
"M" => Ok(Self::MetersToNauticalMiles), | ||
x => Err(error_tokens( | ||
format!("encountered unsupported unit {:?}", x).as_str(), | ||
)), | ||
|
@@ -48,6 +52,12 @@ impl UnitConversion { | |
Self::RadianToDegree | Self::RadPerSecToDegPerSec => quote! { | ||
let result = (result as f64) * (180.0 / std::f64::consts::PI); | ||
}, | ||
Self::MetersPerSecToKnots => quote! { | ||
let result = (result as f64) * 1.94384; | ||
}, | ||
Self::MetersToNauticalMiles => quote! { | ||
let result = (result as f64) * 0.539957; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conversion looks off to me. One meter isn't ~1/2 a nautical mile. I think this is doing kilometers to nautical miles. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, my bad |
||
}, | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,17 @@ rust-version.workspace = true | |
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[features] | ||
esp32 = ['micro-rdk/esp32'] | ||
native = ['micro-rdk/native'] | ||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does the NMEA library need to know about esp32 vs native? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because micro-rdk needs to, see https://viam.atlassian.net/browse/RSDK-9710 |
||
|
||
[dependencies] | ||
base64 = { workspace = true } | ||
chrono = { workspace = true } | ||
micro-rdk = { workspace = true, features = ["native"] } | ||
log = { workspace = true } | ||
micro-rdk = { workspace = true } | ||
micro-rdk-nmea-macros = { workspace = true } | ||
thiserror = { workspace = true } | ||
|
||
[package.metadata.com.viam] | ||
module = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, this is now needed because clippy is worked up. It concludes that it doesn't know if
AnalogReaderType
isSend
because of thedyn AnalogReader
.Would it just be easier to declare
AnalogReaderType
aspub type AnalogReaderType<W, E = AnalogError> = Arc<Mutex<dyn AnalogReader<W, Error = E> + Send>>;
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but I was already doing that to Sensor and I wanted to keep the PR small