1

Topic: HidStream.Write throwing Timeout Exception

I've checked the other threads about this in the discussions, but still have not made any progress on my own project.

I have a CSAFE Fitness device that I am trying to control - the protocol is Master-led and the Slave does not even respond unless it gets a good command.  However, I can't even get HIDSharp to even send without throwing a timeout.

Here is my code:

            var usbDeviceList = DeviceList.Local;
            var Concept2Devices = usbDeviceList.GetHidDevices(0x17a4).ToArray();

            HidDevice _c2 = Concept2Devices[0];

            Console.WriteLine("HidDevice:");
            Console.WriteLine(_c2.ToString() + " @ " + _c2.DevicePath);
            Console.WriteLine(_c2.GetFileSystemName());
            Console.WriteLine(_c2.GetFriendlyName());
            Console.WriteLine(_c2.GetHashCode());
            Console.WriteLine(_c2.GetType());
            Console.WriteLine();

            ReportDescriptor reportDescriptor = _c2.GetReportDescriptor();
            DeviceItem deviceItem = reportDescriptor.DeviceItems[0];

            Report ReportTwo = deviceItem.Reports[1];

            Console.WriteLine("Report 0x02:");
            Console.WriteLine(string.Format("{0}: ReportID={1}, Length={2}, Items={3}",
                                ReportTwo.ReportType, ReportTwo.ReportID, ReportTwo.Length, ReportTwo.DataItems.Count));
            Console.WriteLine();

            DataItem ReportTwoData = ReportTwo.DataItems[0];

            Console.WriteLine("Data 0:");
            Console.WriteLine(string.Format("  {0} Elements x {1} Bits, Units: {2}, Expected Usage Type: {3}, Flags: {4}, Usages: {5}",
                ReportTwoData.ElementCount, ReportTwoData.ElementBits, ReportTwoData.Unit.System, ReportTwoData.ExpectedUsageType, ReportTwoData.Flags,
                string.Join(", ", ReportTwoData.Usages.GetAllValues().Select(usage => usage.ToString("X4") + " " + ((Usage)usage).ToString()))));
            Console.WriteLine();
            Console.WriteLine();

            HidStream DeviceStream;
            if (_c2.TryOpen(out DeviceStream)) Console.WriteLine("Connection Open...\n");

            Console.WriteLine("HidStream:");
            Console.WriteLine("CanWrite: {0}", DeviceStream.CanWrite);
            Console.WriteLine("CanRead: {0}", DeviceStream.CanRead);
            Console.WriteLine("CanSeek: {0}", DeviceStream.CanSeek);
            Console.WriteLine("CanTimeout: {0}", DeviceStream.CanTimeout);
            Console.WriteLine("Device: {0}", DeviceStream.Device);
            //Console.WriteLine("Length: {0}", DeviceStream.Length);  //Throws
            //Console.WriteLine("Position: {0}", DeviceStream.Position);  //Throws
            Console.WriteLine("ReadTimeout: {0}", DeviceStream.ReadTimeout);
            Console.WriteLine("Tag: {0}", DeviceStream.Tag);
            Console.WriteLine("WriteTimeout: {0}", DeviceStream.WriteTimeout);
            Console.WriteLine();

            byte[] SetHoriz = new byte[] { 0x21, 0x03, 0x02, 0x00, 0x21 };                       //(CSAFE_SETHORIZONTAL_CMD, 2 x Km units specifier)

            SimpleDumpHex(SetHoriz);

            FormatTX(0x02, SetHoriz, out byte[] TxData);
            SimpleDumpHex(TxData);

            Console.Read();
            DeviceStream.Write(TxData, 0, TxData.Length);  // Timeout Exception

The DeviceStream.Write command times out after 3 seconds.

Here's the output of everything before that:

HidDevice:
Concept2 Concept2 Performance Monitor 5 (PM5) 430444103 (VID 6052, PID 10, version 1.0) @ \\?\hid#vid_17a4&pid_000a#9&344d321d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
\\?\hid#vid_17a4&pid_000a#9&344d321d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Concept2 Performance Monitor 5 (PM5)
46104728
HidSharp.Platform.Windows.WinHidDevice

Report 0x02:
Input: ReportID=2, Length=501, Items=2

Data 0:
  120 Elements x 8 Bits, Units: None, Expected Usage Type: 0, Flags: Variable, Usages: FFA000A9 4288676009


Connection Open...

HidStream:
CanWrite: True
CanRead: True
CanSeek: False
CanTimeout: True
Device: Concept2 Concept2 Performance Monitor 5 (PM5) 430444103 (VID 6052, PID 10, version 1.0)
ReadTimeout: 3000
Tag:
WriteTimeout: 3000

21 03 02 00 21
02 F1 21 03 02 00 21 01 F2

I have some other example code with references to the protocol and communicating with this device, so I know that I need to write to Report 0x02 - but that's about all the information I have.

Is there anything that you could possibly see that I am doing wrong?

I have not even gotten to reading data yet...


Thanks.

2

Re: HidStream.Write throwing Timeout Exception

SO!  Just for giggles I tried running this on another computer (just grabbed my laptop and ran out of the build folder)... and it worked.  It sent fine.

So, now I guess the debugging comes down to why my workstation cannot send.

Both computers are running Windows 10, where should I even start looking to see why it does not work on my workstation?


Thanks in advance!