@@ -484,6 +484,20 @@ pub unsafe extern "C" fn h0001_info_data(info: *mut HidioHostInfo) -> bool {
484
484
}
485
485
} ;
486
486
487
+ // Set string pointers
488
+ intf. hostinfo . os_version = match CUtf8 :: from_str ( intf. os_version . as_str ( ) ) {
489
+ Ok ( cstr) => cstr. as_bytes_with_nul ( ) . as_ptr ( ) as * const c_char ,
490
+ Err ( _) => {
491
+ return false ;
492
+ }
493
+ } ;
494
+ intf. hostinfo . host_software_name = match CUtf8 :: from_str ( intf. host_software_name . as_str ( ) ) {
495
+ Ok ( cstr) => cstr. as_bytes_with_nul ( ) . as_ptr ( ) as * const c_char ,
496
+ Err ( _) => {
497
+ return false ;
498
+ }
499
+ } ;
500
+
487
501
* info = intf. hostinfo . clone ( ) ;
488
502
true
489
503
}
@@ -609,6 +623,46 @@ pub unsafe extern "C" fn hidio_h0034_terminalout(output: *const c_char) -> Hidio
609
623
HidioStatus :: Success
610
624
}
611
625
626
+ /// # Safety
627
+ /// Sends the result of a manufacturing test
628
+ /// Will return an ACK, but this confirmation isn't used
629
+ #[ no_mangle]
630
+ pub unsafe extern "C" fn hidio_h0051_manufacturingres (
631
+ command : u16 ,
632
+ argument : u16 ,
633
+ data : * mut u8 ,
634
+ len : u16 ,
635
+ ) -> HidioStatus {
636
+ use h0051:: * ;
637
+
638
+ // Retrieve interface
639
+ let intf = match INTF . as_mut ( ) {
640
+ Some ( intf) => intf,
641
+ None => {
642
+ return HidioStatus :: ErrorNotInitialized ;
643
+ }
644
+ } ;
645
+
646
+ // Prepare data
647
+ let data = match Vec :: from_slice ( core:: slice:: from_raw_parts ( data, len as usize ) ) {
648
+ Ok ( vec) => vec,
649
+ Err ( _) => {
650
+ return HidioStatus :: ErrorBufSizeTooSmall ;
651
+ }
652
+ } ;
653
+
654
+ // Send command
655
+ if let Err ( err) = intf. h0051_manufacturingres ( Cmd {
656
+ command,
657
+ argument,
658
+ data,
659
+ } ) {
660
+ return intf. error_handler ( err) ;
661
+ }
662
+
663
+ HidioStatus :: Success
664
+ }
665
+
612
666
// ----- Command Interface -----
613
667
614
668
struct CommandInterface <
@@ -675,8 +729,8 @@ where
675
729
minor_version : 0 ,
676
730
patch_version : 0 ,
677
731
os : 0 ,
678
- os_version : os_version . as_ptr ( ) as * const c_char ,
679
- host_software_name : host_software_name . as_ptr ( ) as * const c_char ,
732
+ os_version : core :: ptr :: null ( ) ,
733
+ host_software_name : core :: ptr :: null ( ) ,
680
734
} ;
681
735
682
736
Ok ( CommandInterface {
@@ -1095,4 +1149,8 @@ where
1095
1149
}
1096
1150
}
1097
1151
}
1152
+
1153
+ fn h0051_manufacturingres_ack ( & mut self , _data : h0051:: Ack ) -> Result < ( ) , CommandError > {
1154
+ Ok ( ( ) )
1155
+ }
1098
1156
}
0 commit comments