Commit 288307a637b18e6f28d4408cb3172a68171f73ed
Committed by
GitHub
Merge pull request #169 from nbuchwitz/devel/initialize-after-match
Skip devices which don't match filter criteria
Showing
1 changed file
with
18 additions
and
15 deletions
main.c
| ... | ... | @@ -132,7 +132,23 @@ libusb_device_handle * LIBUSB_CALL open_device_with_vid( |
| 132 | 132 | const char *second_stage; |
| 133 | 133 | |
| 134 | 134 | if(verbose == 2) |
| 135 | - printf("Found candidate Compute Module..."); | |
| 135 | + printf("Found candidate Compute Module...\n"); | |
| 136 | + | |
| 137 | + // Check if we should match against a specific port number or path | |
| 138 | + if ((targetPortNo == 99 || portNo == targetPortNo) && | |
| 139 | + (targetpathname == NULL || strcmp(targetpathname, pathname) == 0)) | |
| 140 | + { | |
| 141 | + if(verbose) | |
| 142 | + printf("Device located successfully\n"); | |
| 143 | + found = dev; | |
| 144 | + } | |
| 145 | + else | |
| 146 | + { | |
| 147 | + if(verbose == 2) | |
| 148 | + printf("Device port / path does not match, trying again\n"); | |
| 149 | + | |
| 150 | + continue; | |
| 151 | + } | |
| 136 | 152 | |
| 137 | 153 | bcm2711 = (desc.idProduct == 0x2711); |
| 138 | 154 | if (bcm2711) |
| ... | ... | @@ -169,21 +185,8 @@ libusb_device_handle * LIBUSB_CALL open_device_with_vid( |
| 169 | 185 | if (fp_sign) |
| 170 | 186 | fclose(fp_sign); |
| 171 | 187 | |
| 172 | - /////////////////////////////////////////////////////////////////////// | |
| 173 | - // Check if we should match against a specific port number | |
| 174 | - /////////////////////////////////////////////////////////////////////// | |
| 175 | - if ((targetPortNo == 99 || portNo == targetPortNo) && | |
| 176 | - (targetpathname==NULL||strcmp(targetpathname,pathname)==0)) | |
| 177 | - { | |
| 178 | - if(verbose) printf("Device located successfully\n"); | |
| 179 | - found = dev; | |
| 188 | + if (found) | |
| 180 | 189 | break; |
| 181 | - } | |
| 182 | - else | |
| 183 | - { | |
| 184 | - if(verbose == 2) | |
| 185 | - printf("...Wrong Port/Path, Trying again\n"); | |
| 186 | - } | |
| 187 | 190 | } |
| 188 | 191 | } |
| 189 | 192 | } | ... | ... |