Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Nov 2009 21:04:21 +0100
From:      Roland Smith <rsmith@xs4all.nl>
To:        Olivier GARNIER <oli.garnier@wanadoo.fr>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: read/write data on usb weather station WMR100
Message-ID:  <20091123200421.GA52907@slackbox.xs4all.nl>
In-Reply-To: <4B0AD75B.6090002@wanadoo.fr>
References:  <4B0A94C7.9030400@wanadoo.fr> <20091123174531.GA49267@slackbox.xs4all.nl> <4B0AD75B.6090002@wanadoo.fr>

next in thread | previous in thread | raw e-mail | index | archive | help

--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Nov 23, 2009 at 07:41:31PM +0100, Olivier GARNIER wrote:
> Roland Smith a =E9crit :
> > On Mon, Nov 23, 2009 at 02:57:27PM +0100, Olivier GARNIER wrote:
> >  =20
> >> 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=B0, H=B0, wind, ...)
> >>    =20
> > This machine probably only comes with windoze software? If you don't kn=
ow the
> > protocol for data exchange used between the hard- and software it might=
 be
> > difficult getting it to work on FreeBSD.
> >  =20
> I've found some internet site witch speak about it. I've asked oregon,=20
> but they do not want to talk about it...

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

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

> > 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 w=
indows
> > softere under emulators/wine.
> >  =20
> Yes, but i want to get back data and put it in a postgresql database,=20
> 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=20
> >> (exemple witch are in /usr/ports/devel/libusb/work/...test/ do not wor=
k).
> >>    =20
> > 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? Wha=
t does
> > dmesg report?
> >  =20
> 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=20
> 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.=20

> 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 =3D NULL;

And 'struct usb_device *found =3D NULL;'

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

Should be 'ssize_t cnt =3D 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 =3D 0;
> int err =3D 0;
> if (cnt < 0)
>   error();
> for (i =3D 0; i < cnt; i++) {
>   libusb_device *device =3D list[i];
struct usb_device *device =3D list[i];

>   if (is_interesting(device)) {

This function is missing in your code fragment...

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

Should be:

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

Hope this helps.

Roland
--=20
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)

--OgqxwSJOaUobr8KG
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.13 (FreeBSD)

iEYEARECAAYFAksK6sUACgkQEnfvsMMhpyWaHgCghY3ax/irsgid5tpBLJY+k9G4
7D4Anib9sSwWGGI8/vp+XHmykiNAAIRI
=SDZd
-----END PGP SIGNATURE-----

--OgqxwSJOaUobr8KG--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20091123200421.GA52907>