# Listen for USB input



## kr651129 (Dec 3, 2013)

I have a hardward device coming in through USB, I'd like the terminal to display the input.  How would I go about doing this?


----------



## fonz (Dec 3, 2013)

It sounds to me like you need/want to snoop USB traffic. I don't know whether there's anything in the ports tree that can do that. If not, you're probably going to need to hook a few system calls in the kernel, which would be an interesting and educational exercise if you've never done such a thing before.

Thanks for the interesting question, by the way. I've got a USB device here (*) that comes only with Windows drivers, so for quite a while now I've been wanting to figure out how to snoop USB traffic and analyse it in order to reverse-engineer the communication protocol so I can create an open-source driver (and front-end) for it.

Ad (*): If you must know, it's an electronic variometer used in paragliding :h


----------



## protocelt (Dec 4, 2013)

I have no experience with it, but would usbdump(8) possibly work?


----------



## wblock@ (Dec 4, 2013)

What kind of hardware device?  usbhidaction(1) can do things with uhid(4) devices.  I'd link to the foot pedal thread, but this terrible forum software seems to have no global search and the links are broken.


----------



## protocelt (Dec 4, 2013)

wblock@ said:
			
		

> What kind of hardware device?  usbhidaction(1) can do things with uhid(4) devices.  I'd link to the foot pedal thread, but this terrible forum software seems to have no global search and the links are broken.



Foot pedal thread: https://forums.freebsd.org/viewtopic.php?f=46&t=41439

That came in handy by the way so thanks for that post.


----------



## fonz (Dec 4, 2013)

protocelt said:
			
		

> I have no experience with it, but would usbdump(8) possibly work?


I really thought I had already posted this, but apparently something went funky. Anyway: thanks for the suggestion! I wasn't even aware of that utility, even though it's in the base system.  :r


----------



## kr651129 (Dec 4, 2013)

wblock@ said:
			
		

> What kind of hardware device?  usbhidaction(1) can do things with uhid(4) devices.  I'd link to the foot pedal thread, but this terrible forum software seems to have no global search and the links are broken.



My wife got me a makey-makey for my birthday a while ago and I haven't had a chance to play with it yet.  It's essentially a USB keyboard/mouse that works out of the box on most systems.  It allows me to turn anything that will conduct a current into a touch device.  By default it just supports up, down, left, right, left click, right click, and space.  I just wanted to see some output to see if it's working.  Later I plan on listening to this device through a Java application I'll write to have a few "touch devices" at my desk that will have it execute commands I run a lot, restart my firewall, and other trivial things.



			
				fonz said:
			
		

> It sounds to me like you need/want to snoop USB traffic. I don't know whether there's anything in the ports tree that can do that. If not, you're probably going to need to hook a few system calls in the kernel, which would be an interesting and educational exercise if you've never done such a thing before.
> 
> Thanks for the interesting question, by the way. I've got a USB device here (*) that comes only with Windows drivers, so for quite a while now I've been wanting to figure out how to snoop USB traffic and analyse it in order to reverse-engineer the communication protocol so I can create an open-source driver (and front-end) for it.
> 
> Ad (*): If you must know, it's an electronic variometer used in paragliding :h



Haha, you just outlined the main reason I love *BSD/Linux over Windows.  You can say what you did and assume people will at the very least know what you're talking about.  The same conversation with a lot of Windows users would have a reply with something along these lines "Ummm, so I should reboot the machine" /flamebait


----------



## fonz (Dec 4, 2013)

kr651129 said:
			
		

> The same conversation with a lot of Windows users would have a reply with something along these lines "Ummm, so I should reboot the machine" /flamebait


To be fair, most Windows users don't need to understand such things because their gizmos come with Windows drivers and Windows front-end applications so they don't even need to know what actually makes it work


----------



## kr651129 (Dec 4, 2013)

fonz said:
			
		

> kr651129 said:
> 
> 
> 
> ...



I'll take my own bait here....I have this conversation with my wife all the time.  You don't NEED to know how your car works.  But it sure is a lot cheaper to know how to change your own oil or know how to fix your car with a quick and dirty hack when you're on the side of the highway so you can at least get it to a shop   That being said, you're right


----------



## fonz (Dec 4, 2013)

kr651129 said:
			
		

> fonz said:
> 
> 
> 
> > I have this conversation with my wife all the time.  You don't NEED to know how your car works.  But it sure is a lot cheaper to know how to change your own oil or know how to fix your car with a quick and dirty hack when you're on the side of the highway so you can at least get it to a shop


If she's your wife, doesn't she have you to change the oil and look after the car for her?  P  §e


----------



## kr651129 (Dec 4, 2013)

fonz said:
			
		

> kr651129 said:
> 
> 
> 
> ...



Checkmate, well played sir, well played  :beergrin


----------

