File tree Expand file tree Collapse file tree 3 files changed +32
-10
lines changed Expand file tree Collapse file tree 3 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ OPTIONS:
131
131
-l, --logfile <LOGFILE> Log file path [default: /var/log/aa-proxy-rs.log]
132
132
-s, --stats-interval <SECONDS> Interval of showing data transfer statistics (0 = disabled)
133
133
[default: 0]
134
+ -u, --udc <UDCNAME> Specify UDC Controller to use
134
135
-V, --version Print version information
135
136
```
136
137
Most options are self explanatory, but these needs some more attention:<br >
Original file line number Diff line number Diff line change @@ -57,6 +57,14 @@ struct Args {
57
57
/// Interval of showing data transfer statistics (0 = disabled)
58
58
#[ clap( short, long, value_name = "SECONDS" , default_value_t = 0 ) ]
59
59
stats_interval : u16 ,
60
+
61
+ /// UDC Controller name
62
+ #[ clap(
63
+ short,
64
+ long
65
+ ) ]
66
+ udc : Option < String > ,
67
+
60
68
}
61
69
62
70
fn logging_init ( debug : bool , log_path : & PathBuf ) {
@@ -106,6 +114,7 @@ async fn tokio_main(
106
114
advertise : bool ,
107
115
legacy : bool ,
108
116
connect : Option < Address > ,
117
+ udc : Option < String > ,
109
118
need_restart : Arc < Notify > ,
110
119
tcp_start : Arc < Notify > ,
111
120
) {
@@ -117,7 +126,7 @@ async fn tokio_main(
117
126
std:: thread:: spawn ( || uevent_listener ( accessory_started_cloned) ) ;
118
127
}
119
128
120
- let mut usb = UsbGadgetState :: new ( legacy) ;
129
+ let mut usb = UsbGadgetState :: new ( legacy, udc ) ;
121
130
loop {
122
131
if let Err ( e) = usb. init ( ) {
123
132
error ! ( "{} 🔌 USB init error: {}" , NAME , e) ;
@@ -203,6 +212,7 @@ fn main() {
203
212
args. advertise ,
204
213
args. legacy ,
205
214
args. connect ,
215
+ args. udc ,
206
216
need_restart,
207
217
tcp_start,
208
218
)
Original file line number Diff line number Diff line change @@ -53,27 +53,38 @@ pub struct UsbGadgetState {
53
53
configfs_path : PathBuf ,
54
54
udc_name : String ,
55
55
legacy : bool ,
56
+ udc : Option < String > ,
56
57
}
57
58
58
59
impl UsbGadgetState {
59
- pub fn new ( legacy : bool ) -> UsbGadgetState {
60
+ pub fn new ( legacy : bool , udc : Option < String > ) -> UsbGadgetState {
60
61
let mut state = UsbGadgetState {
61
62
configfs_path : PathBuf :: from ( "/sys/kernel/config/usb_gadget" ) ,
62
63
udc_name : String :: new ( ) ,
63
64
legacy,
65
+ udc
64
66
} ;
65
67
66
- let udc_dir = PathBuf :: from ( "/sys/class/udc" ) ;
67
- if let Ok ( entries) = fs:: read_dir ( & udc_dir) {
68
- for entry in entries {
69
- if let Ok ( entry) = entry {
70
- info ! ( "Using UDC: {:?}" , entry. file_name( ) ) ;
71
- if let Ok ( fname) = entry. file_name ( ) . into_string ( ) {
72
- state. udc_name . push_str ( fname. as_str ( ) ) ;
73
- break ;
68
+ // If UDC argument is passed, use it, otherwise check sys
69
+ match state. udc {
70
+ None => {
71
+ let udc_dir = PathBuf :: from ( "/sys/class/udc" ) ;
72
+ if let Ok ( entries) = fs:: read_dir ( & udc_dir) {
73
+ for entry in entries {
74
+ if let Ok ( entry) = entry {
75
+ info ! ( "Using UDC: {:?}" , entry. file_name( ) ) ;
76
+ if let Ok ( fname) = entry. file_name ( ) . into_string ( ) {
77
+ state. udc_name . push_str ( fname. as_str ( ) ) ;
78
+ break ;
79
+ }
80
+ }
74
81
}
75
82
}
76
83
}
84
+ Some ( ref udcname) => {
85
+ info ! ( "Using UDC: {:?}" , udcname) ;
86
+ state. udc_name . push_str ( & udcname) ;
87
+ }
77
88
}
78
89
79
90
return state;
You can’t perform that action at this time.
0 commit comments