Advanced Search

Search Results (Searched for: XHC)

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

XHC WHB04B development?

Category: General LinuxCNC Questions

Okay, so probably not hardware related then, after all. I'll try to adjust my test setup a little bit and see if I can reproduce the issue.
  • Hakan
  • Hakan
03 Mar 2026 10:13 - 03 Mar 2026 10:15
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

With loops 100 I easily got a crash.
Unfortunately it dídn't recover. Same old libusb debug message.
hal   failed to wait for requested mode. waited 500ms
task: main loop took 0.018703 seconds
r = -4 when fail
Failed at 1
transmission failed, try to reconnect ...-4
transmission failed, try to reconnect ...-4
connection lost, cleaning up
libusb_handle_events_timeout_completed done 0
libusb_release_interface done -4
libusb_close done
process done

Done with process()
About to tear down usb
Trying again for 100th time
Started while looooop
After initWhb()
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
Before mUsb.isDeviceOpen()
is Open
libusb: debug [libusb_unref_device] destroy device 3.8
Shutting down and cleaning up LinuxCNC...
Running HAL shutdown script
This is on the "new" N100 mini pc.
  • rodw
  • rodw's Avatar
03 Mar 2026 00:21
Replied by rodw on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

Reading something today. Maybe try using smp affinity to lock the USB interrupt to  Core1 (away from core 0 housekeeping) and assuming > 2 cores. You can find the interrupt by
cat /proc/interrupts | grep -i usb

Then follow one of the many posts about cpu affinity for networking. Just remember you need to reset this on every boot.
  • Finngineering
  • Finngineering
02 Mar 2026 20:00
Replied by Finngineering on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

Okay, so maybe we can conclude that somehow the hardware is not 100% suitable on your "real" setup?

If you still test on the N100, I believe you could force the setupAsyncTransfer error by putting the loops back to original values (or even higher), and jogging while a program is running.
  • Hakan
  • Hakan
02 Mar 2026 19:20
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

Duplicated the setup to a N100 mini-PC.
Couldn't crash the xhc, didn't try for that long though.
So I unplugged the dongle. Put it back.
And it restarted and continued to work. Like magic.

It didn't fail at the usual setupAsyncTransfer, it was somewhere else.
 
  • Q-Man0815
  • Q-Man0815
02 Mar 2026 18:20 - 02 Mar 2026 18:41

Handrad XHC-WHB04b-6 braucht 9b für LEAD Funktion

Category: Deutsch

Signals utilized for operating spindle and feed override. The feed rotary button can serve in
  • Continuous move x% from max velocity
  • Step move x mm
  • MPG override feed/spindle
  • The special position Lead.
    Continuous: In this mode jogging is performed at the selected feed rate. As long the jogwheel turns, the selected axis moves.
    Step: In this mode the machine moves steps  wheel_counts at the currently selected step size and the current set feed rate in machine units. If the commanded position is not reached the machine keeps moving even the jogwheel is not turning.

    Lead: Manipulates the spindle override.

    MPG: Manipulates the feedrate override.

    See here  xhc-whb04b-6  

     
    Signale, die zum Betätigen von Spindel und Vorschubübersteuerung verwendet werden. Der Vorschub-Drehknopf kann dienen als
  • Countinou: Bewegung x% von der maximalen Geschwindigkeit
  • Steps x mm
  • MPG-Vorschubübersteuerung
  • Die Sonderstellung Lead


         Continous: In diesem Modus wird das Joggen mit der gewählten Vorschubgeschwindigkeit durchgeführt. Wenn man                        das Jogwheel dreht, bewegt sich die ausgewählte Achse. 

          Step: In diesem Modus bewegt die Maschine mit den Schritten  wheel_counts bei der aktuell ausgewählten Schrittgröße                  und der aktuellen Soll Vorschubrate in Maschineneinheiten. Die Maschine bewegt sich so lange bis die Anzahl der Schritte                abgearbeitet ist, selbst dann wenn das Handrad nicht gedreht wird.
         Lead: Manipuliert die Spindelübersteuerung
         MPG: Manipuliert die Vorschubübersteuerung



              Siehe auch   xhc-whb04b-6


 
  • Hakan
  • Hakan
02 Mar 2026 14:35
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

Exactly the same log message.
I also tested to unplug + plug back the dongle. Exactly the same log message.
Both ended up in the debug message in libusb.

It can of course be my hardware. It isn't to difficult to test with another test computer I have.
  • Hakan
  • Hakan
02 Mar 2026 13:24
Replied by Hakan on topic XHC WHB04B development?

XHC WHB04B development?

Category: General LinuxCNC Questions

I use the built-in :) libusb-1.0 in debian bookworm (12.13)
It says 
#define LIBUSB_API_VERSION 0x01000109
in the include file.

I was able to install libusb 1.28, compile xhc component with it and at least it starts.
I have a minimal milling job this afternoon. I'll see how it reacts.
Displaying 31 - 45 out of 213 results.
Time to create page: 0.590 seconds
Powered by Kunena Forum