<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[James's Programming Page — HidStream.Write throwing Timeout Exception]]></title>
	<link rel="self" href="https://swforum.seekye.com/feed/atom/topic/10145/" />
	<updated>2021-01-16T21:00:05Z</updated>
	<generator>PunBB</generator>
	<id>https://swforum.seekye.com/topic/10145/</id>
		<entry>
			<title type="html"><![CDATA[Re: HidStream.Write throwing Timeout Exception]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/13124/#p13124" />
			<content type="html"><![CDATA[<p>SO!&nbsp; Just for giggles I tried running this on another computer (just grabbed my laptop and ran out of the build folder)... and it worked.&nbsp; It sent fine.</p><p>So, now I guess the debugging comes down to why my workstation cannot send.</p><p>Both computers are running Windows 10, where should I even start looking to see why it does not work on my workstation?</p><br /><p>Thanks in advance!</p>]]></content>
			<author>
				<name><![CDATA[RandyF]]></name>
				<uri>https://swforum.seekye.com/user/14345/</uri>
			</author>
			<updated>2021-01-16T21:00:05Z</updated>
			<id>https://swforum.seekye.com/post/13124/#p13124</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[HidStream.Write throwing Timeout Exception]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/13123/#p13123" />
			<content type="html"><![CDATA[<p>I&#039;ve checked the other threads about this in the discussions, but still have not made any progress on my own project.</p><p>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.&nbsp; However, I can&#039;t even get HIDSharp to even send without throwing a timeout.</p><p>Here is my code:<br /></p><div class="codebox"><pre><code>            var usbDeviceList = DeviceList.Local;
            var Concept2Devices = usbDeviceList.GetHidDevices(0x17a4).ToArray();

            HidDevice _c2 = Concept2Devices[0];

            Console.WriteLine(&quot;HidDevice:&quot;);
            Console.WriteLine(_c2.ToString() + &quot; @ &quot; + _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(&quot;Report 0x02:&quot;);
            Console.WriteLine(string.Format(&quot;{0}: ReportID={1}, Length={2}, Items={3}&quot;,
                                ReportTwo.ReportType, ReportTwo.ReportID, ReportTwo.Length, ReportTwo.DataItems.Count));
            Console.WriteLine();

            DataItem ReportTwoData = ReportTwo.DataItems[0];

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

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

            Console.WriteLine(&quot;HidStream:&quot;);
            Console.WriteLine(&quot;CanWrite: {0}&quot;, DeviceStream.CanWrite);
            Console.WriteLine(&quot;CanRead: {0}&quot;, DeviceStream.CanRead);
            Console.WriteLine(&quot;CanSeek: {0}&quot;, DeviceStream.CanSeek);
            Console.WriteLine(&quot;CanTimeout: {0}&quot;, DeviceStream.CanTimeout);
            Console.WriteLine(&quot;Device: {0}&quot;, DeviceStream.Device);
            //Console.WriteLine(&quot;Length: {0}&quot;, DeviceStream.Length);  //Throws
            //Console.WriteLine(&quot;Position: {0}&quot;, DeviceStream.Position);  //Throws
            Console.WriteLine(&quot;ReadTimeout: {0}&quot;, DeviceStream.ReadTimeout);
            Console.WriteLine(&quot;Tag: {0}&quot;, DeviceStream.Tag);
            Console.WriteLine(&quot;WriteTimeout: {0}&quot;, 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</code></pre></div><p>The DeviceStream.Write command times out after 3 seconds.</p><p>Here&#039;s the output of everything before that:<br /></p><div class="codebox"><pre><code>HidDevice:
Concept2 Concept2 Performance Monitor 5 (PM5) 430444103 (VID 6052, PID 10, version 1.0) @ \\?\hid#vid_17a4&amp;pid_000a#9&amp;344d321d&amp;0&amp;0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
\\?\hid#vid_17a4&amp;pid_000a#9&amp;344d321d&amp;0&amp;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</code></pre></div><p>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&#039;s about all the information I have.</p><p>Is there anything that you could possibly see that I am doing wrong?</p><p>I have not even gotten to reading data yet...</p><br /><p>Thanks.</p>]]></content>
			<author>
				<name><![CDATA[RandyF]]></name>
				<uri>https://swforum.seekye.com/user/14345/</uri>
			</author>
			<updated>2021-01-16T20:36:52Z</updated>
			<id>https://swforum.seekye.com/post/13123/#p13123</id>
		</entry>
</feed>
