Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
77da961
Fix missing class initialization in constructors.
BsAtHome Feb 7, 2025
c7f1a56
Method isInitialized() is used in an assert statement and must ensure…
BsAtHome Feb 9, 2025
37ee955
Fix missing initialization.
BsAtHome Feb 27, 2025
5d13265
whb04b: Pass arguments properly
hdiethelm Feb 16, 2026
4c74a2b
whb04b: Fix inversion of -B argument
hdiethelm Feb 16, 2026
8189e15
whb04b: Remove unused code
hdiethelm Feb 16, 2026
90a1970
whb04b: Fix machine moving after change from MPG to STEP or CON
hdiethelm Feb 16, 2026
3e3622b
whb04b: Don't change from auto to manual when jogging
hdiethelm Feb 17, 2026
90e1705
whb04b: Fix example-configuration file ending
hdiethelm Feb 22, 2026
bde0082
whb04b: Use isProgramIdle to check if manual mode can be activated
hdiethelm Mar 3, 2026
f711506
fix for https://github.com/LinuxCNC/linuxcnc/issues/3485 (#3518)
zajc3w Jul 15, 2025
c76c8c0
whb04b: Add missing entry in FeedRotaryButtonCodes::codeMap
hdiethelm Mar 3, 2026
8db0bdc
whb04b: Try to improve error handling
hdiethelm Mar 6, 2026
fed678f
whb04b: Cleanup
hdiethelm Mar 7, 2026
a51d72c
whb04b: Remove unneccesary code
hdiethelm Mar 7, 2026
991ee0e
whb04b: Proper close and reconnect
hdiethelm Mar 7, 2026
ab93e43
whb04b: Cleanup
hdiethelm Mar 7, 2026
3a33f3b
whb04b: Get rid of bad asserts and use static_assert
hdiethelm Mar 7, 2026
baa3af6
whb04b: Error handling
hdiethelm Mar 7, 2026
068ae76
whb04b: Comments / Cleanup
hdiethelm Mar 7, 2026
32b723b
whb04b: Cleanup
hdiethelm Mar 7, 2026
ff69aa4
whb04b: Remove teardown and checks
hdiethelm Mar 7, 2026
2e51200
whb04b: Interrupted is not an error
hdiethelm Mar 7, 2026
683c510
whb04b: Change to interrupt
hdiethelm Mar 7, 2026
d257628
whb04b: Use step size 1mm in 60 and 100% position if -B is not given
hdiethelm Mar 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/hal/user_comps/xhc-whb04b-6/hal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Hal::freeSimulatedPin(void** pin)
if (*pin != nullptr)
{
free(*pin);
pin = nullptr;
*pin = nullptr;
}
}
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -581,11 +581,6 @@ void Hal::init(const MetaButtonCodes* metaButtons, const KeyCodes& keyCodes)
mIsInitialized = true;
}
// ----------------------------------------------------------------------
bool Hal::isInitialized()
{
return mIsInitialized;
}
// ----------------------------------------------------------------------
hal_float_t Hal::getAxisXPosition(bool absolute) const
{
if (absolute)
Expand Down Expand Up @@ -1358,8 +1353,9 @@ void Hal::setJogCounts(const HandWheelCounters& counters)
*memory->out.axisAJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_A);
*memory->out.axisBJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_B);
*memory->out.axisCJogCounts = counters.counts(HandWheelCounters::CounterNameToIndex::AXIS_C);
requestManualMode(false);
requestTeleopMode(false);

