@@ -3,16 +3,12 @@ fn main() {
3
3
. nth ( 1 )
4
4
. expect ( "No firmware filename received" ) ;
5
5
6
- let mut libusb_context: libusb:: Context = libusb:: Context :: new ( ) . unwrap ( ) ;
7
-
8
- libusb_context. set_log_level ( libusb:: LogLevel :: Warning ) ;
9
6
10
7
// See `libusb` output in documentation for where these come from
11
8
const USB_VENDOR_ID : u16 = 0x05a9 ;
12
9
const USB_PRODUCT_ID : u16 = 0x0580 ;
13
10
14
- let mut libusb_dev_handle: libusb:: DeviceHandle = libusb_context
15
- . open_device_with_vid_pid ( USB_VENDOR_ID , USB_PRODUCT_ID )
11
+ let libusb_dev_handle = rusb:: open_device_with_vid_pid ( USB_VENDOR_ID , USB_PRODUCT_ID )
16
12
. unwrap ( ) ;
17
13
18
14
// Device only has one USB 'endpoint'/interface (see `lsusb` output)
@@ -68,9 +64,10 @@ fn main() {
68
64
let upper_transaction_idx = 0x15 ; // 21d
69
65
70
66
/* Goes from 0 to 65536, incrementing by 512. Then, starts over at 0, and continues incrementing.
71
- This is again something that was taken from OrbisEyeCam */
72
- let mut wValue = std:: num:: Wrapping ( std:: u16:: MAX ) ;
73
- wValue. 0 = 0 ;
67
+ This is again something that was taken from OrbisEyeCam
68
+ Corresponds to 'wValue' in standard USB semantics */
69
+ let mut w_value = std:: num:: Wrapping ( std:: u16:: MAX ) ;
70
+ w_value. 0 = 0 ;
74
71
75
72
while file_byte_idx < firmware_file_len {
76
73
let pkt_size = std:: cmp:: min (
@@ -86,21 +83,21 @@ fn main() {
86
83
upper_transaction_idx
87
84
} ;
88
85
89
- let bytes_transferred = libusb_dev_handle
86
+ let _bytes_transferred = libusb_dev_handle
90
87
. write_control (
91
88
USB_OUTGOING_PACKET_BM_REQUEST_TYPE ,
92
89
0x0 ,
93
- wValue . 0 ,
90
+ w_value . 0 ,
94
91
cur_transaction_idx,
95
92
& firmware_file_as_bytes[ file_byte_idx as usize ..pkt_end_idx] ,
96
93
std:: time:: Duration :: ZERO ,
97
94
)
98
95
. unwrap ( ) ;
99
96
100
97
// Careful with this log statement. Logging in between USB transactions can slow things down enough to where it no longer works
101
- //println!("Transferred {} bytes [{} , {}], value= {}, index= {}", bytes_transferred, file_byte_idx, pkt_end_idx, wValue .0, transaction_idx);
98
+ //println!("Transferred {} bytes [{} , {}], value= {}, index= {}", bytes_transferred, file_byte_idx, pkt_end_idx, w_value .0, transaction_idx);
102
99
103
- wValue += pkt_size as u16 ;
100
+ w_value += pkt_size as u16 ;
104
101
file_byte_idx += pkt_size as usize ;
105
102
}
106
103
0 commit comments