Search code examples
c#usbscsi

send SCSI commands using C#


I'm controlling my self-designed USB device using SCSI interface with C by opening a file handle, ioctl and using sg_io_hdr_t structure. I have to design a GUI, and i should do that with C#. I am not too familiar with C#. Could u suggest a way to do that with C#


Solution

  • You have a few options

    1- Use p/invoke (platform invoke) interoperability. Using this you can do one of two things. Either use p/invoke to call the Win32 api from .NET, alternatively you can write a C dll that exports a simplified interface to control the device and then interop to this dll.

    2- You could use managed C++, and create a library that you can call from C#.

    3- You could wrap your C code as a COM object and use COM interop from C#.

    Since you presumably have some working C code, I think the easiest would be to create a DLL that exports a easy to invoke interface and then use P/Invoke to call that from C#