<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[James's Programming Page — Works on Linux, but only as root?]]></title>
	<link rel="self" href="https://swforum.seekye.com/feed/atom/topic/10068/" />
	<updated>2013-06-18T14:58:07Z</updated>
	<generator>PunBB</generator>
	<id>https://swforum.seekye.com/topic/10068/</id>
		<entry>
			<title type="html"><![CDATA[Re: Works on Linux, but only as root?]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12918/#p12918" />
			<content type="html"><![CDATA[<p>&quot;On a side note&quot; was the issue. It looks like I might have introduced this error when trying to debug. I apologize&nbsp; for wasting your time.</p><p>Just for future generations, here are my udev rules, which I needed to access as non-root:</p><p>SUBSYSTEM==&quot;usb&quot;, ATTR{idVendor}==&quot;1234&quot;, ATTR{idProduct}==&quot;1111&quot;, MODE=&quot;0660&quot;, GROUP=&quot;plugdev&quot;<br />KERNEL==&quot;hidraw*&quot;, ATTRS{idVendor}==&quot;1234&quot;, ATTRS{idProduct}==&quot;1111&quot;, MODE=&quot;0666&quot;, GROUP=&quot;plugdev&quot;</p><p>Thanks for the great code!</p>]]></content>
			<author>
				<name><![CDATA[dblank]]></name>
				<uri>https://swforum.seekye.com/user/14133/</uri>
			</author>
			<updated>2013-06-18T14:58:07Z</updated>
			<id>https://swforum.seekye.com/post/12918/#p12918</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Works on Linux, but only as root?]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12917/#p12917" />
			<content type="html"><![CDATA[<p>Ah, come to think of it, it may need to be subsystem hidraw not usb in udev.</p><p>I&#039;ll investigate the permissions this weekend. All of my tests on Linux (32-bit Ubuntu) have been as root. Some folks use the library on Raspberry Pi as well, but that&#039;s always root.</p><p>GetInfo... GetInfo queries both udev as well as trying to open the hidraw device to get the report descriptor (for the Input, Output, and Feature report lengths, mainly). So if it has no permission to open the hidraw device, it can&#039;t enumerate it successfully. You are sure you have permissions to /dev/hidraw0?</p><p>On a side note, the TryCreateDevice code you have there has the GetInfo condition reversed from my code -- it&#039;s supposed to fail on false not true. What version are you using?</p>]]></content>
			<author>
				<name><![CDATA[Zer]]></name>
				<uri>https://swforum.seekye.com/user/2/</uri>
			</author>
			<updated>2013-06-14T15:29:02Z</updated>
			<id>https://swforum.seekye.com/post/12917/#p12917</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Works on Linux, but only as root?]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12916/#p12916" />
			<content type="html"><![CDATA[<p>Yes, I did everything necessary to be able to read on the Linux side. But still, I had to make the above change.</p>]]></content>
			<author>
				<name><![CDATA[dblank]]></name>
				<uri>https://swforum.seekye.com/user/14133/</uri>
			</author>
			<updated>2013-06-14T15:11:51Z</updated>
			<id>https://swforum.seekye.com/post/12916/#p12916</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Works on Linux, but only as root?]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12915/#p12915" />
			<content type="html"><![CDATA[<p>Sorry for the delayed response.</p><p>Hmm. I will investigate this weekend. Read-only, I assume you are only able to read HID packets but not write them?</p><p>See what your permissions on /dev/hidraw0 are. By default, yes, it requires root. This is one way Linux differs rather drastically from (say) Windows where anyone can access any HID device any time. See <a href="http://askubuntu.com/questions/15570/configure-udev-to-change-permissions-on-usb-hid-device">http://askubuntu.com/questions/15570/co … hid-device</a> for how to configure udev otherwise.</p>]]></content>
			<author>
				<name><![CDATA[Zer]]></name>
				<uri>https://swforum.seekye.com/user/2/</uri>
			</author>
			<updated>2013-06-14T15:09:35Z</updated>
			<id>https://swforum.seekye.com/post/12915/#p12915</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Works on Linux, but only as root?]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12914/#p12914" />
			<content type="html"><![CDATA[<p>Actually, the solution ended up to be commenting out the following bits:</p><p>protected override bool TryCreateDevice(object key, out HidDevice device, out object creationState)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; creationState = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string syspath = (string)key; var hidDevice = new LinuxHidDevice(syspath);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool info = hidDevice.GetInfo();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if (info) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; &nbsp; device = null; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; &nbsp; return false; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; device = hidDevice; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return true;<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>and then it works for root and regular users.</p>]]></content>
			<author>
				<name><![CDATA[dblank]]></name>
				<uri>https://swforum.seekye.com/user/14133/</uri>
			</author>
			<updated>2013-06-09T15:09:23Z</updated>
			<id>https://swforum.seekye.com/post/12914/#p12914</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Works on Linux, but only as root?]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12913/#p12913" />
			<content type="html"><![CDATA[<p>I have found that if I change TryParseReportDescriptor in NativeMethods.cs from:</p><p>int handle = NativeMethods.retry(() =&gt; NativeMethods.open<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (devnode, NativeMethods.oflag.NONBLOCK));</p><p>to:</p><p>int handle = NativeMethods.retry(() =&gt; NativeMethods.open<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (devnode, NativeMethods.oflag.RDONLY));</p><p>Then it works. Is this a valid solution?</p>]]></content>
			<author>
				<name><![CDATA[dblank]]></name>
				<uri>https://swforum.seekye.com/user/14133/</uri>
			</author>
			<updated>2013-06-08T20:01:47Z</updated>
			<id>https://swforum.seekye.com/post/12913/#p12913</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Works on Linux, but only as root?]]></title>
			<link rel="alternate" href="https://swforum.seekye.com/post/12912/#p12912" />
			<content type="html"><![CDATA[<p>Hi, I just downloaded HidSharp and compiled the solution on Linux. I had to change the Target to &quot;.NET 3.5&quot; for all projects, but it compiled and ran.</p><p>However, it fails unless I run as root. It appears that something requires permissions, but I can&#039;t tell what. Here are some more details.</p><p>Any advice or hints would be appreciated!</p><p>-Doug</p><p>$ ls -al /dev/bus/usb/002/009 crw-rwxr-- 1 root plugdev 189, 136 Jun&nbsp; 8 14:20 /dev/bus/usb/002/009</p><p>$ mono HidSharp.Test.exe<br />Complete device list (took 73 ms to get 0 devices):</p><p>Opening HID class device...<br />Failed to open device.</p><p>$ sudo mono HidSharp.Test.exe<br />Complete device list (took 90 ms to get 2 devices):<br />BirdBrain Tools Finch (VID 9044, PID 4369, version 266)<br />(unnamed) (VID 16700, PID 33121, version 512)</p><p>Opening HID class device...<br />BirdBrain Tools Finch (VID 9044, PID 4369, version 266)<br />(unnamed) (VID 16700, PID 33121, version 512)</p><p>Max Lengths:<br />&nbsp; Input:&nbsp; &nbsp;9<br />&nbsp; Output:&nbsp; 2<br />&nbsp; Feature: 0</p><p>The operating system name for this device is:<br />&nbsp; /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6/2-1.6.1/2-1.6.1:1.0/0003:413C:8161.0001/hidraw/hidraw0</p>]]></content>
			<author>
				<name><![CDATA[dblank]]></name>
				<uri>https://swforum.seekye.com/user/14133/</uri>
			</author>
			<updated>2013-06-08T19:24:33Z</updated>
			<id>https://swforum.seekye.com/post/12912/#p12912</id>
		</entry>
</feed>
