XHC WHB04B development?

More
7 months 3 weeks ago - 7 months 3 weeks ago #343932 by Hakan
Replied by Hakan on topic XHC WHB04B development?
I tried that already, there is no access to log_handler.
struct libusb_context is not defined, only the pointer to it.
I tried with 
Code:
            *mInitCout << "init  enabling reception ...";             libusb_set_log_cb(getUsbContext(), nullptr, LIBUSB_LOG_CB_GLOBAL);             libusb_set_log_cb(getUsbContext(), nullptr, LIBUSB_LOG_CB_CONTEXT);             if (!enableReceiveAsyncTransfer())
in process(), but no change.
There was a new message when restarting the connection from 
Code:
core.c:         usbi_warn(_ctx, "device %d.%d still referenced",
and that didn't crash even if it uses the same underlying log_v function.
I leave it like that.

The problem has been the assert statement. But I tested to remove that some two years ago
(the github issue) and failed in the same way it does now. But in general the assert is what
people experience, I understood.

I'll test Hannes' version next.

Edit: Tested, it avoids the mode switching altogether. I think that is perfectly fine.
I don't expect to switch to Man mode and jog when I'm running a program. Could happen
by mistake even. If I feel a need to switch to Man I'll designate a button for that.
I have a vague memory I did that on the previous generation xhc.

Is it in a shape to go into linuxcnc repo? I think it should end up there.
Last edit: 7 months 3 weeks ago by Hakan.

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #343944 by Finngineering
Yeah, it appears libusb_context is defined in libusbi.h, which is not part of the normal "distribution package". I missed that. There are several compilation defines/options for libusb, which makes a bit more difficult to understand exactly what is happening. But I do think that your libusb_set_log_cb() should have done the trick (unless for some of those compile time options).

It was a little bit strange from the start that it succeeded to print that debug message and only afterwards seemed to hang (which we now know was a segault). I wonder if there could be something wrong with the handling of variadic (=any number of) arguments, which messes up the stack and in the end gives the segfault.

I had a second look at the issue you created a couple of years ago. And yeah, already there you identified libusb as a problem. I don't think really put much thought into that the first time I read it.

Hannes have made a pull request which is waiting to be accepted into LinuxCNC. Andypugh bought a similar pendant and will test the code once he receives the pendant. I guess if he is happy the PR will be accepted. Maybe in 1-2 weeks, is my guess.

I don't think it's possible to switch to manual mode while a program is running or paused. Which is what Hannes version checks for. I presume that if the program is running/paused, it needs to be stopped prior to making the mode change. But I have not verified that. If you are not having a program running/paused, then jogging should change to manual mode.

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #343963 by Hannes
Replied by Hannes on topic XHC WHB04B development?
Normally, you anyway don't want the program or MDI command to stop because you accidentally jog, so I figured this is a good choice, even if it would switch to manual. Which it doesn't do anyway, at least in my case.

I did not read the whole thread in detail. But it seams you have issues with libusb_submit_transfer() and the assert afterwards? According to the manual, this function is allowed to return disconnected: manpages.debian.org/unstable/libusb2-dev/libusb.3.en.html
This should be fine, we should handle the error, cleanup properly and try to reconnect. Worst case, you have to do is disconnect the dongle and reconnect it again. I can look into that.

Meanwhile, do you have a way to reliably get the device to disconnect? Otherwise, it is always hard to see if a fix is really a fix or just the device behaving nicely for a few hours and then failing again.

@Hakan: I see you have Debian 12 (So libusb 2:1.0.26-1 I guess, libusb-1.0 is the package name, not the exact version). Did you try Debian 13?
@Finngineering:
Which Debian version do you have? Kernel version? Libusb version?
I have Debian 13 stock, libusb 2:1.0.28-1

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #343974 by Finngineering
The assert statement is setupAsyncTransfer() is the "big" issue. Simply removing that causes the reconnect to be triggered when trying to send a display update. For me that reconnection works without problems. For Hakan, it gets stuck/segfaults in libusb after reconnect. Somewhere along these lines:
forum.linuxcnc.org/38-general-linuxcnc-q...ment?start=80#343687
It would of course be good to get to the bottom of this. But since I can't reproduce this, it's a bit difficult to debug.

Both myself (with the original firmware) and Hakan can trigger the disconnect reliably by using the original component and jogging while a program is running.

On the development computer, I use the LinuxCNC 2.9.8 iso image / Debian 13. That one has libusb 1.0.28-1. I'm not at that computer right now, so cannot check the kernel version. But it's the stock one from LinuxCNC 2.9.8 iso (unless "apt upgrade" has updated it).

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #343975 by rodw
Replied by rodw on topic XHC WHB04B development?
I have not been following this but if the system fails with a program running, there is a fault with the driver logic. Jogging should not be permitted unless the machine is in teleop mode and programs are not permitted to run in teleop mode.

The driver could request teleop mode with halui.mode.teleop and this will prevent a program from running. I did this with a hard wired pendant. Gmocappy is a good gui to demonstrate this because setting teleop mode makes it display the jog buttons.

Please Log in or Create an account to join the conversation.

More
7 months 3 weeks ago #343976 by Finngineering
The current component tries to change to manual/teleop mode even with a program running/paused. The changes made by Hannes prevents that. However, if a program is not running/paused and you start jogging, it will change to manual/teleop mode automatically. It could of course be discussed if the pendant should be "allowed" to do this just by jogging the wheel. But the PR by Hannes is really mainly bugfixes, so I would presume that it's best not to alter the behavior of the pendant more than necessary.
The following user(s) said Thank You: rodw

Please Log in or Create an account to join the conversation.

Time to create page: 0.072 seconds
Powered by Kunena Forum