diff --git a/interface/src/auto.rs b/interface/src/auto.rs index 2a954f3..7aa55f8 100644 --- a/interface/src/auto.rs +++ b/interface/src/auto.rs @@ -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 anyhow::{Context, Ok, Result}; use eframe::Storage; use libloading::{Library, Symbol}; -use tokio::sync::{self, broadcast, mpsc, watch}; +use tokio::{sync::{self, broadcast, mpsc, watch}, task::JoinHandle}; use crate::storage::StorageManager; @@ -118,7 +118,12 @@ impl Auto { } /// entrypoint - async fn run(&self, interface: &AutoInterface) { + pub async fn run(&self, interface: &AutoInterface) -> Result> { + let func: Symbol Pin + Send>>> = unsafe {self.library.get(b"entry")?}; + + let fut = unsafe { func(interface.clone()) }; + + Ok(tokio::spawn(fut)) } pub fn configs(&self) -> &'static [Configurable] {