Skip to content

Conversation

@engigeer
Copy link
Contributor

@engigeer engigeer commented May 4, 2025

Summary of Changes:

  • update flag for no rotary axis to NAN (per request from previous PR)
  • remove conditions for sending status_packet to ensure controller receives response from all keypress events

status_packet.feed_rate = st_get_realtime_rate();

if(msgtype || memcmp(&prev_status, &status_packet, offsetof(machine_status_packet_t, msgtype))) {
if(true) {//msgtype || memcmp(&prev_status, &status_packet, offsetof(machine_status_packet_t, msgtype))) {
Copy link
Contributor Author

@engigeer engigeer May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to get your thoughts on this change to ensure the status message is sent even if the status_packet is unchanged. The rationale is that some commands from the controller do not change the status packet, (e.g., macro keys), but the controller firmware expects a response packet after each keypress.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to force an update on keypresses?

but the controller firmware expects a response packet after each keypress.

For what reason?

Copy link
Contributor Author

@engigeer engigeer Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to force an update on keypresses?

I agree this may be preferable to sending unnecessary redundant messages for every real-time interval. I will update the PR to include a flag when a keypress is received and add a check against this flag to the if statement.

For what reason?

The jog controller has a timeout to notify the user if it has lost communication with the host. The
current implementation could maybe be improved, but involves setting a zero in the first (i.e., address) bit of the memory location used to store the recieved machine_status_packet whenever a command character is sent to the host. The code then checks to ensure that this bit is reset to some non-zero value (i.e., a machine_status_packet update has been received) within the timeout interval, and displays an error message if not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code then checks to ensure that this bit is reset to some non-zero value (i.e., a machine_status_packet update has been received) within the timeout interval, and displays an error message if not.

Why not reset the bit when the command character is read? That should happen fairly quickly if the communication is up.

@terjeio
Copy link
Contributor

terjeio commented Jun 16, 2025

Sorry for the late update - I've been waiting for I2C displays which I received a few days ago. And I have some other pending changes that we discussed earlier. One is changing the address byte to message version, another is ditching the machine_state_t enum that does not match the underlying state bit positions.

Changed code:
i2c_interface.zip

static void send_status_info (void *data)
{
uint_fast8_t idx = min(4, N_AXIS);
uint_fast8_t idx = N_AXIS; //min(4, N_AXIS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will lead to out-of-bounds indexing of the position aray if > 4 axes are defined, is that what you intend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an error on my part. I had experienced an issue previously where the keypad was reporting values for the 4th axis when none was configured, but looking at this line again I don't see how it could be the source of the issue. I will remove from the PR.

status_packet.feed_rate = st_get_realtime_rate();

if(msgtype || memcmp(&prev_status, &status_packet, offsetof(machine_status_packet_t, msgtype))) {
if(true) {//msgtype || memcmp(&prev_status, &status_packet, offsetof(machine_status_packet_t, msgtype))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to force an update on keypresses?

but the controller firmware expects a response packet after each keypress.

For what reason?

@engigeer
Copy link
Contributor Author

Sorry for the late update - I've been waiting for I2C displays which I received a few days ago. And I have some other pending changes that we discussed earlier. One is changing the address byte to message version, another is ditching the machine_state_t enum that does not match the underlying state bit positions.

Changed code: i2c_interface.zip

No apology necessary. I appreciate you've got a lot on your plate, and am continually impressed with all the features you've been working on simultaneously.

Thanks for providing the updated code. I will test this out with my jog pendant to see if I need to make any changes to my controller firmware for compatibility.

@terjeio
Copy link
Contributor

terjeio commented Jun 17, 2025

I am contemplating a more radical change of the message struct to make it more flexible. One would be to move the current position (machine_coords_t) to the msg array to get rid of the 4-axis limit. Another one add a struct (or structs?) for rarely changing data (such coolant, spindle and pin statuses) and move those to the msg array as well - and only send on changes. Support for requesting a complete status report from the pendant should be added so messages containing all the data can be sent.

Is this too complicated? Perhaps not so if you start using the parser I have published?

@engigeer
Copy link
Contributor Author

Sorry for the late update - I've been waiting for I2C displays which I received a few days ago. And I have some other pending changes that we discussed earlier. One is changing the address byte to message version, another is ditching the machine_state_t enum that does not match the underlying state bit positions.

Changed code: i2c_interface.zip

It took longer than I anticipated to get my jog2k controller working with the new i2c_interface code you shared, but I think the issue were more related to my debugging setup more than anything else. There might be a small increase necessary to the SEND_STATUS_NOW_DELAY to work with the rp2040. But for now, it seems to work reasonably well with the jog2k and the stm32f4xx.

I haven't updated the PR branch since any changes would be redundant once you implement the new interface. Please let me know if you would prefer something else. Thanks!

@engigeer
Copy link
Contributor Author

I am contemplating a more radical change of the message struct to make it more flexible. One would be to move the current position (machine_coords_t) to the msg array to get rid of the 4-axis limit. Another one add a struct (or structs?) for rarely changing data (such coolant, spindle and pin statuses) and move those to the msg array as well - and only send on changes. Support for requesting a complete status report from the pendant should be added so messages containing all the data can be sent.

Is this too complicated? Perhaps not so if you start using the parser I have published?

Having worked with the current jog2k controller code a bit more while testing the new interface, I agree implementation of your parser is likely the best long-term path to maintain compatibility while accommodating new functionality. That said, I know the Expatria folks are working on a new variant of the controller, so I'm wondering if it might be better to somehow leave support in the plugin for the jog2k as a legacy device and then focus on the new controller for new features / improvements going forward. Perhaps @andrewmarles might have some thoughts on this?

@engigeer
Copy link
Contributor Author

Perhaps while awaiting a decision on more comprehensive changes to the message structure it would be possible to merge the NAN flag for 3-axis mode? Also fine if you would prefer to wait. I only ask because I’m preparing a PR to Expatria for the Jog2K FW (which is already using NAN as the flag) and would like to keep things in sync if possible.

@terjeio terjeio merged commit a802a03 into grblHAL:master Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants