<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[James's Programming Page — HidSharp stream.Write throws an exception]]></title>
	<link rel="self" href="https://swforum.seekye.com/feed/atom/topic/10086/" />
	<updated>2016-03-11T16:49:36Z</updated>
	<generator>PunBB</generator>
	<id>https://swforum.seekye.com/topic/10086/</id>
		<entry>
			<title type="html"><![CDATA[Re: HidSharp stream.Write throws an exception]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12950/#p12950" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Zer]]></name>
				<uri>https://swforum.seekye.com/user/2/</uri>
			</author>
			<updated>2016-03-11T16:49:36Z</updated>
			<id>https://swforum.seekye.com/post/12950/#p12950</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[HidSharp stream.Write throws an exception]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12947/#p12947" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[daraius]]></name>
				<uri>https://swforum.seekye.com/user/14179/</uri>
			</author>
			<updated>2016-02-26T18:09:11Z</updated>
			<id>https://swforum.seekye.com/post/12947/#p12947</id>
		</entry>
</feed>
