@@ -309,57 +309,55 @@ public void ResetToIdle()
309
309
/// </summary>
310
310
public void Manifest ( )
311
311
{
312
- Status status ;
313
-
314
312
// After the zero length DFU_DNLOAD request terminates the Transfer phase,
315
313
// the device is ready to manifest the new firmware.
316
314
Dnload ( 0 , new byte [ 0 ] ) ;
317
315
318
- // If the device enters dfuMANIFEST-SYNC (bitMainfestationTolerant = 1),
319
- // then the host issues the DFU_GETSTATUS request, and the device enters the dfuIDLE state.
320
- // At that point, the host can perform another download, solicit an upload, or issue a USB reset
321
- // to return the device to application run-time mode.
322
- if ( DfuDescriptor . ManifestationTolerant )
316
+ try
323
317
{
318
+ // wait until manifesting completes
319
+ Status status ;
324
320
for ( status = GetStatus ( ) ; status . State == State . Manifest ; status = GetStatus ( ) )
325
321
{
326
322
Thread . Sleep ( status . PollTimeout ) ;
327
323
}
328
324
329
- VerifyState ( status , State . Idle ) ;
330
-
331
- BusReset ( ) ;
332
- }
333
- // If, however, the device enters the dfuMANIFEST-WAIT-RESET state (bitManifestationTolerant = 0),
334
- // then if bitWillDetach = 1 the device generates a detach-attach sequence on the bus,
335
- // otherwise (bitWillDetach = 0) the host must issue a USB reset to the device.
336
- // After the bus reset the device will evaluate the firmware status and enter the appropriate mode.
337
- else
338
- {
339
- try
325
+ if ( DfuDescriptor . ManifestationTolerant )
340
326
{
341
- for ( status = GetStatus ( ) ; status . State == State . Manifest ; status = GetStatus ( ) )
342
- {
343
- Thread . Sleep ( status . PollTimeout ) ;
344
- }
345
-
346
- VerifyState ( status , State . ManifestWaitReset ) ;
327
+ // If the device enters dfuMANIFEST-SYNC (bitMainfestationTolerant = 1),
328
+ // then the host issues the DFU_GETSTATUS request, and the device enters the dfuIDLE state.
329
+ VerifyState ( status , State . Idle ) ;
347
330
331
+ // At that point, the host can perform another download, solicit an upload, or issue a USB reset
332
+ // to return the device to application run-time mode.
348
333
BusReset ( ) ;
349
334
}
350
- catch ( Exception )
335
+ else
351
336
{
352
- // exceptions due to broken pipe are allowed if the USB device detaches itself
353
- if ( DfuDescriptor . WillDetach )
354
- {
355
- }
356
- else
337
+ // If, however, the device enters the dfuMANIFEST-WAIT-RESET state (bitManifestationTolerant = 0),
338
+ // then if bitWillDetach = 1 the device generates a detach-attach sequence on the bus,
339
+ VerifyState ( status , State . ManifestWaitReset ) ;
340
+
341
+ // otherwise (bitWillDetach = 0) the host must issue a USB reset to the device.
342
+ // After the bus reset the device will evaluate the firmware status and enter the appropriate mode.
343
+ if ( ! DfuDescriptor . WillDetach )
357
344
{
358
- throw ;
345
+ BusReset ( ) ;
359
346
}
360
347
}
361
- Close ( ) ;
362
348
}
349
+ catch ( Exception )
350
+ {
351
+ // exceptions due to broken pipe are allowed if the USB device detaches itself
352
+ if ( ! DfuDescriptor . ManifestationTolerant && DfuDescriptor . WillDetach )
353
+ {
354
+ }
355
+ else
356
+ {
357
+ throw ;
358
+ }
359
+ }
360
+ Close ( ) ;
363
361
}
364
362
365
363
/// <summary>
0 commit comments