1
Fork 0

run (untested)

This commit is contained in:
Andy Killorin 2025-03-22 15:27:49 -04:00
parent 321ece84bc
commit b63986711d
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -1,10 +1,10 @@
use std::{collections::VecDeque, ops::{Deref, Div, Index, Range, Sub}, sync::Arc}; use std::{collections::VecDeque, future::Future, ops::{Deref, Div, Index, Range, Sub}, pin::Pin, sync::Arc};
use common::{CamState, ControlPacket, SensorData, TelemetryPacket}; use common::{CamState, ControlPacket, SensorData, TelemetryPacket};
use anyhow::{Context, Ok, Result}; use anyhow::{Context, Ok, Result};
use eframe::Storage; use eframe::Storage;
use libloading::{Library, Symbol}; use libloading::{Library, Symbol};
use tokio::sync::{self, broadcast, mpsc, watch}; use tokio::{sync::{self, broadcast, mpsc, watch}, task::JoinHandle};
use crate::storage::StorageManager; use crate::storage::StorageManager;
@ -118,7 +118,12 @@ impl Auto {
} }
/// entrypoint /// entrypoint
async fn run(&self, interface: &AutoInterface) { pub async fn run(&self, interface: &AutoInterface) -> Result<JoinHandle<()>> {
let func: Symbol<unsafe extern "C" fn(AutoInterface) -> Pin<Box<dyn Future<Output = ()> + Send>>> = unsafe {self.library.get(b"entry")?};
let fut = unsafe { func(interface.clone()) };
Ok(tokio::spawn(fut))
} }
pub fn configs(&self) -> &'static [Configurable] { pub fn configs(&self) -> &'static [Configurable] {