Skip to content

Commit

Permalink
Attempt to fix in relation to #2, release 25.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JaciBrunning committed Jan 13, 2025
1 parent 1ca5f04 commit aec1b4d
Show file tree
Hide file tree
Showing 14 changed files with 752 additions and 20 deletions.
4 changes: 3 additions & 1 deletion grapple-hook/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grapple-hook",
"private": true,
"version": "25.0.0",
"version": "25.0.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -22,8 +22,10 @@
"immutability-helper": "^3.1.1",
"json-schema-to-typescript": "^13.0.1",
"node-sass": "^8.0.0",
"prism-react-renderer": "^2.4.1",
"react": "^18.2.0",
"react-bootstrap": "^2.7.2",
"react-code-blocks": "^0.1.6",
"react-confirm": "^0.3.0-2",
"react-dom": "^18.2.0",
"react-slider": "^2.0.5",
Expand Down
199 changes: 197 additions & 2 deletions grapple-hook/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"old_version_req",
"old_version_rsp",
"provider_manager_req",
"provider_manager_rsp"
"provider_manager_rsp",
"roborio_req",
"roborio_rsp"
],
"properties": {
"firmware_req": {
Expand Down Expand Up @@ -52,6 +54,12 @@
},
"provider_manager_rsp": {
"$ref": "#/definitions/ProviderManagerResponse"
},
"roborio_req": {
"$ref": "#/definitions/RoboRioDaemonRequest"
},
"roborio_rsp": {
"$ref": "#/definitions/RoboRioDaemonResponse"
}
},
"definitions": {
Expand Down Expand Up @@ -1581,7 +1589,8 @@
"required": [
"address",
"connected",
"description"
"description",
"ty"
],
"properties": {
"address": {
Expand All @@ -1592,6 +1601,9 @@
},
"description": {
"type": "string"
},
"ty": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -1734,6 +1746,149 @@
}
]
},
"RoboRIOStatus": {
"type": "object",
"required": [
"using_daemon"
],
"properties": {
"using_daemon": {
"type": "boolean"
}
}
},
"RoboRioDaemonRequest": {
"oneOf": [
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": {
"type": "object"
},
"method": {
"type": "string",
"enum": [
"status"
]
}
}
},
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": {
"type": "object",
"required": [
"use_daemon"
],
"properties": {
"use_daemon": {
"type": "boolean"
}
}
},
"method": {
"type": "string",
"enum": [
"set_use_daemon"
]
}
}
},
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": {
"type": "object",
"required": [
"address"
],
"properties": {
"address": {
"type": "string"
}
}
},
"method": {
"type": "string",
"enum": [
"set_address"
]
}
}
}
]
},
"RoboRioDaemonResponse": {
"oneOf": [
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": {
"$ref": "#/definitions/RoboRIOStatus"
},
"method": {
"type": "string",
"enum": [
"status"
]
}
}
},
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": {
"type": "null"
},
"method": {
"type": "string",
"enum": [
"set_use_daemon"
]
}
}
},
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": {
"type": "null"
},
"method": {
"type": "string",
"enum": [
"set_address"
]
}
}
}
]
},
"WrappedDeviceProviderRequest": {
"oneOf": [
{
Expand Down Expand Up @@ -1815,6 +1970,30 @@
]
}
}
},
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": {
"type": "object",
"required": [
"req"
],
"properties": {
"req": true
}
},
"method": {
"type": "string",
"enum": [
"call"
]
}
}
}
]
},
Expand Down Expand Up @@ -1891,6 +2070,22 @@
]
}
}
},
{
"type": "object",
"required": [
"data",
"method"
],
"properties": {
"data": true,
"method": {
"type": "string",
"enum": [
"call"
]
}
}
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion grapple-hook/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion grapple-hook/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "grapple-hook"
version = "25.0.0"
version = "25.0.1"
description = "Configuration Tool for Grapple Hardware"
authors = ["Jaci Brunning <[email protected]>"]
license = "GPLv3"
Expand Down
5 changes: 4 additions & 1 deletion grapple-hook/src-tauri/src/bin/gen-schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{path::Path, fs, env};

use grapple_hook::devices::{flexican::{FlexiCanRequest, FlexiCanResponse}, lasercan::{LaserCanRequest, LaserCanResponse}, mitocandria::{MitocandriaRequest, MitocandriaResponse}, provider_manager::{ProviderManagerRequest, ProviderManagerResponse}, FirmwareUpgradeDeviceRequest, FirmwareUpgradeDeviceResponse, OldVersionDeviceRequest, OldVersionDeviceResponse};
use grapple_hook::devices::{flexican::{FlexiCanRequest, FlexiCanResponse}, lasercan::{LaserCanRequest, LaserCanResponse}, mitocandria::{MitocandriaRequest, MitocandriaResponse}, provider_manager::{ProviderManagerRequest, ProviderManagerResponse}, roborio::daemon::{RoboRioDaemonRequest, RoboRioDaemonResponse}, FirmwareUpgradeDeviceRequest, FirmwareUpgradeDeviceResponse, OldVersionDeviceRequest, OldVersionDeviceResponse};

#[derive(schemars::JsonSchema)]
#[allow(unused)]
Expand All @@ -22,6 +22,9 @@ struct MegaSchema {

mitocandria_req: MitocandriaRequest,
mitocandria_rsp: MitocandriaResponse,

roborio_req: RoboRioDaemonRequest,
roborio_rsp: RoboRioDaemonResponse,
}

fn main() -> anyhow::Result<()> {
Expand Down
6 changes: 6 additions & 0 deletions grapple-hook/src-tauri/src/devices/generic_usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bounded_static::ToBoundedStatic;
use futures::{SinkExt, StreamExt};
use grapple_frc_msgs::{binmarshal::{AsymmetricCow, BitView, BitWriter, BufferBitWriter, Demarshal, Marshal, MarshalUpdate}, bridge::BridgedCANMessage, grapple::{fragments::FragmentReassembler, GrappleMessageId, TaggedGrappleMessage}, ManufacturerMessage};
use log::{info, warn};
use serde_json::json;
use tokio::sync::{mpsc, Mutex};
use tokio_serial::{SerialPort, SerialStream, UsbPortInfo};
use tokio_util::codec::Framed;
Expand Down Expand Up @@ -149,12 +150,17 @@ impl DeviceProvider for GenericUSB {

async fn info(&self) -> anyhow::Result<ProviderInfo> {
Ok(ProviderInfo {
ty: "Generic-USB".to_owned(),
description: "Grapple USB Device".to_owned(),
address: self.inner.address.clone(),
connected: self.inner.running.load(std::sync::atomic::Ordering::Relaxed)
})
}

async fn call(&self, _req: serde_json::Value) -> anyhow::Result<serde_json::Value> {
Ok(json!({}))
}

async fn device_manager_call(&self, req: DeviceManagerRequest) -> anyhow::Result<DeviceManagerResponse> {
self.inner.device_manager.rpc_process(req).await
}
Expand Down
6 changes: 6 additions & 0 deletions grapple-hook/src-tauri/src/devices/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use super::device_manager::{DeviceManagerRequest, DeviceManagerResponse};

#[derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
pub struct ProviderInfo {
pub ty: String,
pub description: String,
pub address: String,
pub connected: bool,
Expand All @@ -17,6 +18,7 @@ pub trait DeviceProvider {
async fn disconnect(&self) -> anyhow::Result<()>;
async fn info(&self) -> anyhow::Result<ProviderInfo>;

async fn call(&self, req: serde_json::Value) -> anyhow::Result<serde_json::Value>;
async fn device_manager_call(&self, req: DeviceManagerRequest) -> anyhow::Result<DeviceManagerResponse>;
}

Expand Down Expand Up @@ -47,4 +49,8 @@ impl WrappedDeviceProvider {
pub async fn device_manager_call(&self, req: DeviceManagerRequest) -> anyhow::Result<DeviceManagerResponse> {
self.inner.device_manager_call(req).await
}

async fn call(&self, req: serde_json::Value) -> anyhow::Result<serde_json::Value> {
self.inner.call(req).await
}
}
Loading

0 comments on commit aec1b4d

Please sign in to comment.