USB communication on FreeBSD

General discussion on mikroC.
Post Reply
Author
Message
Matjaz
Posts: 12
Joined: 15 Dec 2010 12:59

USB communication on FreeBSD

#1 Post by Matjaz » 10 Feb 2011 10:29

I wrote a program in C that communicates with my MikroMMB for PIC18FJ board over USB (standard HID device). It works without a problem on Linux (Ubuntu 10.10) by reading and writing to /dev/hidrawX device. But I need it to work on FreeBSD (version 8.1) as well. Unfortunately, there I can only read from /dev/uhidX but can not write to the same device (nothing comes to the board). I have tried several methods but nothing seems to work and Google in not much of a help either. Does anyone have any experience with USB communication on FreeBSD? A working example would be ideal.

Matjaz
Posts: 12
Joined: 15 Dec 2010 12:59

Re: USB communication on FreeBSD

#2 Post by Matjaz » 10 Feb 2011 22:30

Finally I figured it out. I'm posting my solution here if someone will need something similar someday.

FreeBSD in addition to /dev/uhidY device also creates two devices in /dev/usb/, namely /dev/usb/X.X.0 and /dev/usb/X.X.1. First one is for reading and second one for writing data to the USB device. By looking at the output of dmesg, one may notice that the USB device is recognized as uhidY and also ugenX.X. The later gives you a hint which /dev/usb/X.X.* device you should look at.

Post Reply

Return to “mikroC General”