List Info

Thread: libusb and hal




libusb and hal
user name
2007-10-09 11:31:29
Hi,

After doing some hacking in pilot-link for the z22 to get to work with libusb (and to work at all, because visor is also no more working), I've already made a (dirty) patch for pilot-link (see the "z22 F7 problem" thread for more details) to get pilot-xfer to work. Now the next problem is gnome-pilot.

It came to my attention that it worked every time the first time the z22 was connected to the computer after a reboot, and it would not work anymore the next times. So I did some investigation and figured the root of the problem.
When the z22 is connected, the hal_device_added function in gpilotd.c is called a few times, each time with different hal information. only one time this part of code will succeed:
if (!(bus = libhal_device_get_property_string (hal_ctx, udi, "info.bus", NULL))) {
   ;     return;
  ;  }
   ; if (strcmp (bus, "usb_device") != 0 ) {
   ;     libhal_free_string (bus);
        return;
  ;  }
So this means gpilotd is waiting for a "usb_device" to be added by hal, which works the first time. ; But the next times the "usb_device" is not added anymore, as this device stays available in hal. Here is a part of the output of hal-device:
0: udi = '/org/freedesktop/Hal/devices/usb_device_830_61_noserial'
 ; linux.subsystem = 'usb' ; (string)
  info.product = 'Palm Handheld'  (string)
  usb_device.device_revision_bcd = 256  (0x100)  (int)
  usb_device.product = 'Palm Handheld'  (string)
  usb_device.product_id = 97  (0x61)  (int)
  usb_device.speed = 12  (double)
  usb_device.vendor = 'Palm, Inc.' ; (string)
  usb_device.can_wake_up = false ; (bool)
  usb_device.configuration_value = 1  (0x1) ; (int)
  usb_device.linux.device_number = 16  (0x10)  (int)
  info.linux.driver = 'usb' ; (string)
  usb_device.device_class = 255  (0xff)  (int)
  info.parent = '/org/freedesktop/Hal/devices/usb_device_0_0_0000_00_02_0'  (string)
  usb_device.bus_number = 2  (0x2) ; (int)
  usb_device.device_protocol = 0  (0x0) ; (int)
  usb_device.is_self_powered = true  (bool)
  info.subsystem = 'usb_device'  (string)
  info.vendor = 'Palm, Inc.' ; (string)
  usb_device.version = 1.1  (double)
  usb_device.num_interfaces = 1  (0x1) ; (int)
  usb_device.vendor_id = 2096  (0x830)  (int)
  usb_device.speed_bcd = 4608  (0x1200)  (int)
  usb_device.version_bcd = 272  (0x110)  (int)
  info.udi = '/org/freedesktop/Hal/devices/usb_device_830_61_noserial'  (string)
  usb_device.linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:02.0/usb2/2-3'  (string)
  usb_device.num_configurations = 1  (0x1) ; (int)
  info.bus = 'usb_device'  (string)
  linux.device_file = '/dev/bus/usb/002/016'  (string)
  usb_device.num_ports = 0  (0x0) ; (int)
  usb_device.max_power = 500  (0x1f4)  (int)
  linux.hotplug_type = 2  (0x2) ; (int)
  usb_device.device_subclass = 0  (0x0) ; (int)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:02.0/usb2/2-3'  (string)

so if I do "hal-device -r /org/freedesktop/Hal/devices/usb_device_830_61_noserial" this item will be removed from the hal list, and the next time I connect my z22 gnome-pilot will work!

So now I know the cause of the problem, but I don't know how to fix this. Should hal normally remove this device? Should gnome-pilot not wait for an "usb_device" but for something else? ... ?

Can somebody help me on this?

