Skip to content

Commit adba5d0

Browse files
committed
Refactored M70-M73 modal state handling, should now be fully compatible with LinuxCNC behaviour.
Added ADC/DAC resolution to $pinstate command, changed reported values to integer for ADC/DAC devices and float formatted for PWM devices. Numeric settings can now be set via G65P1Q<n>S<value>, <n> is the setting number, <value> is the new value. Changed alarm code for Modbus exceptions (communication errors) from 14 to 19. Refactored MPG stream code to allow plugins to hook into MPG streams (via event handler). Added _free memory system parameter, returns value in KBytes or -1 if not available from driver. Changed basic stream data type from char to uint8_t, added HAL function and core API for releasing/closing UART streams.
1 parent caa1cfc commit adba5d0

33 files changed

+515
-274
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## grblHAL ##
22

3-
Latest build date is 20251018, see the [changelog](changelog.md) for details.
3+
Latest build date is 20251108, see the [changelog](changelog.md) for details.
44

55
> [!NOTE]
66
> A settings reset will be performed on an update of builds prior to 20241208. Backup and restore of settings is recommended.

alarms.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "core_handlers.h"
2828

2929
PROGMEM static const alarm_detail_t alarm_detail[] = {
30-
#ifndef NO_SETTINGS_DESCRIPTIONS
3130
{ Alarm_HardLimit, "Hard limit has been triggered. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." },
3231
{ Alarm_SoftLimit, "Soft limit alarm. G-code motion target exceeds machine travel. Machine position retained. Alarm may be safely unlocked." },
3332
{ Alarm_AbortCycle, "Reset/E-stop while in motion. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." },
@@ -45,8 +44,9 @@ PROGMEM static const alarm_detail_t alarm_detail[] = {
4544
{ Alarm_HomingFailAutoSquaringApproach, "Homing fail. Could not find second limit switch for auto squared axis within search distances. Try increasing max travel, decreasing pull-off distance, or check wiring." },
4645
{ Alarm_SelftestFailed, "Power on selftest (POS) failed." },
4746
{ Alarm_MotorFault, "Motor fault." },
48-
{ Alarm_HomingFail, "Homing fail. Bad configuration." }
49-
#endif // NO_SETTINGS_DESCRIPTIONS
47+
{ Alarm_HomingFail, "Homing fail. Bad configuration." },
48+
{ Alarm_ModbusException, "Modbus exception. Timeout or message error." },
49+
{ Alarm_ExpanderException, "I/O expander communication failed." }
5050
};
5151

5252
static alarm_details_t details = {

alarms.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ typedef enum {
4545
Alarm_SelftestFailed = 16, //!< 16
4646
Alarm_MotorFault = 17, //!< 17
4747
Alarm_HomingFail = 18, //!< 18
48-
Alarm_AlarmMax = Alarm_HomingFail
48+
Alarm_ModbusException = 19, //!< 19
49+
Alarm_ExpanderException = 20, //!< 20
50+
Alarm_AlarmMax = Alarm_ExpanderException
4951
} alarm_code_t;
5052

5153
typedef struct {

changelog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## grblHAL changelog
22

3-
<a name="20251106">Build 20251106
3+
<a name="20251108">Build 20251108
44

55
Core:
66

@@ -16,18 +16,25 @@ Core:
1616

1717
* Added `_free memory` system parameter, returns value in KBytes or -1 if not available from driver.
1818

19+
* Changed basic stream data type from `char` to `uint8_t`, added HAL function and core API for releasing/closing UART streams.
20+
1921
Drivers:
2022

23+
* All: updated for core stream changes.
24+
2125
* iMRX1062: Decorated constant data with `PROGMEM` and some rarely used functions with `FLASHMEM` to reduce RAM footprint. Fixed buggy Laser PPI mode.
2226

2327
Plugins:
2428

2529
* Many: decoracted constant data with `PROGMEM` to reduce RAM footprint for Arduino based drivers \(iMXRT1062 and SAM3X8E\).
30+
Updated for core stream changes.
2631

2732
* Keypad, macros: macros can now be executed via `M81<x>` commands, `<x>` is the macro number matching the `$49<x>` macro setting values.
2833

2934
* Misc, FluidNC I/O Expander: new experimental plugin for the STM32 based I/O expander; adds up to 8 digtal inputs, 10 outputs and a RGB LED.
3035

36+
---
37+
3138
<a name="20251107">20251107
3239

3340
Plugins:

core_handlers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ typedef void (*on_global_settings_restore_ptr)(void);
106106
typedef void (*on_realtime_report_ptr)(stream_write_ptr stream_write, report_tracking_flags_t report);
107107
typedef void (*on_unknown_feedback_message_ptr)(stream_write_ptr stream_write);
108108
typedef void (*on_stream_changed_ptr)(stream_type_t type);
109+
typedef void (*on_mpg_registered_ptr)(io_stream_t *stream, bool tx_capable);
109110
typedef bool (*on_laser_ppi_enable_ptr)(uint_fast16_t ppi, uint_fast16_t pulse_length);
110111
typedef void (*on_homing_rate_set_ptr)(axes_signals_t axes, float rate, homing_mode_t mode);
111112

@@ -251,6 +252,7 @@ typedef struct {
251252
on_get_commands_ptr on_get_commands; //!< Deprecated, use system_register_commands() to register new commands.
252253
on_user_command_ptr on_user_command;
253254
on_stream_changed_ptr on_stream_changed;
255+
on_mpg_registered_ptr on_mpg_registered;
254256
on_homing_rate_set_ptr on_homing_rate_set;
255257
on_homing_completed_ptr on_homing_completed;
256258
on_probe_toolsetter_ptr on_probe_toolsetter;

crossbar.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,8 @@ control_signals_t xbar_fn_to_signals_mask (pin_function_t fn)
184184

185185
return signals;
186186
}
187+
188+
const char *xbar_resolution_to_string (pin_cap_t cap)
189+
{
190+
return !cap.analog || cap.pwm || cap.servo_pwm ? "?" : ((const char * const[]){"4", "8", "10", "12", "14", "16", "18", "20", "24", "32"})[cap.resolution];
191+
}

crossbar.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ PROGMEM static const pin_name_t pin_names[] = {
322322
{ .function = Input_LimitZ_Max, .name = "Z limit max" },
323323
{ .function = Input_HomeZ, .name = "Z home" },
324324
{ .function = Input_HomeZ_2, .name = "Z home 2" },
325-
#ifndef NO_SETTINGS_DESCRIPTIONS
326325
{ .function = Input_SpindleIndex, .name = "Spindle index" },
327326
{ .function = Input_SpindlePulse, .name = "Spindle pulse" },
328327
{ .function = Input_Aux0, .name = "Aux in 0" },
@@ -357,7 +356,6 @@ PROGMEM static const pin_name_t pin_names[] = {
357356
{ .function = Input_Analog_Aux5, .name = "Aux analog in 5" },
358357
{ .function = Input_Analog_Aux6, .name = "Aux analog in 6" },
359358
{ .function = Input_Analog_Aux7, .name = "Aux analog in 7" },
360-
#endif
361359
{ .function = Output_StepX, .name = "X step" },
362360
{ .function = Output_StepX2, .name = "X2 step" },
363361
{ .function = Output_StepY, .name = "Y step" },
@@ -422,7 +420,6 @@ PROGMEM static const pin_name_t pin_names[] = {
422420
{ .function = Input_HomeV, .name = "V home" },
423421
{ .function = Input_MotorFaultV, .name = "V motor fault" },
424422
#endif
425-
#ifndef NO_SETTINGS_DESCRIPTIONS
426423
{ .function = Output_MotorChipSelect, .name = "Motor CS" },
427424
{ .function = Output_MotorChipSelectX, .name = "Motor CSX" },
428425
{ .function = Output_MotorChipSelectY, .name = "Motor CSY" },
@@ -511,7 +508,6 @@ PROGMEM static const pin_name_t pin_names[] = {
511508
{ .function = Bidirectional_MotorUARTM5, .name = "UART M5" },
512509
{ .function = Bidirectional_MotorUARTM6, .name = "UART M6" },
513510
{ .function = Bidirectional_MotorUARTM7, .name = "UART M7" }
514-
#endif
515511
};
516512

517513
typedef enum {
@@ -815,12 +811,18 @@ static inline bool xbar_is_probe_in (pin_function_t fn)
815811
return fn == Input_Probe || fn == Input_Probe2 || fn == Input_Toolsetter;
816812
}
817813

814+
#define N_AUX_AIN_MAX (Input_Analog_AuxMax - Input_Analog_Aux0 + 1)
815+
#define N_AUX_AOUT_MAX (Output_Analog_AuxMax - Output_Analog_Aux0 + 1)
816+
#define N_AUX_DIN_MAX (Input_AuxMax - Input_Aux0 + 1)
817+
#define N_AUX_DOUT_MAX (Output_AuxMax - Output_Aux0 + 1)
818+
818819
void xbar_set_homing_source (void);
819820
limit_signals_t xbar_get_homing_source (void);
820821
limit_signals_t xbar_get_homing_source_from_cycle (axes_signals_t homing_cycle);
821822
axes_signals_t xbar_fn_to_axismask (pin_function_t id);
822823
const char *xbar_fn_to_pinname (pin_function_t id);
823824
const char *xbar_group_to_description ( pin_group_t group);
825+
const char *xbar_resolution_to_string (pin_cap_t cap);
824826
control_signals_t xbar_fn_to_signals_mask (pin_function_t id);
825827

826828
#endif

errors.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "core_handlers.h"
2828

2929
PROGMEM static const status_detail_t status_detail[] = {
30-
#ifndef NO_SETTINGS_DESCRIPTIONS
3130
{ Status_OK, NULL },
3231
{ Status_ExpectedCommandLetter, "G-code words consist of a letter and a value. Letter was not found." },
3332
{ Status_BadNumberFormat, "Missing the expected G-code word value or numeric value format is not valid." },
@@ -109,7 +108,6 @@ PROGMEM static const status_detail_t status_detail[] = {
109108
{ Status_FileOpenFailed, "Could not open file." },
110109
{ Status_UserException, "User defined error occured." },
111110
{ Status_AuxiliaryPortUnusable, "Port is not usable." }
112-
#endif // NO_SETTINGS_DESCRIPTIONS
113111
};
114112

115113
static error_details_t details = {

expanders_init.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ extern void picohal_io_init (void);
9191
extern void thcad2_init (void);
9292
#endif
9393

94+
#if FNC_EXPANDER_ENABLE
95+
void fnc_expander_init (void);
96+
#endif
97+
9498
//
9599

96100
static inline void io_expanders_init (void)
@@ -117,6 +121,10 @@ static inline void io_expanders_init (void)
117121
picohal_io_init();
118122
#endif
119123

124+
#if FNC_EXPANDER_ENABLE
125+
fnc_expander_init();
126+
#endif
127+
120128
#if THCAD2_ENABLE
121129
thcad2_init();
122130
#endif

fs_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ static size_t fs_read (void *buffer, size_t size, size_t count, vfs_file_t *file
149149

150150
if((rcount = min(rcount, size * count))) {
151151
while(rcount--)
152-
*pos++ = iostream((io_stream_t **)&file->handle)->read();
152+
*pos++ = (uint8_t)iostream((io_stream_t **)&file->handle)->read();
153153
}
154154

155155
return rcount;
156156
}
157157

158158
static size_t fs_write (const void *buffer, size_t size, size_t count, vfs_file_t *file)
159159
{
160-
iostream((io_stream_t **)&file->handle)->write_n(buffer, size * count);
160+
iostream((io_stream_t **)&file->handle)->write_n((uint8_t *)buffer, size * count);
161161

162162
return size * count;
163163
}

0 commit comments

Comments
 (0)