<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[James's Programming Page — HidSharp stream.Write throws an exception]]></title>
		<link>https://swforum.seekye.com/topic/10086/</link>
		<atom:link href="https://swforum.seekye.com/feed/rss/topic/10086/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in HidSharp stream.Write throws an exception.]]></description>
		<lastBuildDate>Fri, 11 Mar 2016 16:49:36 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: HidSharp stream.Write throws an exception]]></title>
			<link>https://swforum.seekye.com/post/12950/#p12950</link>
			<description><![CDATA[<p>What Report ID are you trying to write to? Packets need to include that as the first byte, or 0 if there is no Report ID.</p>]]></description>
			<author><![CDATA[null@example.com (Zer)]]></author>
			<pubDate>Fri, 11 Mar 2016 16:49:36 +0000</pubDate>
			<guid>https://swforum.seekye.com/post/12950/#p12950</guid>
		</item>
		<item>
			<title><![CDATA[HidSharp stream.Write throws an exception]]></title>
			<link>https://swforum.seekye.com/post/12947/#p12947</link>
			<description><![CDATA[<p>Just started using HidSharp, and love the elegant simplicity of finding devices.</p><p>I can succesfully find my device, Open it and attach it to a HidStream<br />If I do Read&#039;s on it as in the demo programs, they timeout as expected because my device will not return any data until it has recd a command.</p><p>So when I try to send it a command using stream.Write&nbsp; it always ends up with thisException:<br />&nbsp; An unhandled exception of type &#039;System.IO.IOException&#039; occurred in HidSharp.dll<br />&nbsp; Additional information: Operation failed early.</p><p>Its simple enough that I cannot see what I am doing wrong.&nbsp; Running on Windows10 and VS2013.&nbsp; I can duplicate the behavior from HidSharp.Test in CS.&nbsp; And also from my own app in CPP using HidSharp.dll as a reference.</p><p>After the stream is open I do<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var bytesout = System.Text.Encoding.ASCII.GetBytes(&quot;CFGR0&quot;); <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.Write(bytesout);</p><p>More detail below...<br />Would appreciate any help figuring this out.<br />Thanks <br />Daraius</p><br /><p>If I break in the debugger it ends up in<br />&lt;NativeMethods.cs&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; public unsafe static void OverlappedOperation(IntPtr ioHandle,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntPtr eventHandle, int eventTimeout, IntPtr closeEventHandle,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool overlapResult,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NativeOverlapped* overlapped, out uint bytesTransferred)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool closed = false;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!overlapResult)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int win32Error = Marshal.GetLastWin32Error();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (win32Error != NativeMethods.ERROR_IO_PENDING)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw new IOException(&quot;Operation failed early.&quot;, new Win32Exception());<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntPtr* handles = stackalloc IntPtr[2];</p>]]></description>
			<author><![CDATA[null@example.com (daraius)]]></author>
			<pubDate>Fri, 26 Feb 2016 18:09:11 +0000</pubDate>
			<guid>https://swforum.seekye.com/post/12947/#p12947</guid>
		</item>
	</channel>
</rss>
