You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class CardManager
{
public const int VendorId = 1133;
public const int ProductId = 52475;
//public byte[] data;
private static HidDevice mydevice;
//private static HidDeviceData hidDevice;
//private string devicePath;
//private const int ReportLength = 8;
//public string tString1 { get ; set; }
public HidDevice[] GetAllDevice()
{
var allDeviceList = HidDevices.Enumerate().ToArray();
HidDevice[] device = new HidDevice[allDeviceList.Length];
for (int i = 0; i < allDeviceList.Length; i++)
{
device[i] = allDeviceList[i];
}
return device;
}
public byte[] Close()
{
mydevice = HidDevices.Enumerate(VendorId, ProductId).FirstOrDefault();
mydevice.OpenDevice();
if (mydevice!= null)
{
//devicePath = mydevice.DevicePath;
//mydevice.Inserted += DeviceAttachedHandler;
//mydevice.Removed += DeviceRemovedHandler;
mydevice.MonitorDeviceEvents = true;
// mydevice.ReadReport(OnReport);
var data = new byte[9]
{
0x00,
0x15,
0x00,
0x00,
0x02,
0x19,
0x00,
0x00,
0x00
}; // Lock
mydevice.Write(data);
// mydevice.ReadReport(OnReport);
HidDeviceData carddata = mydevice.Read();
mydevice.CloseDevice();
return carddata.Data;
}
else
{
return null;
}
}
I can write and read to the buffer synchronously, but I want to listen to the device asynchronously in the background and see the incoming data(byte array). Is it possible ?
The text was updated successfully, but these errors were encountered:
I can write and read to the buffer synchronously, but I want to listen to the device asynchronously in the background and see the incoming data(byte array). Is it possible ?
The text was updated successfully, but these errors were encountered: