This repository was archived by the owner on Dec 15, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -78,12 +78,29 @@ fn main() {
78
78
fn run ( ) -> Result < ( ) > {
79
79
let matches = App :: new ( "itmdump" )
80
80
. version ( include_str ! ( concat!( env!( "OUT_DIR" ) , "/commit-info.txt" ) ) )
81
- . arg ( Arg :: with_name ( "PATH" ) . help ( "Named pipe to use" ) . required ( true ) )
81
+ . arg ( Arg :: with_name ( "PATH" )
82
+ . help ( "Named pipe to use" )
83
+ . required ( true ) )
84
+ . arg ( Arg :: with_name ( "port" )
85
+ . long ( "stimulus" )
86
+ . short ( "s" )
87
+ . help ( "Stimulus port to extract ITM data for." )
88
+ . takes_value ( true )
89
+ . default_value ( "0" )
90
+ . validator ( |s| match s. parse :: < u8 > ( ) {
91
+ Ok ( _) => Ok ( ( ) ) ,
92
+ Err ( e) => Err ( e. to_string ( ) )
93
+ } ) )
82
94
. get_matches ( ) ;
83
95
84
96
let pipe = PathBuf :: from ( matches. value_of ( "PATH" ) . unwrap ( ) ) ;
85
97
let pipe_ = pipe. display ( ) ;
86
98
99
+ let stim_port = matches. value_of ( "port" )
100
+ . unwrap ( ) // We supplied a default value
101
+ . parse :: < u8 > ( )
102
+ . expect ( "Arg validator should ensure this parses" ) ;
103
+
87
104
if pipe. exists ( ) {
88
105
try!( fs:: remove_file ( & pipe)
89
106
. chain_err ( || format ! ( "couldn't remove {}" , pipe_) ) ) ;
@@ -130,8 +147,8 @@ fn run() -> Result<()> {
130
147
try!( stream. read_exact ( ref_slice_mut ( & mut header) ) ) ;
131
148
let port = header >> 3 ;
132
149
133
- // Ignore all the packets that don't come from the stimulus port 0
134
- if port != 0 {
150
+ // Ignore packets not from the chosen stimulus port
151
+ if port != stim_port {
135
152
return Ok ( ( ) ) ;
136
153
}
137
154
You can’t perform that action at this time.
0 commit comments