read/write data on usb weather station WMR100

Roland Smith rsmith at xs4all.nl
Mon Nov 23 20:04:28 UTC 2009


On Mon, Nov 23, 2009 at 07:41:31PM +0100, Olivier GARNIER wrote:
> Roland Smith a écrit :
> > On Mon, Nov 23, 2009 at 02:57:27PM +0100, Olivier GARNIER wrote:
> >   
> >> Hi,
> >>
> >> I have an usb weather station (oregon wmr100).
> >> It's an usb device only.
> >> I want to be able to get data from it (T°, H°, wind, ...)
> >>     
> > This machine probably only comes with windoze software? If you don't know the
> > protocol for data exchange used between the hard- and software it might be
> > difficult getting it to work on FreeBSD.
> >   
> I've found some internet site witch speak about it. I've asked oregon, 
> but they do not want to talk about it...

They want to keep it a secret. Pretty stupid, IMHO. 

Maybe you'll find this interesting:
http://groups.google.com/group/usb_net/web/oregon-scientific-wmr100a-weather-station-usb-api-documentation?version=23

> > There seems to be a Linux program (WeatherD) that works with this
> > station. Maybe you can get that to work? Or you could try running the windows
> > softere under emulators/wine.
> >   
> Yes, but i want to get back data and put it in a postgresql database, 
> and i found no way to use it as i want.
> >> I tried to use libusb to make a c software but it seems not to work 
> >> (exemple witch are in /usr/ports/devel/libusb/work/...test/ do not work).
> >>     
> > Can you elaborate a bit? This is too little info for anyone to help you.
> > If you plug the device in, do you see an ugen device being created? What does
> > dmesg report?
> >   
> When I plug in and out the device that's what i see :
> uhid0: <vendor 0x0fde Universal Bridge, class 0/0, rev 1.10/3.02, addr 
> 2> on uhub0
> uhid0: at uhub0 port 1 (addr 2) disconnected
> uhid0: detached

Ok, if it uses the HID procotol, you don't need libusb. You can use the
ioctl(2) calls as specified in the uhid(4) manual page.

It might be helpfull to read the USB HID page on Wikipedia;
http://en.wikipedia.org/wiki/USB_human_interface_device_class
This page also has a link to the full specification of this protocol, among
other resources.

> # pkg_info | grep libusb
> libusb-0.1.12_4     Library giving userland programs access to USB devices

I have the same one here. Works fine (used by xsane and gphoto2)

> # cd /usr/ports/devel/libusb/work/libusb-0.1.12/tests
> #  ./descriptor_test
> bus/device  idVendor/idProduct
> # ./find_hubs
> Class/SubClass/Protocol
> #  ./find_mice
> idVendor/idProduct/bcdDevice
> # ./get_resolution
> idVendor/idProduct/bcdDevice
> # ./hub_strings
> Class/SubClass/Protocol
> #./id_test
> bus/device  idVendor/idProduct/bcdDevice  Class/SubClass/Protocol
> # ./testlibusb

You'd have to look at the source code to see why these programs return empty
output. 

> As it does not work i tried this i named test.c :

That is because it has quite a lot of bugs. :-)

> #include <usb.h>
> // discover devices
> libusb_device **list;

That should be 'struct usb_device **list;'

> libusb_device *found = NULL;

And 'struct usb_device *found = NULL;'

> ssize_t cnt = libusb_get_device_list(NULL, &list);

Should be 'ssize_t cnt = usb_get_device_list(NULL, &list);'

Generally, the function and structure names in usb.h start with 'usb_', not
'libusb_'.

I don't see a main() function in your code either...

> ssize_t i = 0;
> int err = 0;
> if (cnt < 0)
>   error();
> for (i = 0; i < cnt; i++) {
>   libusb_device *device = list[i];
struct usb_device *device = list[i];

>   if (is_interesting(device)) {

This function is missing in your code fragment...

>     found = device;
>     break;
>   }
>  }
> if (found) {
>   libusb_device_handle *handle;
>   err = libusb_open(found, &handle);

Should be:

struct usb_device_handle handle;
err = usb_open(&handle);

Hope this helps.

Roland
-- 
R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20091123/8b116cd0/attachment.pgp


More information about the freebsd-questions mailing list