requestManualMode(false);
requestTeleopMode(false);
}
// ----------------------------------------------------------------------
void Hal::setFunction(bool enabled)
Expand All @@ -1374,6 +1370,13 @@ bool Hal::requestAutoMode(bool isRisingEdge)
// ----------------------------------------------------------------------
bool Hal::requestManualMode(bool isRisingEdge)
{
if(isRisingEdge && !*memory->in.isProgramIdle)
{
//Don't try to change to manual when not idle
//When a program is running, this will fail
//When an MDI command is active, this would stop it
return false;
}
return requestMode(isRisingEdge, memory->out.doModeManual, memory->in.isModeManual);
}
// ----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/hal/user_comps/xhc-whb04b-6/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class Hal
void init(const MetaButtonCodes* metaButtons, const KeyCodes& codes);
//! \return true if void init(const MetaButtonCodes*, const KeyCodes&) has been called beforehand,
//! false otherwise
bool isInitialized();
bool isInitialized() const { return mIsInitialized; };
//! \return true if simulation mode is enabled, false otherwise
bool isSimulationModeEnabled() const;
//! indicates the program has been invoked in hal mode or normal
Expand Down
51 changes: 32 additions & 19 deletions src/hal/user_comps/xhc-whb04b-6/pendant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ FeedRotaryButtonCodes::FeedRotaryButtonCodes() :
percent_30(0x10, "1", "30%"),
percent_60(0x1a, "5", "60%"),
percent_100(0x1b, "10", "100%"),
lead(0x1c, "Lead", ""), // user jasenk2 seem to need 0x9b for xhc-whb06-4 see : https://github.com/LinuxCNC/linuxcnc/pull/987
// solution added in this file for use both know keycodes (0x1c) + Jasenk (0x9b)
lead(0x1c, "Lead", ""), // user jasenk2 seem to need 0x9b for xhc-whb06-4 see : https://github.com/LinuxCNC/linuxcnc/pull/987, zajc3w needs 0x9B for xhc-whb06-6 see: https://github.com/LinuxCNC/linuxcnc/issues/3485
lead9B(0x9B, "Lead", ""), //previous solution ommited line 607 and key code 0x9b was still not recognised
undefined(0x00, "", ""),
codeMap{
{percent_2.code, &percent_2},
Expand All @@ -343,6 +343,7 @@ FeedRotaryButtonCodes::FeedRotaryButtonCodes() :
{percent_60.code, &percent_60},
{percent_100.code, &percent_100},
{lead.code, &lead},
{lead9B.code, &lead9B},
{undefined.code, &undefined}
}
{
Expand Down Expand Up @@ -541,6 +542,7 @@ FeedRotaryButton::FeedRotaryButton(const KeyCode& keyCode,
mStepMode(stepMode),
mIsPermitted(false),
mStepSize(0),
mIsStepMode_5_10(false),
mEventListener(listener)
{
}
Expand All @@ -566,6 +568,8 @@ FeedRotaryButton& FeedRotaryButton::operator=(const FeedRotaryButton& other)
{
RotaryButton::operator=(other);
mStepMode = other.mStepMode;
mStepSize = other.mStepSize;
mEventListener = other.mEventListener;
return *this;
}
// ----------------------------------------------------------------------
Expand All @@ -582,6 +586,11 @@ void FeedRotaryButton::setStepMode(HandwheelStepmodes::Mode stepMode)
update();
}
// ----------------------------------------------------------------------
void FeedRotaryButton::setStepMode_5_10(bool enable)
{
mIsStepMode_5_10 = enable;
}
// ----------------------------------------------------------------------
HandwheelStepmodes::Mode FeedRotaryButton::stepMode() const
{
return mStepMode;
Expand All @@ -600,7 +609,7 @@ void FeedRotaryButton::update()
return;
}

if (*mKey == KeyCodes::Feed.lead)
if (*mKey == KeyCodes::Feed.lead || *mKey == KeyCodes::Feed.lead9B)
{
mStepSize = mLeadSizeMapper.getStepSize(HandwheelLeadModeStepSize::PositionNameIndex::LEAD);
mIsPermitted = mLeadSizeMapper.isPermitted(HandwheelLeadModeStepSize::PositionNameIndex::LEAD);
Expand All @@ -621,7 +630,7 @@ void FeedRotaryButton::update()
mStepSize = mStepSizeMapper.getStepSize(second);
mIsPermitted = mStepSizeMapper.isPermitted(second);

if (mIsStepMode_5_10 && mStepSize > 2) {mStepSize = 0;} // TODO DOES NOT WORK bool variable seems to be not synched inside pendant.h
if (!mIsStepMode_5_10 && mStepSize > 2) {mStepSize = 1.0;}

}
else if (mStepMode == HandwheelStepmodes::Mode::CON)
Expand Down Expand Up @@ -666,6 +675,7 @@ std::ostream& operator<<(std::ostream& os, const AxisRotaryButton& data)
AxisRotaryButton& AxisRotaryButton::operator=(const AxisRotaryButton& other)
{
RotaryButton::operator=(other);
mEventListener = other.mEventListener;
return *this;
}
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -723,11 +733,6 @@ void Handwheel::enableVerbose(bool enable)
}
}
// ----------------------------------------------------------------------
void Handwheel::setMode(HandWheelCounters::CounterNameToIndex activeCounterMode)
{
mCounters.setActiveCounter(activeCounterMode);
}
// ----------------------------------------------------------------------
void Handwheel::count(int8_t delta)
{
assert(mEventListener != nullptr);
Expand Down Expand Up @@ -827,6 +832,8 @@ ButtonsState& ButtonsState::operator=(const ButtonsState& other)
mCurrentMetaButton = other.mCurrentMetaButton;
mAxisButton = other.mAxisButton;
mFeedButton = other.mFeedButton;
mPreviousState = other.mPreviousState;
mEventListener = other.mEventListener;
return *this;
}
// ----------------------------------------------------------------------
Expand Down Expand Up @@ -1356,7 +1363,7 @@ void Pendant::onFeedActiveEvent(const KeyCode& feed)
// ----------------------------------------------------------------------
void Pendant::dispatchFeedEventToHandwheel(const KeyCode& feed, bool isActive)
{
if (feed.code == KeyCodes::Feed.lead.code || feed.code == 0x9b) // user jasenk2 seem to need 0x9b for xhc-whb06-4 see : https://github.com/LinuxCNC/linuxcnc/pull/987
if (feed.code == KeyCodes::Feed.lead.code || feed.code == KeyCodes::Feed.lead9B.code) // user jasenk2 seem to need 0x9b for xhc-whb06-4 see : https://github.com/LinuxCNC/linuxcnc/pull/987
{
mHandWheel.counters().enableLeadCounter(isActive);
}
Expand Down Expand Up @@ -1388,7 +1395,7 @@ void Pendant::dispatchActiveFeedToHal(const KeyCode& feed, bool isActive)
{
mHal.setFeedValueSelected100(isActive);
}
else if (feed.code == KeyCodes::Feed.lead.code || feed.code == 0x9b) // user jasenk2 seem to need 0x9b for xhc-whb06-4 see : https://github.com/LinuxCNC/linuxcnc/pull/987
else if (feed.code == KeyCodes::Feed.lead.code || feed.code == KeyCodes::Feed.lead9B.code) // user jasenk2 seem to need 0x9b for xhc-whb06-4 see : https://github.com/LinuxCNC/linuxcnc/pull/987
{
mHal.setFeedValueSelectedLead(isActive);
mCurrentButtonsState.feedButton().setStepMode(HandwheelStepmodes::Mode::MPG);
Expand Down Expand Up @@ -1477,11 +1484,17 @@ bool Pendant::onJogDialEvent(const HandWheelCounters& counters, int8_t delta)
{
mHal.toggleFeedrateDecrease();
}
}
else if (!counters.isLeadCounterActive() && (feedButton.stepMode() == HandwheelStepmodes::Mode::CON || feedButton.stepMode() == HandwheelStepmodes::Mode::STEP))
{ // Normal Mode
mHal.setJogCounts(counters);
}
}

if (!counters.isLeadCounterActive())
{
//The counters must be set always if not in lead mode
//Otherwhise, the machine will move, sometimes a long distance in the following case:
//MGP mode -> Wheel turned -> CON or STEP mode -> After first wheel pulse
//due to the counters are increased in MPG mode but not set until the first wheel count event
//Setting them does not create a move in MPG mode due to the scale is zero
mHal.setJogCounts(counters);
}
}
mDisplay.onJogDialEvent(counters, delta);
return true;
Expand Down Expand Up @@ -1567,17 +1580,17 @@ void Pendant::dispatchAxisEventToHal(const KeyCode& axis, bool isActive)
// ----------------------------------------------------------------------
void Pendant::setLeadModeSpindle(bool enable)
{
mIsLeadModeSpindle = true;
mIsLeadModeSpindle = enable;
}
// ----------------------------------------------------------------------
void Pendant::setLeadModeFeed(bool enable)
{
mIsLeadModeFeed = true;
mIsLeadModeFeed = enable;
}
// ----------------------------------------------------------------------
void Pendant::setStepMode_5_10(bool enable)
{
mIsStepMode_5_10 = true;
mCurrentButtonsState.feedButton().setStepMode_5_10(enable);
}
// ----------------------------------------------------------------------
Display::Display(const ButtonsState& currentButtonsState, Hal& hal, UsbOutPackageData& displayData) :
Expand Down
4 changes: 2 additions & 2 deletions src/hal/user_comps/xhc-whb04b-6/pendant.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class FeedRotaryButtonCodes
const KeyCode percent_60;
const KeyCode percent_100;
const KeyCode lead;
const KeyCode lead9B;
const KeyCode undefined;
const std::map<uint8_t, const KeyCode*> codeMap;

Expand Down Expand Up @@ -391,6 +392,7 @@ class FeedRotaryButton : public RotaryButton
~FeedRotaryButton();
virtual bool setKeyCode(const KeyCode& keyCode) override;
void setStepMode(HandwheelStepmodes::Mode stepMode);
void setStepMode_5_10(bool enable);
HandwheelStepmodes::Mode stepMode() const;
float stepSize() const;
bool isPermitted() const override;
Expand Down Expand Up @@ -438,7 +440,6 @@ class Handwheel
Handwheel(const FeedRotaryButton& feedButton, KeyEventListener* listener = nullptr);
~Handwheel();
void enableVerbose(bool enable);
void setMode(HandWheelCounters::CounterNameToIndex mode);
void count(int8_t delta);
const HandWheelCounters& counters() const;
HandWheelCounters& counters();
Expand Down Expand Up @@ -586,7 +587,6 @@ class Pendant : public KeyEventListener
//! if in Lead mode: if true jog wheel changes the spindle speed, changes the feed override otherwise
bool mIsLeadModeSpindle = false;
bool mIsLeadModeFeed = false;
bool mIsStepMode_5_10 = false;

float mScale;
float mMaxVelocity;
Expand Down
Loading