Skip to content
TheChatArchiveThe Chat Archive
Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)Hugging Face OpenAssistant Conversations (oasst2)

I have an embedded application written in Rust (so using #![no_std]). I am using the…

In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
  1. User

    I have an embedded application written in Rust (so using #![no_std]). I am using the embassy (https://embassy.dev/) as my async runtime. In my program I have two tasks: one data acquisition task, and a data processing task. I want the data gathered in the acquisition task to find its way inside the data processing task. Ideally, I want to only react on new data, as shown in the example below. What are some idiomatic ways to do so? Here's a rough idea of how my code looks like:

    #[embassy_executor::task]
    async fn data_acquisition(mut used_peripherals: UsedPeripherals) {
        let data = sample_data(&mut used_peripherals).await;
        // Now I want to access the data in another task.
    }
    
    #[embassy_executor::task]
    async fn data_processing() {
        // Somehow wait for new data.
        // Do stuff with the received data.
    }
    
  2. Assistant

    There are a few ways to do this. One way is to use a channel. A channel is a way for two tasks to communicate with each other. You can create a channel and then send the data from the data acquisition task to the data processing task. The data processing task can then subscribe to the channel and receive the data as it becomes available.

    Another way to do this is to use a shared variable. A shared variable is a variable that is accessible to all tasks in the program. You can create a shared variable and then write the data to the variable from the data acquisition task. The data processing task can then read the data from the variable.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.