Kind regards,
Tom Billiet
Re: libusb and hal
user name
2007-10-09 12:32:45
On Tue, 2007-10-09 at 18:31 +0200, Tom Billiet wrote:
> Hi,
> 
> After doing some hacking in pilot-link for the z22 to
get to work with
> libusb (and to work at all, because visor is also no
more working),
> I've already made a (dirty) patch for pilot-link (see
the "z22 F7
> problem" thread for more details) to get
pilot-xfer to work. Now the
> next problem is gnome-pilot.
> 
> It came to my attention that it worked every time the
first time the
> z22 was connected to the computer after a reboot, and
it would not
> work anymore the next times. So I did some
investigation and figured
> the root of the problem.
> When the z22 is connected, the hal_device_added
function in gpilotd.c
> is called a few times, each time with different hal
information. only
> one time this part of code will succeed:
> if (!(bus = libhal_device_get_property_string (hal_ctx,
udi,
> "info.bus", NULL))) {
>         return;
>     }
>     if (strcmp (bus, "usb_device") != 0 ) {
>         libhal_free_string (bus);
>         return;
>     }
> So this means gpilotd is waiting for a
"usb_device" to be added by
> hal, which works the first time.  But the next times
the "usb_device"
> is not added anymore, as this device stays available in
hal.

Tom,

Thanks for your work on this already.  Are you saying that
the
"usb_device" is only added once, even if you
disconnect the z22
physically from your computer?

Can you watch other HAL events to see what gets generated
when you
attempt a sync?  I'm sure there'll be something we can hook
into, and
then it might be time for gnome-pilot 2.0.16...

Regards,

Matt

Matt Davey        If the rich could hire other people to die
for them, the
mcdaveymrao.cam.ac.uk 	poor could make a wonderful living -
Yiddish Proverb

_______________________________________________
gnome-pilot-list mailing list
gnome-pilot-listgnome.org
http://mail.gnome.org/mailman/listinfo/gnome-pilot-list

Re: libusb and hal
user name
2007-10-09 12:58:55

----- Original Message -----
From: Matt Davey
Time: 09-10-07 19:32
> 
> Tom,
> 
> Thanks for your work on this already.  Are you saying
that the
> "usb_device" is only added once, even if you
disconnect the z22
> physically from your computer?

Exactly.
I must say I have not tried if there is some timeout on
this, that it
will disappear after a time. But even then you would not be
able to sync
between the timeouts.

> 
> Can you watch other HAL events to see what gets
generated when you
> attempt a sync?  I'm sure there'll be something we can
hook into, and
> then it might be time for gnome-pilot 2.0.16...

it seems the hal_device_added is always called at least
twice. One time
it already exits here
if (!(bus = libhal_device_get_property_string (hal_ctx, udi,
"info.bus",
NULL))) {
		return;
	}
So you can't do anything with that I think.

The second time it exits here
if (strcmp (bus, "usb_device") != 0 ) {
	libhal_free_string (bus);
	return;
}
and it seems bus it set to "usb".  My best guess
is that when you get an
adding where bus = usb, you might be able to ask hal if
there is already
a palm "usb_device" available, and if so, use it.
But I have no idea how
to do that 

Regards,
Tom

_______________________________________________
gnome-pilot-list mailing list
gnome-pilot-listgnome.org
http://mail.gnome.org/mailman/listinfo/gnome-pilot-list

Re: libusb and hal
user name
2007-10-09 20:43:29
On Tue, 2007-10-09 at 19:58 +0200, Tom Billiet wrote:
> 
> ----- Original Message -----
> From: Matt Davey
> Time: 09-10-07 19:32
> > 
> > Tom,
> > 
> > Thanks for your work on this already.  Are you
saying that the
> > "usb_device" is only added once, even if
you disconnect the z22
> > physically from your computer?
> 
> Exactly.
> I must say I have not tried if there is some timeout on
this, that it
> will disappear after a time. But even then you would
not be able to sync
> between the timeouts.
> 
> > 
> > Can you watch other HAL events to see what gets
generated when you
> > attempt a sync?  I'm sure there'll be something we
can hook into, and
> > then it might be time for gnome-pilot 2.0.16...
> 
> it seems the hal_device_added is always called at least
twice. One time
> it already exits here
> if (!(bus = libhal_device_get_property_string (hal_ctx,
udi, "info.bus",
> NULL))) {
> 		return;
> 	}
> So you can't do anything with that I think.
> 
> The second time it exits here
> if (strcmp (bus, "usb_device") != 0 ) {
> 	libhal_free_string (bus);
> 	return;
> }
> and it seems bus it set to "usb".  My best
guess is that when you get an
> adding where bus = usb, you might be able to ask hal if
there is already
> a palm "usb_device" available, and if so, use
it. But I have no idea how
> to do that 
> 
> Regards,
> Tom

I don't know beans about USB, but thinking about what you've
described
in this series of e-mails, it seems to me that you need to
beware of the
case of HAL remembering a Palm device that was formerly
attached but is
no longer there.   That in turn makes me think that if HAL
is
remembering a device that is no longer there, then maybe the
problem is
in the HAL logic.   Are the supporters of that code on this
mailing list
or is that a kernel topic?

Drew

_______________________________________________
gnome-pilot-list mailing list
gnome-pilot-listgnome.org
http://mail.gnome.org/mailman/listinfo/gnome-pilot-list

Re: libusb and hal
user name
2007-10-10 04:21:01
On Tue, 2007-10-09 at 21:43 -0400, R. Drew Davis wrote:
> On Tue, 2007-10-09 at 19:58 +0200, Tom Billiet wrote:
> > 
> > ----- Original Message -----
> > From: Matt Davey
> > Time: 09-10-07 19:32
> > > 
> > > Tom,
> > > 
> > > Thanks for your work on this already.  Are
you saying that the
> > > "usb_device" is only added once,
even if you disconnect the z22
> > > physically from your computer?
> > 
> > Exactly.
> > I must say I have not tried if there is some
timeout on this, that it
> > will disappear after a time. But even then you
would not be able to sync
> > between the timeouts.
> > 
> 
> I don't know beans about USB, but thinking about what
you've described
> in this series of e-mails, it seems to me that you need
to beware of the
> case of HAL remembering a Palm device that was formerly
attached but is
> no longer there.   That in turn makes me think that if
HAL is
> remembering a device that is no longer there, then
maybe the problem is
> in the HAL logic.   Are the supporters of that code on
this mailing list
> or is that a kernel topic?

Drew, I agree.  I haven't had time to try reproducing this
yet, but this
feels like a regression in the HAL behaviour.  I know that
multiple
libusb / HAL syncing worked just fine for me.  Either it is
device
specific or is a regression outside of gnome-pilot.

Tom, what HAL version do you have installed?  It would be
great if we
could narrow this down to a HAL change, but I'll fire off a
message to
the hal list once I know what version this behaviour has
been seen in.

Matt


_______________________________________________
gnome-pilot-list mailing list
gnome-pilot-listgnome.org
http://mail.gnome.org/mailman/listinfo/gnome-pilot-list

Re: libusb and hal
user name
2007-10-10 11:13:51

----- Original Message -----
From: Matt Davey
Time: 10-10-07 11:21
> On Tue, 2007-10-09 at 21:43 -0400, R. Drew Davis
wrote:
>> On Tue, 2007-10-09 at 19:58 +0200, Tom Billiet
wrote:
>>> ----- Original Message -----
>>> From: Matt Davey
>>> Time: 09-10-07 19:32
>>>> Tom,
>>>>
>>>> Thanks for your work on this already.  Are
you saying that the
>>>> "usb_device" is only added once,
even if you disconnect the z22
>>>> physically from your computer?
>>> Exactly.
>>> I must say I have not tried if there is some
timeout on this, that it
>>> will disappear after a time. But even then you
would not be able to sync
>>> between the timeouts.
>>>
>> I don't know beans about USB, but thinking about
what you've described
>> in this series of e-mails, it seems to me that you
need to beware of the
>> case of HAL remembering a Palm device that was
formerly attached but is
>> no longer there.   That in turn makes me think that
if HAL is
>> remembering a device that is no longer there, then
maybe the problem is
>> in the HAL logic.   Are the supporters of that code
on this mailing list
>> or is that a kernel topic?
> 
> Drew, I agree.  I haven't had time to try reproducing
this yet, but this
> feels like a regression in the HAL behaviour.  I know
that multiple
> libusb / HAL syncing worked just fine for me.  Either
it is device
> specific or is a regression outside of gnome-pilot.
>
I agree on this too. In my opinion hal should not keep
disconnected
devices, or at least notify again if it's reconnected
> 
> Tom, what HAL version do you have installed?  It would
be great if we
> could narrow this down to a HAL change, but I'll fire
off a message to
> the hal list once I know what version this behaviour
has been seen in.
> 
hal: 0.5.9.1
hal-info: 0.20070831
kernel: 2.6.22-ARCH
udev: 115

