Skip to content

Commit e0cb9ab

Browse files
committed
Fixes to get GitHub Actions passing again
- Includes a temporary hidio_test() function to debug hid-io-kiibohd
1 parent 7b3c25c commit e0cb9ab

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

.github/workflows/rust_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
- uses: actions-rs/cargo@v1
152152
with:
153153
command: build
154-
args: --manifest-path hid-io-protocol/Cargo.toml --target thumbv7em-none-eabi --no-default-features --features device --release
154+
args: --manifest-path hid-io-protocol/Cargo.toml --no-default-features --features device --release
155155

156156
fmt:
157157
name: Rustfmt

hid-io-kiibohd/src/lib.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,38 @@ pub extern "C" fn hidio_txbyte_bufsize() -> u16 {
196196
<TxBuf as Unsigned>::to_u16()
197197
}
198198

199+
#[no_mangle]
200+
pub extern "C" fn hidio_test() {
201+
let ids = [
202+
HidIoCommandID::SupportedIDs,
203+
HidIoCommandID::GetInfo,
204+
HidIoCommandID::TestPacket,
205+
HidIoCommandID::ManufacturingTest,
206+
];
207+
208+
let config = HidioConfig {
209+
device_name: String::<U256>::from("Test").as_ptr() as *mut c_char,
210+
device_mcu: String::<U256>::from("Test").as_ptr() as *mut c_char,
211+
device_serial_number: String::<U256>::from("Test").as_ptr() as *mut c_char,
212+
firmware_version: String::<U256>::from("Test").as_ptr() as *mut c_char,
213+
firmware_vendor: String::<U256>::from("Test").as_ptr() as *mut c_char,
214+
};
215+
216+
unsafe {
217+
INTF = Some(match CommandInterface::<TxBuf, RxBuf, BufChunk, MessageLen, SerializationLen, IdLen>::new(&ids, config) {
218+
Ok(intf) => intf,
219+
Err(CommandError::IdVecTooSmall) => {
220+
return;
221+
}
222+
Err(_) => {
223+
// TODO Convert errors properly
224+
//HIDIO_ERROR.copy_from_slice("ERROR TODO".as_bytes());
225+
return;
226+
}
227+
});
228+
}
229+
}
230+
199231
/// Initialized the hid-io CommandInterface
200232
#[no_mangle]
201233
pub extern "C" fn hidio_init(config: HidioConfig) -> HidioStatus {

hid-io-protocol/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ edition = "2018"
1818

1919
[lib]
2020
name = "hid_io_protocol"
21-
crate-type = ["rlib", "staticlib"]
2221

2322

2423
[features]
@@ -36,7 +35,7 @@ server = ["log", "bincode_core/std"]
3635

3736
[dependencies]
3837
arraydeque = { version = "^0.4", default-features = false }
39-
bincode_core = { git = "https://github.com/bincode-org/bincode-core.git", default-features = false }
38+
bincode_core = { git = "https://github.com/bincode-org/bincode-core.git" }
4039
heapless = { version = "^0.5" }
4140
log = { version = "^0.4", default-features = false, optional = true }
4241
num_enum = { version = "^0.5", default-features = false }

hid-io-protocol/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use heapless::Vec;
4040
use num_enum::{IntoPrimitive, TryFromPrimitive};
4141
use serde::ser::{self, Serialize, SerializeSeq, Serializer};
4242

43+
#[cfg(all(not(test), target_feature = "thumb-mode"))]
4344
#[cfg(feature = "device")]
4445
use core::panic::PanicInfo;
4546

@@ -685,7 +686,9 @@ impl<H: ArrayLength<u8>> HidIoPacketBuffer<H> {
685686

686687
// Make sure serialization worked
687688
len = writer.written_len();
688-
if self.ptype == HidIoPacketType::Sync && len < 2 || self.ptype != HidIoPacketType::Sync && len < 5 {
689+
if self.ptype == HidIoPacketType::Sync && len < 2
690+
|| self.ptype != HidIoPacketType::Sync && len < 5
691+
{
689692
error!(
690693
"Serialization too small: {} -> {:02X?}",
691694
len,
@@ -943,11 +946,12 @@ impl<H: ArrayLength<u8>> fmt::Display for HidIoPacketBuffer<H> {
943946
}
944947
}
945948

946-
//#[cfg(all(not(test), target_feature = "thumb-mode"))]
949+
#[cfg(all(not(test), target_feature = "thumb-mode"))]
947950
#[cfg(all(not(test), feature = "device"))]
948951
#[lang = "eh_personality"]
949952
fn eh_personality() {}
950953

954+
#[cfg(all(not(test), target_feature = "thumb-mode"))]
951955
#[cfg(all(not(test), feature = "device"))]
952956
#[panic_handler]
953957
fn panic(_info: &PanicInfo) -> ! {

0 commit comments

Comments
 (0)