Advanced Search

Search Results (Searched for: XHC)

  • Hannes
  • Hannes
07 Mar 2026 09:54 - 07 Mar 2026 09:55
Replied by Hannes on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

That WHB component is somewhat a rabbit hole... I tried to do proper error handling, can you test it?
github.com/hdiethelm/linuxcnc-fork/tree/...fix-v2-errorhandling
The proper way of testing would be:
1. Get this version to fail reliably: github.com/hdiethelm/linuxcnc-fork/tree/xhc-whb04b-6-fix-v2
2. Now test this version: github.com/hdiethelm/linuxcnc-fork/tree/...fix-v2-errorhandling
Otherwise, you can never be sure the change made any difference. I now that is often not that easy.

Looking at the code, just removing the assert() probably can result in segfaults in libusb as long as the error is not handled properly.

Note that even with my changes, it is not really how you would do it in a nice way but it should work I think. I am not able to reproduce your issue, so I can just guess and try to do better error handling.

@rodw: Jogging in manual mode is fine. My machine can not jog in teleop mode due to I have two Y axis servo motors. The only thing the WHB component does after my PR is:
- Change to teleop mode if not homed (which fails on my machine but on others, it will do that) -> You can jog before homing any special action
- Change to manual mode if homed AND program is idle -> You can jog after homing without any special action
  • Finngineering
  • Finngineering
07 Mar 2026 08:47
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

rodw: I tend to agree that jogging should not be possible by accident. However, I would personally keep that kind of behavior change separate from the bugfixes in the PR. I just fear that changing behavior makes the PR more likely to be not be accepted. But I don't really know, and it's Hannes' PR after all.

Hakan: Great if you got rid of that libusb issue. Then unless somebody else experience the same issue, I think not much need to dig deeper.
  • Hakan
  • Hakan
07 Mar 2026 08:42 - 07 Mar 2026 08:45
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

You are right, rodw, and I don't particularly like it. But that's how it is.
That part can be taken out, for sure.

Some news. I think it is now narrowed down to debian 12 and probably gcc 12.2
Hannes, your question on trixie, I thought I was on trixie on my development pc, no I was on 12.13.
And suspicion about va_args.
So I upgraded to trixie and gcc 14.2.0.
Recompiled, and now it doesn't segv anymore.
It continues after a short break, like it should.
The problem is in libusb1.0 when compiled with gcc 12 (if I understand right).
 
  • rodw
  • rodw's Avatar
07 Mar 2026 08:00
Replied by rodw on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

In my case I had a deadman's switch that had to be held down to enable the jog wheel on the pendant so I set teleop mode when that button was pressed.  I don't think you should allow just jogging the wheel to change modes. There are some safety rules around this stuff. And yes having to switch modes to jog on screen or a pendant is frustrating but probably for safety.
  • Finngineering
  • Finngineering
07 Mar 2026 07:34
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

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.
  • rodw
  • rodw's Avatar
07 Mar 2026 07:22
Replied by rodw on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

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.
  • Finngineering
  • Finngineering
07 Mar 2026 07:08
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

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).
  • Hannes
  • Hannes
06 Mar 2026 22:37
Replied by Hannes on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

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
  • Finngineering
  • Finngineering
06 Mar 2026 15:43
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

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.
  • Hakan
  • Hakan
06 Mar 2026 07:57 - 06 Mar 2026 08:53
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

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 
            *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 
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.
  • Finngineering
  • Finngineering
05 Mar 2026 20:21
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

I just had a quick look, but might go a bit deeper at another time.

The ctx/context appears to be the libusb_context struct. I guess you could just do 
context->log_handler = nullptr;
after libusb_init in usb.cc:
github.com/LinuxCNC/linuxcnc/blob/master...whb04b-6/usb.cc#L629
But this probably isn't the best workaround in general.

I guess most of the problems in the past has been because of the assert statement in setupAsyncTransfer? Or did the pendant never reconnect for you in the past? When I was testing and just unplugged the dongle and plugged it back in, it usually didn't fail in the setupAsyncTransfer function, so the assert statement didn't prevent reconnection.

You might also be interested in testing the changes made by Hannes:
github.com/hdiethelm/linuxcnc-fork/tree/xhc-whb04b-6-fix-v2
I believe you need to do a "git checkout xhc-whb04b-6-fix-v2" after git clone in case you want to test that. With regards to the disconnects, his solution is more elegant than decreasing loops, because it avoids trying to change mode altogether when it's clear it would fail anyway.
 
  • Hakan
  • Hakan
05 Mar 2026 18:36
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

No, I don't know how to change log level even.

Fresh git clone of libusb1.0, configure and make.
Fresh git clone of linuxcnc.
It has been the same behavior/problem with the libusb-1.0 via apt in debian.
This is a problem since a long time, years.
And this N100 PC is relatively new, latest debian and don't have any history.
Except the linuxcnc config, it is the same.
Hard to find something that sticks out.

I provoked the xhc a bit. Easily crashes with wrong loop setting. But it now recovers after three seconds.
This is a situation I can live with. It would have been better with no crash. Until then, this is fine.

The modification I made was in libusb1.0.
What I see is that if one set
context->log_handler = nulltpr;
the problem will not appear, the callback function pointed to by context->log_handler will not be called.
Do you know if this can be done in the xhc component code?
It would be good to use std libusb1.0 libs.
 
  • Finngineering
  • Finngineering
05 Mar 2026 17:19
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

Good job tracking that one down!

Did you previously increase the libusb log level somehow? If so, then maybe that's why it segfaulted for you, but not for me. regardless, looks like a libusb bug to me.
  • Hakan
  • Hakan
05 Mar 2026 14:01
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

I found it.

Ok, I didn't find the reason but I found a way around it.
It always crashed for me with "libusb: debug [libusb_unref_device] destroy device 3.109"
I ran it in the debugger and saw it stopped with a SIGSEGV.
After spending too much time figuring out how to turn on core dumps, I got a core dump.
Here is the stop point.  

 

The one wonders what ctx_log_handler is
(gdb) p ctx->log_handler
$2 = (libusb_log_cb) 0xbb343c565cbddc86

I commented out this line in libusb_unref_device()
 
and then the xhc actually restarted.
Here is the log of that.
hal   failed to wait for requested mode. waited 500ms
pndnt wheel total counts {counts=-353 activeCounter=2 isLeadActive=0}
inTransfer = 0x558412062e00 deviceHandle = 0x558412066360
libusb_fill ..
.. done
Failed in setupAsyncTransfer -4
transmission failed, try to reconnect ...
transmission failed, try to reconnect ...
connection lost, cleaning up
init  pausing 10s, waiting for device to be gone .............. done
init  usb context ... ok
init  not waiting for device XHC-WHB04B-6 vendorId=0x10ce productId=0xeb93, will continue in 0s ...1 ok
init  XHC-WHB04B-6 device found
init  detaching active kernel driver ... ok
init  claiming interface ... ok
init  enabling reception ...In enableReceiveAsyncTransfer
inTransfer = 0x558412062e00 deviceHandle = 0x558412075a50
libusb_fill ..
.. done
 ok
in    0x04 10 00 00 0f 13 00 10 delta 15 => | 04 | 10 |                 |                 |   0.1( 10%) |     Z(    ) |  \
 0 | 10
pndnt wheel  event -353
 
  • Finngineering
  • Finngineering
03 Mar 2026 15:27
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

I flashed back the original firmware to my dongle for testing. When commenting out the assert and adding a debug print there instead if r != 0, I get the following output during jogging in auto:
in    0x04 10 00 00 10 11 00 10 delta 16 => | 04 | 10 |                 |                 |     1( 30%) |     X(    ) |   0 | 10
pndnt wheel  event 604
pndnt wheel total counts {counts=604 activeCounter=0 isLeadActive=0}
in    0x04 10 00 00 10 11 06 10 delta 16 => | 04 | 10 |                 |                 |     1( 30%) |     X(    ) |   6 | 10
pndnt wheel  event 610
Can't switch mode while mode is AUTO and interpreter is not IDLE
hal   failed to wait for requested mode. waited 300ms
pndnt wheel total counts {counts=610 activeCounter=0 isLeadActive=0}
Usb::setupAsyncTransfer() libusb_submit_transfer failed with code -4
transmission failed, try to reconnect ...
transmission failed, try to reconnect ...
connection lost, cleaning up
init  pausing 3s, waiting for device to be gone ....... done
init  usb context ... ok
init  not waiting for device XHC-WHB04B-6 vendorId=0x10ce productId=0xeb93, will continue in 0s .... ok
init  XHC-WHB04B-6 device found
init  detaching active kernel driver ... ok
init  claiming interface ... ok
init  enabling reception ... ok
in    0x04 10 00 00 10 11 00 10 delta 16 => | 04 | 10 |                 |                 |     1( 30%) |     X(    ) |   0 | 10
pndnt wheel  event 610
pndnt wheel total counts {counts=610 activeCounter=0 isLeadActive=0}
task: main loop took 0.036080 seconds
in    0x04 10 00 00 10 11 00 10 delta 16 => | 04 | 10 |                 |                 |     1( 30%) |     X(    ) |   0 | 10
pndnt wheel  event 610
pndnt wheel total counts {counts=610 activeCounter=0 isLeadActive=0}
I tried more than 10 times in a row, and every time the pendant successfully reconnected. In other words, I cannot reproduce your issue. And unfortunately that also means I cannot be of much help to you.

It is a bit surprising that you get the same issue on two different machines, and I don't. Or are the two machines you tested on fairly similar? Could still be e.g. kernel version difference, I suppose. In case they have fixed some usb bugs related to this. It's a bit of a long shot, but I don't have anything better at the moment.
Displaying 16 - 30 out of 213 results.
Time to create page: 0.544 seconds
Powered by Kunena Forum