1+ using System . Diagnostics . CodeAnalysis ;
12using System . Reflection . Metadata ;
23using System . Runtime . InteropServices ;
34using Serilog ;
@@ -14,7 +15,7 @@ public string GetNotes()
1415 "1) To temporarily unload, run \" sudo modprobe -r cdc_acm\" \n " +
1516 "2) To disable it, run \" echo 'blacklist cdc_acm' | sudo tee -a /etc/modprobe.d/cdc_acm-blacklist.conf\" " ;
1617
17- public async Task < List < DeviceInfo > > GetDevices ( ) {
18+ public List < DeviceInfo > GetDevices ( ) {
1819 var list = new List < DeviceInfo > ( ) ;
1920 foreach ( var bus in Directory . EnumerateDirectories ( "/dev/bus/usb/" ) )
2021 foreach ( var device in Directory . EnumerateFiles ( bus ) ) {
@@ -31,7 +32,7 @@ public async Task<List<DeviceInfo>> GetDevices() {
3132 if ( vendor == USB . Vendor ) {
3233 var product = reader . ReadInt16 ( ) ;
3334 list . Add ( new DeviceInfo {
34- DisplayName = await Lookup . GetDisplayName ( vendor , product ) ,
35+ DisplayName = Lookup . GetDisplayName ( vendor , product ) ,
3536 Identifier = device [ 13 ..] . Replace ( "/" , ":" )
3637 } ) ;
3738 }
@@ -276,6 +277,8 @@ public void Dispose() {
276277 _detached = false ;
277278 }
278279
280+ [ SuppressMessage ( "ReSharper" , "InconsistentNaming" ) ]
281+ [ SuppressMessage ( "ReSharper" , "ShiftExpressionZeroLeftOperand" ) ]
279282 public static unsafe class Interop {
280283 private const int _IOC_NRBITS = 8 ;
281284 private const int _IOC_TYPEBITS = 8 ;
@@ -296,15 +299,15 @@ private static uint _IOR(uint type, uint nr, uint size)
296299 private static uint _IOW ( uint type , uint nr , uint size )
297300 => ( 1U << _IOC_DIRSHIFT ) | ( type << _IOC_TYPESHIFT )
298301 | ( nr << _IOC_NRSHIFT ) | ( size << _IOC_SIZESHIFT ) ;
299- public static uint USBDEVFS_SETINTERFACE = _IOR ( 'U' , 4 , ( uint ) sizeof ( SetInterface ) ) ;
300- public static uint USBDEVFS_GETDRIVER = _IOW ( 'U' , 8 , ( uint ) sizeof ( GetDriver ) ) ;
301- public static uint USBDEVFS_BULK = _IOWR ( 'U' , 2 , ( uint ) sizeof ( BulkTransfer ) ) ;
302- public static uint USBDEVFS_IOCTL = _IOWR ( 'U' , 18 , ( uint ) sizeof ( UsbIoCtl ) ) ;
303- public static uint USBDEVFS_RELEASEINTERFACE = _IOR ( 'U' , 16 , sizeof ( uint ) ) ;
304- public static uint USBDEVFS_CLAIMINTERFACE = _IOR ( 'U' , 15 , sizeof ( uint ) ) ;
305- public static uint USBDEVFS_DISCONNECT = _IO ( 'U' , 22 ) ;
306- public static uint USBDEVFS_CONNECT = _IO ( 'U' , 23 ) ;
307- public static uint USBDEVFS_RESET = _IO ( 'U' , 20 ) ;
302+ public static readonly uint USBDEVFS_SETINTERFACE = _IOR ( 'U' , 4 , ( uint ) Marshal . SizeOf < SetInterface > ( ) ) ;
303+ public static readonly uint USBDEVFS_GETDRIVER = _IOW ( 'U' , 8 , ( uint ) Marshal . SizeOf < GetDriver > ( ) ) ;
304+ public static readonly uint USBDEVFS_BULK = _IOWR ( 'U' , 2 , ( uint ) Marshal . SizeOf < BulkTransfer > ( ) ) ;
305+ public static readonly uint USBDEVFS_IOCTL = _IOWR ( 'U' , 18 , ( uint ) Marshal . SizeOf < UsbIoCtl > ( ) ) ;
306+ public static readonly uint USBDEVFS_RELEASEINTERFACE = _IOR ( 'U' , 16 , sizeof ( uint ) ) ;
307+ public static readonly uint USBDEVFS_CLAIMINTERFACE = _IOR ( 'U' , 15 , sizeof ( uint ) ) ;
308+ public static readonly uint USBDEVFS_DISCONNECT = _IO ( 'U' , 22 ) ;
309+ public static readonly uint USBDEVFS_CONNECT = _IO ( 'U' , 23 ) ;
310+ public static readonly uint USBDEVFS_RESET = _IO ( 'U' , 20 ) ;
308311
309312 public struct BulkTransfer {
310313 public uint Endpoint ;
0 commit comments