output_only/
output-only.rs1use anyhow::Result;
5use remote_xy::remote_xy;
6use remote_xy::RemoteXY;
7use serde::Deserialize;
8use serde::Serialize;
9use std::time::Duration;
10
11const CONF_BUF: &[u8] = &[
12 255, 0, 0, 4, 0, 11, 0, 16, 31, 0, 68, 17, 0, 0, 100, 63, 8, 36,
13];
14
15#[derive(Serialize, Deserialize, Default)]
16#[repr(C)]
17struct InputData {
18 }
20
21#[derive(Serialize, Deserialize)]
22#[repr(C)]
23struct OutputData {
24 online_graph_1: f32,
26 }
28
29impl Default for OutputData {
31 fn default() -> Self {
32 Self {
33 online_graph_1: 1.23,
34 }
35 }
36}
37
38#[tokio::main]
39async fn main() -> Result<()> {
40 let remotexy = remote_xy!(InputData, OutputData, "[::]:6377", CONF_BUF).await?;
41 let mut output = OutputData::default();
42 let mut x = 0.0;
43
44 while remotexy.is_connected() == false {
45 tokio::time::sleep(Duration::from_millis(200)).await;
46 }
47
48 println!("Connected to RemoteXY app");
49
50 tokio::time::sleep(Duration::from_millis(2000)).await;
52
53 println!("Starting to send data");
54 loop {
55 output.online_graph_1 = f32::sin(x);
56 remotexy.set_output(&output);
57 x += 0.1;
58
59 tokio::time::sleep(Duration::from_millis(50)).await;
60 }
61}