I'm using archlinux, which basically means I almost always
have the
latest packages.
If you need any more versions of a certain package, you can
find it
here: http://archlinux.org/packages/search/?sort=-last_update

Regards,
Tom
_______________________________________________
gnome-pilot-list mailing list
gnome-pilot-listgnome.org
http://mail.gnome.org/mailman/listinfo/gnome-pilot-list

Re: libusb and hal
user name
2007-10-13 14:26:13
Hi,

I'm also very interested in how this turns out and am willing to do some testing upon request.

I have seen the same failure where syncing works the first time after boot, but intermittently there after.  I have a Fedora 7 machine that is kept consistently up to date with all patches, including the kernel.  Currently, here is my version info as reported by rpm:

  bash-3.2$ rpm -q hal
  hal-0.5.9-8.fc7
 ; bash-3.2$ rpm -q kernel
  kernel-2.6.22.9-91.fc7
  bash-3.2$ uname -a
  Linux hungover.domain.com 2.6.22.9-91.fc7 #1 SMP Thu Sep 27 20:47:39 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
  bash-3.2$

Thanks,
Brent

On 10/10/07, Tom Billiet < mouse256ulyssis.org">mouse256ulyssis.org> wrote:


----- Original Message -----
From: Matt Davey
Time: 10-10-07 11:21
> On Tue, 2007-10-09 at 21:43 -0400, R. Drew Davis wrote:
>;> On Tue, 2007-10-09 at 19:58 +0200, Tom Billiet wrote:
>;>> ----- Original Message -----
&gt;>> From: Matt Davey
>>> Time: 09-10-07 19:32
>>>>; Tom,
>&gt;>>
>>&gt;> Thanks for your work on this already.&nbsp; Are you saying that the
>&gt;>> "usb_device"; is only added once, even if you disconnect the z22
>>>>; physically from your computer?
>>>; Exactly.
&gt;>> I must say I have not tried if there is some timeout on this, that it
>>;> will disappear after a time. But even then you would not be able to sync
>;>> between the timeouts.
>>>;
>> I don't know beans about USB, but thinking about what you've described
>> in this series of e-mails, it seems to me that you need to beware of the
>> case of HAL remembering a Palm device that was formerly attached but is
>>; no longer there.&nbsp;  That in turn makes me think that if HAL is
>>; remembering a device that is no longer there, then maybe the problem is
>&gt; in the HAL logic.&nbsp;  Are the supporters of that code on this mailing list
>&gt; or is that a kernel topic?
>;
> Drew, I agree.&nbsp; I haven't had time to try reproducing this yet, but this
>; feels like a regression in the HAL behaviour.  ;I know that multiple
&gt; libusb / HAL syncing worked just fine for me. &nbsp;Either it is device
>; specific or is a regression outside of gnome-pilot.
>
I agree on this too. In my opinion hal should not keep disconnected
devices, or at least notify again if it's reconnected
>
> Tom, what HAL version do you have installed?  ;It would be great if we
> could narrow this down to a HAL change, but I'll fire off a message to
> the hal list once I know what version this behaviour has been seen in.
>
hal: 0.5.9.1
hal-info: 0.20070831
kernel: 2.6.22-ARCH
udev: 115

I';m using archlinux, which basically means I almost always have the
latest packages.
If you need any more versions of a certain package, you can find it
here: http://archlinux.org/packages/search/?sort=-last_update

Regards,
Tom
_______________________________________________
gnome-pilot-list mailing list
gnome-pilot-listgnome.org">gnome-pilot-listgnome.org
http://mail.gnome.org/mailman/listinfo/gnome-pilot-list

[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )