diff --git a/docs/po4a.cfg b/docs/po4a.cfg index 5ca4619aa21..fe0852dc513 100644 --- a/docs/po4a.cfg +++ b/docs/po4a.cfg @@ -411,6 +411,7 @@ [type: man_def] build/man/man9/conv_bool_real.9 $lang:build/man/$lang/man9/conv_bool_real.9 [type: man_def] build/man/man9/conv_bool_sint.9 $lang:build/man/$lang/man9/conv_bool_sint.9 [type: man_def] build/man/man9/conv_bool_uint.9 $lang:build/man/$lang/man9/conv_bool_uint.9 +[type: man_def] build/man/man9/conv_real_bool.9 $lang:build/man/$lang/man9/conv_real_bool.9 [type: man_def] build/man/man9/conv_real_sint.9 $lang:build/man/$lang/man9/conv_real_sint.9 [type: man_def] build/man/man9/conv_real_uint.9 $lang:build/man/$lang/man9/conv_real_uint.9 [type: man_def] build/man/man9/conv_sint_bool.9 $lang:build/man/$lang/man9/conv_sint_bool.9 diff --git a/docs/src/getting-started/updating-linuxcnc.adoc b/docs/src/getting-started/updating-linuxcnc.adoc index 63decc6e5e2..52aa5088fa8 100644 --- a/docs/src/getting-started/updating-linuxcnc.adoc +++ b/docs/src/getting-started/updating-linuxcnc.adoc @@ -13,28 +13,32 @@ updates. If you don't have an internet connection to your PC see == Upgrade to the new version -This section describes how to upgrade LinuxCNC from version 2.8.x to a 2.9.y version. -It assumes that you have an existing 2.8 install that you want to update. +This section describes how to upgrade LinuxCNC from version 2.9.x to a 2.10.y version. +It assumes that you have an existing 2.9 install that you want to update. -To upgrade LinuxCNC from a version older than 2.8, you have to first -https://linuxcnc.org/docs/2.8/html/getting-started/updating-linuxcnc.html[upgrade your old install to 2.8], +To upgrade LinuxCNC from a version older than 2.9, you have to first +https://linuxcnc.org/docs/2.9/html/getting-started/updating-linuxcnc.html[upgrade your old install to 2.9], then follow these instructions to upgrade to the new version. If you do not have an old version of LinuxCNC to upgrade, then you're best off making a fresh install of the new version as described in the section <>. -Furthermore, if you are running Ubuntu Precise, Debian Wheezy or Debian Buster it is -well worth considering making a backup of the "linuxcnc" directory on -removable media and performing a +Furthermore, if you are running Ubuntu Precise, Debian Wheezy, Debian Buster or +Debian Bullseye it is well worth considering making a backup of the "linuxcnc" +directory on removable media and performing a <> -as these releases were EOL in 2017, 2018 and 2022 respectively. +as these releases were EOL in 2017, 2018, 2022 and 2026 respectively. If you are running on Ubuntu Lucid then you will have to do this, as Lucid is no longer supported by LinuxCNC (it was EOL in 2013). -To upgrade major versions like 2.8 to 2.9 when you have a network connection at +If you are running Debian Bookworm, then we *strongly* recommend that you upgrade to Debian Trixie. +Moving to the latest Debian version allows for better compatibility and a longer stable path for your installation. +Debian Trixie will have LTS support until June 2030. + +To upgrade major versions like 2.9 to 2.10 when you have a network connection at the machine you need to disable the old linuxcnc.org apt sources in the file /etc/apt/sources.list -and add a new linuxcnc.org apt source for 2.9, then upgrade LinuxCNC. +and add a new linuxcnc.org apt source for 2.10, then upgrade LinuxCNC. The details will depend on which platform you're running on. Open a <> then type `lsb_release -ic` to find this information out: @@ -45,8 +49,8 @@ Distributor ID: Debian Codename: Trixie ---- -You should be running on Debian Bullseye, Bookworm or Trixie or Ubuntu 20.04 "Focal Fossa" or newer. -LinuxCNC 2.9.y will not run on older distributions than these. +You should be running on Debian Bookworm or, recommended, Trixie or Ubuntu 24.04 "Noble Numbat" or newer. +LinuxCNC 2.10.y may not run on older distributions than these and is not supported on anything older. You will also need to check which realtime kernel is being used: @@ -87,11 +91,10 @@ RTAI packages are available for Bookworm and Buster but not currently for Bullse [cols="3,5",options="header"] |=== | OS / Realtime Version | Repository -| Debian Bullseye - preempt m| deb https://linuxcnc.org bullseye base 2.9-uspace -| Debian Bookworm - preempt m| deb https://linuxcnc.org bookworm base 2.9-uspace -| Debian Bookworm - RTAI m| deb https://linuxcnc.org bookworm base 2.9-rt -| Debian Trixie - preempt m| deb https://linuxcnc.org trixie base 2.9-uspace -| Debian Trixie - RTAI m| deb https://linuxcnc.org trixie base 2.9-rt +| Debian Bookworm - preempt m| deb https://linuxcnc.org bookworm base 2.10-uspace +| Debian Bookworm - RTAI m| deb https://linuxcnc.org bookworm base 2.10-rt +| Debian Trixie - preempt m| deb https://linuxcnc.org trixie base 2.10-uspace +| Debian Trixie - RTAI m| deb https://linuxcnc.org trixie base 2.10-rt |=== .Figure with a screenshot of the repository configuration of the synaptic package manager. @@ -145,77 +148,83 @@ Codename: trixie ---- Pick the OS from the list then pick the major version you want like -2.9-rt for RTAI or 2.9-uspace for preempt-rt. +2.10-rt for RTAI or 2.10-uspace for preempt-rt. Next pick the type of computer you have: binary-amd64 for 64-bit PC or binary-arm64 (64bit) for Raspberry Pi. Next pick the version you want from the bottom of the list like -'linuxcnc-uspace_2.9.8_amd64.deb' (choose the latest by date). +'linuxcnc-uspace_2.10.0_amd64.deb' (choose the latest by date). Download the deb and copy it to your home directory. You can rename the file to something a bit shorter with the file manager like -'linuxcnc_2.9.8.deb' then open a terminal and install it with the +'linuxcnc_2.19.0.deb' then open a terminal and install it with the package manager with this command: ---- -sudo dpkg -i linuxcnc_2.9.8.deb +sudo dpkg -i linuxcnc_2.10.0.deb ---- +== Updating to 2.10 -== Updating Configuration Files for 2.9 - -=== Stricter handling of pluggable interpreters - -If you just run regular G-code and you don't know what a pluggable -interpreter is, then this section does not affect you. - -A seldom-used feature of LinuxCNC is support for pluggable interpreters, -controlled by the undocumented `[TASK]INTERPRETER` INI setting. +A large set of changes have been implemented in the new version. +The changes include: -Versions of LinuxCNC before 2.9.0 used to handle an incorrect -`[TASK]INTERPRETER` setting by automatically falling back to using the -default G-code interpreter. +* INI: Reworked INI-file parser with consistent types +* HAL: API breaking change implementing new HAL types +* HAL: Make the underlying HAL memory inaccessible and use a proper API +* TP: New selectable scurve trajectory planner added -Since 2.9.0, an incorrect `[TASK]INTERPRETER` value will cause -LinuxCNC to refuse to start up. Fix this condition by deleting the -`[TASK]INTERPRETER` setting from your INI file, so that LinuxCNC will -use the default G-code interpreter. +=== New HAL types +All integer HAL pins are now 64-bit only and the old HAL type names have changed: -=== Canterp +* `HAL_BOOL` - formerly HAL_BIT +* `HAL_REAL` - formerly HAL_FLOAT +* `HAL_SINT` - formerly HAL_S64 +* `HAL_UINT` - formerly HAL_U64 -If you just run regular G-code and you don't use the `canterp` pluggable -interpreter, then this section does not affect you. +The old 32-bit types have been removed: +* `HAL_S32` - removed +* `HAL_U32` - removed -In the extremely unlikely event that you are using `canterp`, -know that the module has moved from `/usr/lib/libcanterp.so` to -`/usr/lib/linuxcnc/canterp.so`, and the `[TASK]INTERPRETER` setting -correspondingly needs to change from `libcanterp.so` to `canterp.so`. - - -=== Spindle limits in the INI +[IMPORTANT] +==== +Any user components must be updated and recompiled. +The old HAL API is no longer available and access to pins/params is not done by getter/setter. +See ...FIXME... for a more detailed description how to update your components. +==== -It is now possible to add settings to the [SPINDLE] section of the INI file +=== Component changes -MAX_FORWARD_VELOCITY = 20000 The maximum spindle speed (in rpm) +Components were renamed in the HAL type replacement process because they included the old type names: +* conv_XXXX_YYYY - coversion between types now use 'bool', 'real', 'sint' and 'uint' for XXXX and YYYY. +* abs_s32 - replaced by abs_sint. +* abs_s64 - replaced by abs_sint. +* scaled_s32_sums - replaced by scaled_sint_sums. +* mux_generic - renamed pins +* demux_generic - renamed pins +* demux - renamed pin sel-s32 to sel-sint -MIN_FORWARD_VELOCITY = 3000 The minimum spindle speed (in rpm) +=== Updated Python interface -MAX_REVERSE_VELOCITY = 20000 This setting will default to -MAX_FORWARD_VELOCITY if omitted. +The HAL type update is also added to the `hal` module. +Additionally, the type names and direction names have been added as IntEnum types. +All code has been updated to use them and you are encouraged to do the same: -MIN_REVERSE_VELOCITY = 3000` This setting is equivalent to -MIN_FORWARD_VELOCITY but for reverse spindle rotation. It will default -to the MIN_FORWARD_VELOCITY if omitted. +[source,python] +---- +import hal +... -INCREMENT = 200 Sets the step size for spindle speed increment / -decrement commands. This can have a different value for each spindle. -This setting is effective with AXIS and Touchy but note that some -control screens may handle things differently. +# Old: +comp.newpin("pinname", hal.HAL_FLOAT, hal.HAL_IN) -HOME_SEARCH_VELOCITY = 100 - Accepted but currently does nothing +# New: +comp.newpin("pinname", hal.Type.REAL, hal.Dir.IN) +---- -HOME_SEQUENCE = 0 - Accepted but currently does nothing +The old HAL_S32 and HAL_U32 names have been removed and the old HAL type names +HAL_BIT, HAL_FLOAT, HAL_S64 and HAL_U64 will result in a deprecation warning. == Updating Configuration Files for 2.10.y @@ -431,39 +440,16 @@ depth/blend state a part left behind. == New HAL components === Non-Realtime -mdro -mqtt-publisher -pi500_vfd -pmx485-test -qtplasmac-cfg2prefs -qtplasmac-materials -qtplasmac-plasmac2qt -qtplasmac-setup -sim-torch -svd-ps_vfd -=== Realtime -anglejog -div2 -enum -filter_kalman -flipflop -homecomp -limit_axis -mesa_uart -millturn -scaled_s32_sums -tof -ton +...FIXME... -== New Drivers - -A framework for controlling ModBus devices using the serial ports on -many Mesa cards has been introduced. -http://linuxcnc.org/docs/2.9/html/drivers/mesa_modbus.html +=== Realtime -A new GPIO driver for any GPIO which is supported by the gpiod library -is now included: -http://linuxcnc.org/docs/2.9/html/drivers/hal_gpio.html +...FIXME... +== New Drivers +A new ModBus universal driver `hm2_modbus` for Mesa hardware has been created. +It replaces the old mesa_modbus driver and is much more capable. +See hm2_modbus(9) and mesambccc(1). +There are example configurations under `/usr/share/doc/linuxcnc/examples/sample-configs/by_interface/mesa/hm2-modbus`. diff --git a/docs/src/hal/comp.adoc b/docs/src/hal/comp.adoc index 18fca5a909a..db90427cab5 100644 --- a/docs/src/hal/comp.adoc +++ b/docs/src/hal/comp.adoc @@ -180,6 +180,7 @@ Declarations include: * 'component HALNAME (DOC);' * 'pin PINDIRECTION TYPE HALNAME ([SIZE]|[MAXSIZE: CONDSIZE]) (if CONDITION) (= STARTVALUE) (DOC) ;' * 'param PARAMDIRECTION TYPE HALNAME ([SIZE]|[MAXSIZE: CONDSIZE]) (if CONDITION) (= STARTVALUE) (DOC) ;' +* 'alias HALNAME HALNAME ;' * 'function HALNAME (fp | nofp) (DOC);' * 'option OPT (VALUE);' * 'variable CTYPE STARREDNAME ([SIZE]);' diff --git a/docs/src/hal/components.adoc b/docs/src/hal/components.adoc index f70961dab05..06fd5674a31 100644 --- a/docs/src/hal/components.adoc +++ b/docs/src/hal/components.adoc @@ -285,6 +285,7 @@ Limit its slew rate to less than maxv per second. Limit its second derivative to | link:../man/man9/conv_bool_real.9.html[conv_bool_real] |Converts from bool to real || | link:../man/man9/conv_bool_sint.9.html[conv_bool_sint] |Convert a value from bool to sint || | link:../man/man9/conv_bool_uint.9.html[conv_bool_uint] |Convert a value from bool to uint || +| link:../man/man9/conv_real_bool.9.html[conv_real_bool] |Convert a value from real to bool || | link:../man/man9/conv_real_sint.9.html[conv_real_sint] |Convert a value from real to sint || | link:../man/man9/conv_real_uint.9.html[conv_real_uint] |Convert a value from real to uint || | link:../man/man9/conv_sint_bool.9.html[conv_sint_bool] |Convert a value from sint to bool || diff --git a/src/Makefile b/src/Makefile index 927b1227fea..f6e5bee8d2b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -565,7 +565,7 @@ genclean: -rm -f ../lib/*.so.[0-9]* -rm -rf ../docs/build/man -rm -f ../rtlib/*.$(MODULE_EXT) - -rm -f hal/components/conv_*.comp + -rm -f $(patsubst %,hal/components/%,$(notdir $(CONVERTERS))) pycheck-python-files: @echo 'Checking *.py files for python3 compatibility...' diff --git a/src/hal/components/.gitignore b/src/hal/components/.gitignore index 01a447a5a38..c18fb61471b 100644 --- a/src/hal/components/.gitignore +++ b/src/hal/components/.gitignore @@ -1 +1,2 @@ conv_*.comp +!conv_real_bool.comp diff --git a/src/hal/components/boss_plc.c b/src/hal/components/boss_plc.c index 7098b9eb486..a77f4080f2d 100644 --- a/src/hal/components/boss_plc.c +++ b/src/hal/components/boss_plc.c @@ -14,74 +14,74 @@ * the component id number and is formatted as "%d". * * Pins (former parameters): - * u32 boss_plc..amp-ready-delay - * u32 boss_plc..brake-on-delay - * u32 boss_plc..brake-off-delay - * u32 boss_plc..spindle-lo-to-hi - * float boss_plc..jog-scale-0 - * float boss_plc..jog-scale-1 - * float boss_plc..jog-scale-2 + * uint boss_plc..amp-ready-delay + * uint boss_plc..brake-on-delay + * uint boss_plc..brake-off-delay + * uint boss_plc..spindle-lo-to-hi + * real boss_plc..jog-scale-0 + * real boss_plc..jog-scale-1 + * real boss_plc..jog-scale-2 * * Pins: - * bit boss_plc..cycle-start-in - * bit boss_plc..cycle-hold-in - * bit boss_plc..feed-hold-out - * float boss_plc..adaptive-feed-in - * float boss_plc..adaptive-feed-out - * bit boss_plc..tool-change-in - * bit boss_plc..tool-changed-out - * bit boss_plc..wait-user-out - * bit boss_plc..mist-on-in - * bit boss_plc..mist-on-out - * bit boss_plc..flood-on-in - * bit boss_plc..flood-on-out + * bool boss_plc..cycle-start-in + * bool boss_plc..cycle-hold-in + * bool boss_plc..feed-hold-out + * real boss_plc..adaptive-feed-in + * real boss_plc..adaptive-feed-out + * bool boss_plc..tool-change-in + * bool boss_plc..tool-changed-out + * bool boss_plc..wait-user-out + * bool boss_plc..mist-on-in + * bool boss_plc..mist-on-out + * bool boss_plc..flood-on-in + * bool boss_plc..flood-on-out * - * bit boss_plc..limit-override-in - * bit boss_plc..limit-active-out - * float boss_plc..x-position-in - * bit boss_plc..x-jog-en-in - * bit boss_plc..x-limit-in - * bit boss_plc..x-limit-pos-out - * bit boss_plc..x-limit-neg-out - * float boss_plc..y-position-in - * bit boss_plc..y-jog-en-in - * bit boss_plc..y-limit-in - * bit boss_plc..y-limit-pos-out - * bit boss_plc..y-limit-neg-out - * bit boss_plc..z-jog-en-in - * bit boss_plc..z-limit-pos-in - * bit boss_plc..z-limit-neg-in - * bit boss_plc..z-limit-pos-out - * bit boss_plc..z-limit-neg-out + * bool boss_plc..limit-override-in + * bool boss_plc..limit-active-out + * real boss_plc..x-position-in + * bool boss_plc..x-jog-en-in + * bool boss_plc..x-limit-in + * bool boss_plc..x-limit-pos-out + * bool boss_plc..x-limit-neg-out + * real boss_plc..y-position-in + * bool boss_plc..y-jog-en-in + * bool boss_plc..y-limit-in + * bool boss_plc..y-limit-pos-out + * bool boss_plc..y-limit-neg-out + * bool boss_plc..z-jog-en-in + * bool boss_plc..z-limit-pos-in + * bool boss_plc..z-limit-neg-in + * bool boss_plc..z-limit-pos-out + * bool boss_plc..z-limit-neg-out * - * bit boss_plc..x-amp-enable-in - * bit boss_plc..x-amp-ready-in - * bit boss_plc..x-amp-fault-out - * bit boss_plc..y-amp-enable-in - * bit boss_plc..y-amp-ready-in - * bit boss_plc..y-amp-fault-out - * bit boss_plc..z-amp-enable-in - * bit boss_plc..z-amp-ready-in - * bit boss_plc..z-amp-fault-out - * bit boss_plc..a-amp-enable-in - * bit boss_plc..a-amp-ready-in - * bit boss_plc..a-amp-fault-out + * bool boss_plc..x-amp-enable-in + * bool boss_plc..x-amp-ready-in + * bool boss_plc..x-amp-fault-out + * bool boss_plc..y-amp-enable-in + * bool boss_plc..y-amp-ready-in + * bool boss_plc..y-amp-fault-out + * bool boss_plc..z-amp-enable-in + * bool boss_plc..z-amp-ready-in + * bool boss_plc..z-amp-fault-out + * bool boss_plc..a-amp-enable-in + * bool boss_plc..a-amp-ready-in + * bool boss_plc..a-amp-fault-out * - * float boss_plc..spindle-speed-in - * bit boss_plc..spindle-is-on-in - * bit boss_plc..spindle-fwd-out - * bit boss_plc..spindle-rev-out - * bit boss_plc..spindle-inc-in - * bit boss_plc..spindle-dec-in - * bit boss_plc..spindle-inc-out - * bit boss_plc..spindle-dec-out - * bit boss_plc..brake-en-in - * bit boss_plc..brake-en-out + * real boss_plc..spindle-speed-in + * bool boss_plc..spindle-is-on-in + * bool boss_plc..spindle-fwd-out + * bool boss_plc..spindle-rev-out + * bool boss_plc..spindle-inc-in + * bool boss_plc..spindle-dec-in + * bool boss_plc..spindle-inc-out + * bool boss_plc..spindle-dec-out + * bool boss_plc..brake-en-in + * bool boss_plc..brake-en-out * - * bit boss_plc..jog-sel-in-0 - * bit boss_plc..jog-sel-in-1 - * bit boss_plc..jog-sel-in-2 - * bit boss_plc..jog-scale-out + * bool boss_plc..jog-sel-in-0 + * bool boss_plc..jog-sel-in-1 + * bool boss_plc..jog-sel-in-2 + * bool boss_plc..jog-scale-out * * Functions: * void boss_plc..refresh @@ -153,8 +153,8 @@ typedef struct { // Private data. BOOL enabled; rtapi_u32 nSec; - rtapi_u32 count; - rtapi_u32 timeout; + rtapi_uint count; + rtapi_uint timeout; TIMER_ROUTINE pTimeout; void *pArgs; TimerMode mode; @@ -165,7 +165,7 @@ static void Timer_Enable(Timer *this, TimerMode mode); static void Timer_Disable(Timer *this); static BOOL Timer_IsEnabled(Timer *this); static void Timer_Update(Timer *this, long period); -static void Timer_SetTimeout(Timer *this, rtapi_u32 timeout); +static void Timer_SetTimeout(Timer *this, rtapi_uint timeout); #if 0 static void Timer_SetCallback(Timer *this, TIMER_ROUTINE pCallback, void *pArgs); #endif @@ -229,7 +229,7 @@ typedef struct { static int Amp_Export(Amp *this, int compId, int id, char axis); static void Amp_Init(Amp *this); -static void Amp_Refresh(Amp *this, long period, rtapi_u32 readyDelay); +static void Amp_Refresh(Amp *this, long period, rtapi_uint readyDelay); /****************************************************************************** @@ -617,12 +617,12 @@ Plc_ExportLimits(Plc *this, int compId, int id) // Export optional parameters. if(debug > 0){ if(!error){ - error = hal_param_new_ui32(compId, HAL_RO, &this->xLimit.stateDebug, 0, + error = hal_param_new_uint(compId, HAL_RO, &this->xLimit.stateDebug, 0, "boss_plc.%d.%c-limit-state", id, axisNames[0]); } if(!error){ - error = hal_param_new_ui32(compId, HAL_RO, &this->yLimit.stateDebug, 0, + error = hal_param_new_uint(compId, HAL_RO, &this->yLimit.stateDebug, 0, "boss_plc.%d.%c-limit-state", id, axisNames[1]); } } @@ -637,7 +637,7 @@ Plc_ExportAmps(Plc *this, int compId, int id) int error, i; Amp *pAmp; - error = hal_pin_new_ui32(compId, HAL_IO, &this->ampReadyDelay, 50, + error = hal_pin_new_uint(compId, HAL_IO, &this->ampReadyDelay, 50, "boss_plc.%d.amp-ready-delay", id); pAmp = this->amps; @@ -655,11 +655,11 @@ Plc_ExportSpindle(Plc *this, int compId, int id) int error; // Export parameters. - error = hal_pin_new_ui32(compId, HAL_IO, &this->brakeOnDelay, 300, + error = hal_pin_new_uint(compId, HAL_IO, &this->brakeOnDelay, 300, "boss_plc.%d.brake-on-delay", id); if(!error){ - error = hal_pin_new_ui32(compId, HAL_IO, &this->brakeOffDelay, 500, + error = hal_pin_new_uint(compId, HAL_IO, &this->brakeOffDelay, 500, "boss_plc.%d.brake-off-delay", id); } @@ -671,7 +671,7 @@ Plc_ExportSpindle(Plc *this, int compId, int id) // Export optional parameters. if(debug > 0){ if(!error){ - error = hal_param_new_ui32(compId, HAL_RO, &this->spindleStateDebug, 0, + error = hal_param_new_uint(compId, HAL_RO, &this->spindleStateDebug, 0, "boss_plc.%d.spindle-state", id); } } @@ -782,9 +782,9 @@ Plc_Refresh(void *arg, long period) Plc_RefreshJog(this, period); if(debug > 0) { - hal_set_ui32(this->spindleStateDebug, this->spindleState); - hal_set_ui32(this->xLimit.stateDebug, this->xLimit.state); - hal_set_ui32(this->yLimit.stateDebug, this->yLimit.state); + hal_set_uint(this->spindleStateDebug, this->spindleState); + hal_set_uint(this->xLimit.stateDebug, this->xLimit.state); + hal_set_uint(this->yLimit.stateDebug, this->yLimit.state); } } @@ -855,7 +855,7 @@ Plc_RefreshAmps(Plc *this, long period) pAmp = this->amps; for(i = 0; i < NUM_AXIS; i++, pAmp++){ - Amp_Refresh(pAmp, period, hal_get_ui32(this->ampReadyDelay)); + Amp_Refresh(pAmp, period, hal_get_uint(this->ampReadyDelay)); } } @@ -870,7 +870,7 @@ Plc_RefreshSpindle(Plc *this, long period) if(!hal_get_bool(this->pBrakeEnIn)){ this->spindleState = SS_WAIT_BRAKE_OFF; hal_set_bool(this->pBrakeEnOut, 0); - Timer_SetTimeout(&this->spindleTimer, hal_get_ui32(this->brakeOffDelay)); + Timer_SetTimeout(&this->spindleTimer, hal_get_uint(this->brakeOffDelay)); Timer_Enable(&this->spindleTimer, TM_ONE_SHOT); } break; @@ -927,7 +927,7 @@ Plc_RefreshSpindle(Plc *this, long period) if(!hal_get_bool(this->pSpindleIsOnIn)){ this->spindleState = SS_WAIT_BRAKE_ON; - Timer_SetTimeout(&this->spindleTimer, hal_get_ui32(this->brakeOnDelay)); + Timer_SetTimeout(&this->spindleTimer, hal_get_uint(this->brakeOnDelay)); Timer_Enable(&this->spindleTimer, TM_ONE_SHOT); } break; @@ -1123,7 +1123,7 @@ Amp_Init(Amp *this) static void -Amp_Refresh(Amp *this, long period, rtapi_u32 readyDelay) +Amp_Refresh(Amp *this, long period, rtapi_uint readyDelay) { Timer_Update(&this->timer, period); @@ -1204,7 +1204,7 @@ Timer_Update(Timer *this, long period) static void -Timer_SetTimeout(Timer *this, rtapi_u32 timeout) +Timer_SetTimeout(Timer *this, rtapi_uint timeout) { this->count = 0; this->timeout = timeout; diff --git a/src/hal/components/comp.comp b/src/hal/components/comp.comp index cf27ca469e0..8365df255fb 100644 --- a/src/hal/components/comp.comp +++ b/src/hal/components/comp.comp @@ -16,6 +16,7 @@ option period no; function _ "Update the comparator"; license "GPL"; author "Jeff Epler"; +see_also "conv_real_bool(9)."; ;; FUNCTION(_) { rtapi_real tmp = in1 - in0; diff --git a/src/hal/components/conv_real_bool.comp b/src/hal/components/conv_real_bool.comp new file mode 100644 index 00000000000..a00ee0d2dd7 --- /dev/null +++ b/src/hal/components/conv_real_bool.comp @@ -0,0 +1,23 @@ +component conv_real_bool """Convert a value from real to bool + +The output value `out` is False when `in` is within `±eps` of zero. +The `out` pin is set to True once the `in` value reaches beyond. + +* `in` < `-eps` -> `out` = True +* `in` > `+eps` -> `out` = True +* `-eps` ≤ `in` ≤ `+eps` -> `out` = False + +In effect: `out = |in| > |eps|` + +"""; +pin in real in "Input value to convert."; +pin out bool out "Output value is False when input is within ±eps."; +param rw real eps = 1e-8 "Epsilon value to determine the input to be zero."; +option period no; +function _ "Update 'out' based on 'in' to be within 'eps' or not."; +license "GPL"; +author "LinuxCNC authors"; +see_also "comp(9)."; +include ; +;; +out_set(fabs(in) > fabs(eps)); diff --git a/src/hal/components/counter.c b/src/hal/components/counter.c index 829d1412b89..574c859b1a0 100644 --- a/src/hal/components/counter.c +++ b/src/hal/components/counter.c @@ -76,8 +76,8 @@ typedef struct { hal_real_t pos_scale; /* pin: scaling factor for pos */ double old_scale; /* stored scale value */ double scale; /* reciprocal value used for scaling */ - rtapi_s32 last_count; - rtapi_s32 last_index_count; + rtapi_sint last_count; + rtapi_sint last_index_count; } counter_t; /* pointer to array of counter_t structs in shmem, 1 per counter */ @@ -138,8 +138,8 @@ int rtapi_app_main(void) counter_array[n].oldZ = 0; counter_array[n].oldA = 0; counter_array[n].reset_on_index = 0; - hal_set_si32(counter_array[n].raw_count, 0); - hal_set_si32(counter_array[n].count, 0); + hal_set_sint(counter_array[n].raw_count, 0); + hal_set_sint(counter_array[n].count, 0); hal_set_real(counter_array[n].pos, 0.0); hal_set_real(counter_array[n].pos_scale, 1.0); counter_array[n].old_scale = 1.0; @@ -186,12 +186,12 @@ static void update(void *arg, long period) for (cntr = arg, n = 0; n < num_chan; cntr++, n++) { // count on rising edge if(!cntr->oldA && hal_get_bool(cntr->phaseA)) - hal_set_si32(cntr->raw_count, hal_get_si32(cntr->raw_count) + 1); + hal_set_sint(cntr->raw_count, hal_get_sint(cntr->raw_count) + 1); cntr->oldA = hal_get_bool(cntr->phaseA); // reset on rising edge if(cntr->reset_on_index && !cntr->oldZ && hal_get_bool(cntr->phaseZ)) { - cntr->last_index_count = hal_get_si32(cntr->raw_count); + cntr->last_index_count = hal_get_sint(cntr->raw_count); hal_set_bool(cntr->index_ena, 0); } cntr->oldZ = hal_get_bool(cntr->phaseZ); @@ -205,17 +205,17 @@ static void capture(void *arg, long period) for (cntr = arg, n = 0; n < num_chan; cntr++, n++) { /* check reset input */ - int raw_count; - int counts; + rtapi_sint raw_count; + rtapi_sint counts; if (hal_get_bool(cntr->reset)) { /* reset is active, reset the counter */ - hal_set_si32(cntr->raw_count, 0); + hal_set_sint(cntr->raw_count, 0); cntr->last_index_count = 0; cntr->last_count = 0; } /* capture raw counts to latches */ - raw_count = hal_get_si32(cntr->raw_count); - hal_set_si32(cntr->count, raw_count - cntr->last_index_count); + raw_count = hal_get_sint(cntr->raw_count); + hal_set_sint(cntr->count, raw_count - cntr->last_index_count); counts = (raw_count - cntr->last_count); cntr->last_count = raw_count; @@ -232,7 +232,7 @@ static void capture(void *arg, long period) cntr->scale = 1.0 / hal_get_real(cntr->pos_scale); } /* scale count to make floating point position */ - hal_set_real(cntr->pos, hal_get_si32(cntr->count) * cntr->scale); + hal_set_real(cntr->pos, hal_get_sint(cntr->count) * cntr->scale); /* scale counts to make floating point velocity */ hal_set_real(cntr->vel, counts * cntr->scale * 1e9 / period); @@ -273,9 +273,9 @@ static int export_counter(int num, counter_t * addr) /* export pin for the reset input */ CHK(hal_pin_new_bool(comp_id, HAL_IN, &addr->reset, 0, "counter.%d.reset", num)); /* export parameter for raw counts */ - CHK(hal_pin_new_si32(comp_id, HAL_OUT, &addr->raw_count, 0, "counter.%d.rawcounts", num)); + CHK(hal_pin_new_sint(comp_id, HAL_OUT, &addr->raw_count, 0, "counter.%d.rawcounts", num)); /* export pin for counts captured by capture() */ - CHK(hal_pin_new_si32(comp_id, HAL_OUT, &addr->count, 0, "counter.%d.counts", num)); + CHK(hal_pin_new_sint(comp_id, HAL_OUT, &addr->count, 0, "counter.%d.counts", num)); /* export pin for scaled position captured by capture() */ CHK(hal_pin_new_real(comp_id, HAL_OUT, &addr->pos, 0.0, "counter.%d.position", num)); /* export pin for scaled velocity captured by capture() */ diff --git a/src/hal/components/debounce.c b/src/hal/components/debounce.c index b8fe3d0ca4f..582becbabe9 100644 --- a/src/hal/components/debounce.c +++ b/src/hal/components/debounce.c @@ -70,7 +70,7 @@ typedef struct { #ifdef EXPORT_STATE hal_sint_t state; /* parameter*: internal state */ #else - rtapi_s32 state; /* parameter*: internal state */ + rtapi_sint state; /* parameter*: internal state */ #endif } debounce_t; @@ -173,11 +173,11 @@ void rtapi_app_exit(void) ************************************************************************/ #ifdef EXPORT_STATE -static inline rtapi_s32 get_state(hal_sint_t *s) { return hal_get_si32(*s); } -static inline rtapi_s32 set_state(hal_sint_t *s, rtapi_s32 v) { return hal_set_si32(*s, v); } +static inline rtapi_sint get_state(hal_sint_t *s) { return hal_get_sint(*s); } +static inline rtapi_sint set_state(hal_sint_t *s, rtapi_sint v) { return hal_set_sint(*s, v); } #else -static inline rtapi_s32 get_state(rtapi_s32 *s) { return *s; } -static inline rtapi_s32 set_state(rtapi_s32 *s, rtapi_s32 v) { return (*s = v); } +static inline rtapi_sint get_state(rtapi_sint *s) { return *s; } +static inline rtapi_sint set_state(rtapi_sint *s, rtapi_sint v) { return (*s = v); } #endif /** The debounce filter works by incrementing a counter whenever the @@ -205,8 +205,8 @@ static void debounce(void *arg, long period) /* point to filter group */ group = (debounce_group_t *) arg; /* first make sure delay is sane */ - if (hal_get_si32(group->delay) < 0) { - hal_set_si32(group->delay, 1); + if (hal_get_sint(group->delay) < 0) { + hal_set_sint(group->delay, 1); } /* loop thru filters */ for (n = 0; n < group->channels; n++) { @@ -215,7 +215,7 @@ static void debounce(void *arg, long period) /* update this filter */ if (hal_get_bool(filter->in)) { /* input true, is state at threshold? */ - if (get_state(&filter->state) < hal_get_si32(group->delay)) { + if (get_state(&filter->state) < hal_get_sint(group->delay)) { /* no, increment */ set_state(&filter->state, get_state(&filter->state) + 1); } else { @@ -257,7 +257,7 @@ static int export_group(int num, debounce_group_t * addr, int group_size) return -1; } /* export param variable for delay */ - retval = hal_param_new_si32(comp_id, HAL_RW, &addr->delay, 5, "debounce.%d.delay", num); + retval = hal_param_new_sint(comp_id, HAL_RW, &addr->delay, 5, "debounce.%d.delay", num); if (retval != 0) { rtapi_print_msg(RTAPI_MSG_ERR, "DEBOUNCE: ERROR: 'debounce.%d.delay' param export failed\n", num); return retval; @@ -304,7 +304,7 @@ static int export_filter(int num, debounce_t * addr, int group_num) } #ifdef EXPORT_STATE /* export parameter containing internal state */ - retval = hal_param_new_si32(comp_id, HAL_RO, &addr->state, 0, "%s.state", buf); + retval = hal_param_new_sint(comp_id, HAL_RO, &addr->state, 0, "%s.state", buf); if (retval != 0) { rtapi_print_msg(RTAPI_MSG_ERR, "DEBOUNCE: ERROR: '%s.state' param export failed\n", buf); return retval; diff --git a/src/hal/components/encoder.c b/src/hal/components/encoder.c index 6cb08cf12c5..76166a7f057 100644 --- a/src/hal/components/encoder.c +++ b/src/hal/components/encoder.c @@ -88,10 +88,10 @@ typedef struct { char count_detected; char index_detected; char latch_detected; - rtapi_s32 raw_count; + rtapi_sint raw_count; rtapi_u32 timestamp; - rtapi_s32 index_count; - rtapi_s32 latch_count; + rtapi_sint index_count; + rtapi_sint latch_count; } atomic; /* this structure contains the runtime data for a single counter @@ -120,10 +120,10 @@ typedef struct { hal_bool_t latch_in; /* c:r counter latch input */ hal_bool_t latch_rising; /* u:r latch on rising edge? */ hal_bool_t latch_falling; /* u:r latch on falling edge? */ - rtapi_s32 raw_count; /* c:rw captured raw_count */ + rtapi_sint raw_count; /* c:rw captured raw_count */ rtapi_u32 timestamp; /* c:rw captured timestamp */ - rtapi_s32 index_count; /* c:rw captured index count */ - rtapi_s32 latch_count; /* c:rw captured index count */ + rtapi_sint index_count; /* c:rw captured index count */ + rtapi_sint latch_count; /* c:rw captured index count */ hal_sint_t count; /* c:w captured binary count value */ hal_sint_t count_latch; /* c:w captured binary count value */ hal_real_t min_speed; /* c:r minimum velocity to estimate nonzero */ @@ -273,12 +273,12 @@ int rtapi_app_main(void) cntr->buf[0].index_detected = 0; cntr->buf[1].index_detected = 0; cntr->bp = &(cntr->buf[0]); - hal_set_si32(cntr->raw_counts, 0); + hal_set_sint(cntr->raw_counts, 0); cntr->raw_count = 0; cntr->timestamp = 0; cntr->index_count = 0; cntr->latch_count = 0; - hal_set_si32(cntr->count, 0); + hal_set_sint(cntr->count, 0); hal_set_real(cntr->min_speed, 1.0); hal_set_real(cntr->pos, 0.0); hal_set_real(cntr->pos_latch, 0.0); @@ -332,7 +332,7 @@ static void update(void *arg, long period) cntr = arg; for (n = 0; n < howmany; n++) { buf = (atomic *) cntr->bp; - hal_set_si32(cntr->dt, hal_get_si32(cntr->dt) + period); + hal_set_sint(cntr->dt, hal_get_sint(cntr->dt) + period); /* get state machine current state */ state = cntr->state; /* add input bits to state code */ @@ -352,15 +352,15 @@ static void update(void *arg, long period) } /* should we count? */ if (state & SM_CNT_UP_MASK) { - if (hal_get_si32(cntr->missing_teeth) && hal_get_si32(cntr->dt) > hal_get_si32(cntr->limit_dt)){ + if (hal_get_sint(cntr->missing_teeth) && hal_get_sint(cntr->dt) > hal_get_sint(cntr->limit_dt)){ cntr->gaps++; } - buf->raw_count = hal_set_si32(cntr->raw_counts, hal_get_si32(cntr->raw_counts) + 1); + buf->raw_count = hal_set_sint(cntr->raw_counts, hal_get_sint(cntr->raw_counts) + 1); buf->timestamp = timebase; buf->count_detected = 1; - hal_set_si32(cntr->dt, 0); + hal_set_sint(cntr->dt, 0); } else if (state & SM_CNT_DN_MASK) { - buf->raw_count = hal_set_si32(cntr->raw_counts, hal_get_si32(cntr->raw_counts) - 1); + buf->raw_count = hal_set_sint(cntr->raw_counts, hal_get_sint(cntr->raw_counts) - 1); buf->timestamp = timebase; buf->count_detected = 1; } @@ -376,7 +376,7 @@ static void update(void *arg, long period) /* test for index enabled and rising edge on phase Z */ if ((state & cntr->Zmask) == 1) { /* capture counts, reset Zmask */ - buf->index_count = hal_get_si32(cntr->raw_counts); + buf->index_count = hal_get_sint(cntr->raw_counts); buf->index_detected = 1; cntr->Zmask = 0; } @@ -388,7 +388,7 @@ static void update(void *arg, long period) if((rising && hal_get_bool(cntr->latch_rising)) || (falling && hal_get_bool(cntr->latch_falling))) { buf->latch_detected = 1; - buf->latch_count = hal_get_si32(cntr->raw_counts); + buf->latch_count = hal_get_sint(cntr->raw_counts); } cntr->old_latch = latch; @@ -465,12 +465,12 @@ static void capture(void *arg, long period) running count of edges seen since startup. The public "count" is the difference between raw_count and index_count, so it will become zero. */ - cntr->raw_count = hal_get_si32(cntr->raw_counts); + cntr->raw_count = hal_get_sint(cntr->raw_counts); cntr->index_count = cntr->raw_count; } /* process data from update() */ if ( buf->count_detected ) { - rtapi_s32 missing_teeth = hal_get_si32(cntr->missing_teeth); + rtapi_sint missing_teeth = hal_get_sint(cntr->missing_teeth); /* one or more counts in the last period */ buf->count_detected = 0; delta_time = buf->timestamp - cntr->timestamp; @@ -478,13 +478,13 @@ static void capture(void *arg, long period) // lowpass the gap detector deliberately ignoring missing teeth // see https://github.com/LinuxCNC/linuxcnc/issues/2635 if (delta_counts != 0){ - rtapi_s32 limit_dt = hal_get_si32(cntr->limit_dt); + rtapi_sint limit_dt = hal_get_sint(cntr->limit_dt); limit_dt *= 0.9; limit_dt += 0.1 * ((missing_teeth + 0.5) * (delta_time / delta_counts)); - hal_set_si32(cntr->limit_dt, limit_dt); + hal_set_sint(cntr->limit_dt, limit_dt); } // correct counts for tooth gap - hal_set_si32(cntr->raw_counts, hal_get_si32(cntr->raw_counts) + missing_teeth * cntr->gaps); + hal_set_sint(cntr->raw_counts, hal_get_sint(cntr->raw_counts) + missing_teeth * cntr->gaps); cntr->raw_count = buf->raw_count + missing_teeth * cntr->gaps; delta_counts += missing_teeth * cntr->gaps; cntr->gaps = 0; @@ -500,7 +500,7 @@ static void capture(void *arg, long period) if ( cntr->counts_since_timeout ) { /* calc time since last count */ delta_time = timebase - cntr->timestamp; - if (hal_get_si32(cntr->missing_teeth) && delta_time > 1.5 * hal_get_si32(cntr->limit_dt)){ + if (hal_get_sint(cntr->missing_teeth) && delta_time > 1.5 * hal_get_sint(cntr->limit_dt)){ // dont update the velocity in the tooth gap } else if ( delta_time < 1e9 / ( hal_get_real(cntr->min_speed) * cntr->scale )) { /* not to long, estimate vel if a count arrived now */ @@ -527,11 +527,11 @@ static void capture(void *arg, long period) } hal_set_real(cntr->vel_rpm, hal_get_real(cntr->vel) * 60.0); /* compute net counts */ - hal_set_si32(cntr->count, cntr->raw_count - cntr->index_count); - hal_set_si32(cntr->count_latch, cntr->latch_count - cntr->index_count); + hal_set_sint(cntr->count, cntr->raw_count - cntr->index_count); + hal_set_sint(cntr->count_latch, cntr->latch_count - cntr->index_count); /* scale count to make floating point position */ - hal_set_real(cntr->pos, hal_get_si32(cntr->count) * cntr->scale); - hal_set_real(cntr->pos_latch, hal_get_si32(cntr->count_latch) * cntr->scale); + hal_set_real(cntr->pos, hal_get_sint(cntr->count) * cntr->scale); + hal_set_real(cntr->pos_latch, hal_get_sint(cntr->count_latch) * cntr->scale); /* add interpolation value */ delta_time = timebase - cntr->timestamp; interp = hal_get_real(cntr->vel) * (delta_time * 1e-9); @@ -604,19 +604,19 @@ static int export_encoder(counter_t * addr,char * prefix) } /* export parameter for raw counts */ - retval = hal_pin_new_si32(comp_id, HAL_OUT, &(addr->raw_counts), 0, + retval = hal_pin_new_sint(comp_id, HAL_OUT, &(addr->raw_counts), 0, "%s.rawcounts", prefix); if (retval != 0) { return retval; } /* export pin for counts captured by capture() */ - retval = hal_pin_new_si32(comp_id, HAL_OUT, &(addr->count), 0, + retval = hal_pin_new_sint(comp_id, HAL_OUT, &(addr->count), 0, "%s.counts", prefix); if (retval != 0) { return retval; } /* export pin for counts latched by capture() */ - retval = hal_pin_new_si32(comp_id, HAL_OUT, &(addr->count_latch), 0, + retval = hal_pin_new_sint(comp_id, HAL_OUT, &(addr->count_latch), 0, "%s.counts-latched", prefix); if (retval != 0) { return retval; @@ -676,7 +676,7 @@ static int export_encoder(counter_t * addr,char * prefix) return retval; } /* export pin for missing-tooth index */ - retval = hal_pin_new_si32(comp_id, HAL_IN, &(addr->missing_teeth), 0, + retval = hal_pin_new_sint(comp_id, HAL_IN, &(addr->missing_teeth), 0, "%s.missing-teeth", prefix); if (retval != 0) { return retval; @@ -686,13 +686,13 @@ static int export_encoder(counter_t * addr,char * prefix) #if 0 // These two, 'dt' and 'limit_dt' are used in the code and if they are // used, then they must be created to allocate storage. - retval = hal_param_new_si32(comp_id, HAL_RO, &(addr->dt), 0, + retval = hal_param_new_sint(comp_id, HAL_RO, &(addr->dt), 0, "%s.dt", prefix); if (retval != 0) { return retval; } - retval = hal_param_new_si32(comp_id, HAL_RO, &(addr->limit_dt), 0, + retval = hal_param_new_sint(comp_id, HAL_RO, &(addr->limit_dt), 0, "%s.limit_dt", prefix); if (retval != 0) { return retval; diff --git a/src/hal/components/encoder_ratio.c b/src/hal/components/encoder_ratio.c index 6e2b65b7bca..1dfbe3f3355 100644 --- a/src/hal/components/encoder_ratio.c +++ b/src/hal/components/encoder_ratio.c @@ -121,11 +121,11 @@ typedef struct { hal_bool_t slave_A; /* quadrature input */ hal_bool_t slave_B; /* quadrature input */ hal_bool_t enable; /* enable input */ - unsigned master_state; /* quad decode state machine state */ - unsigned slave_state; /* quad decode state machine state */ - int raw_error; /* internal data */ - int master_increment; /* internal data */ - int slave_increment; /* internal data */ + rtapi_uint master_state; /* quad decode state machine state */ + rtapi_uint slave_state; /* quad decode state machine state */ + rtapi_sint raw_error; /* internal data */ + rtapi_sint master_increment; /* internal data */ + rtapi_sint slave_increment; /* internal data */ double output_scale; /* internal data */ hal_real_t error; /* error output */ hal_uint_t master_ppr; /* parameter: master encoder PPR */ @@ -279,7 +279,7 @@ static void sample(void *arg, long period) (void)period; encoder_pair_t *pair; int n; - unsigned state; + rtapi_uint state; pair = arg; for (n = 0; n < howmany; n++) { @@ -346,9 +346,9 @@ static void update(void *arg, long period) } /* update scale factors (only needed if params change, but it's faster to do it every time than to detect changes.) */ - pair->master_increment = hal_get_ui32(pair->master_teeth) * hal_get_ui32(pair->slave_ppr); - pair->slave_increment = hal_get_ui32(pair->slave_teeth) * hal_get_ui32(pair->master_ppr); - pair->output_scale = hal_get_ui32(pair->master_ppr) * hal_get_ui32(pair->slave_ppr) * hal_get_ui32(pair->slave_teeth); + pair->master_increment = hal_get_uint(pair->master_teeth) * hal_get_uint(pair->slave_ppr); + pair->slave_increment = hal_get_uint(pair->slave_teeth) * hal_get_uint(pair->master_ppr); + pair->output_scale = hal_get_uint(pair->master_ppr) * hal_get_uint(pair->slave_ppr) * hal_get_uint(pair->slave_teeth); /* move on to next pair */ pair++; } @@ -405,22 +405,22 @@ static int export_encoder_pair(int num, encoder_pair_t * addr, char* prefix) return retval; } /* export pins for config info() */ - retval = hal_pin_new_ui32(comp_id, HAL_IO, &(addr->master_ppr), 0, + retval = hal_pin_new_uint(comp_id, HAL_IO, &(addr->master_ppr), 0, "%s.master-ppr", prefix); if (retval != 0) { return retval; } - retval = hal_pin_new_ui32(comp_id, HAL_IO, &(addr->slave_ppr), 0, + retval = hal_pin_new_uint(comp_id, HAL_IO, &(addr->slave_ppr), 0, "%s.slave-ppr", prefix); if (retval != 0) { return retval; } - retval = hal_pin_new_ui32(comp_id, HAL_IO, &(addr->master_teeth), 0, + retval = hal_pin_new_uint(comp_id, HAL_IO, &(addr->master_teeth), 0, "%s.master-teeth", prefix); if (retval != 0) { return retval; } - retval = hal_pin_new_ui32(comp_id, HAL_IO, &(addr->slave_teeth), 0, + retval = hal_pin_new_uint(comp_id, HAL_IO, &(addr->slave_teeth), 0, "%s.slave-teeth", prefix); if (retval != 0) { return retval; diff --git a/src/hal/components/homecomp.comp b/src/hal/components/homecomp.comp index 909646954cc..aca3f4125d5 100644 --- a/src/hal/components/homecomp.comp +++ b/src/hal/components/homecomp.comp @@ -164,7 +164,7 @@ static int mkp(int id, int njoints) "joint.%d.homing", jno)); CHK(hal_pin_new_bool(id, HAL_OUT, &p->homed, 0, "joint.%d.homed", jno)); - CHK(hal_pin_new_si32(id, HAL_OUT, &p->home_state, 0, + CHK(hal_pin_new_sint(id, HAL_OUT, &p->home_state, 0, "joint.%d.home-state", jno)); CHK(hal_pin_new_bool(id, HAL_IO, &p->index_enable, 0, "joint.%d.index-enable", jno)); @@ -196,7 +196,7 @@ static void wr(int njoints) one_joint_home_data_t *p = &joint_home_data[jno]; hal_set_bool(p->homing, 0); hal_set_bool(p->homed, get_homed(jno)); - hal_set_si32(p->home_state, 0); // HOME_IDLE + hal_set_sint(p->home_state, 0); // HOME_IDLE } } diff --git a/src/hal/components/lcd.c b/src/hal/components/lcd.c index 6c07c263a01..6dfb059bd51 100644 --- a/src/hal/components/lcd.c +++ b/src/hal/components/lcd.c @@ -47,7 +47,7 @@ typedef struct { typedef struct { lcd_page_t *pages; - unsigned num_pages; + rtapi_uint num_pages; hal_uint_t page_num; hal_uint_t out; hal_real_t contrast; @@ -165,7 +165,7 @@ int rtapi_app_main(void){ break; case 'u': case 'c': - retval = hal_pin_new_ui32(comp_id, HAL_IN, + retval = hal_pin_new_uint(comp_id, HAL_IN, &(inst->pages[p].args[a].u), 0, "lcd.%02i.page.%02i.arg.%02i", i, p, a); @@ -175,7 +175,7 @@ int rtapi_app_main(void){ break; case 's': - retval = hal_pin_new_si32(comp_id, HAL_IN, + retval = hal_pin_new_sint(comp_id, HAL_IN, &(inst->pages[p].args[a].s), 0, "lcd.%02i.page.%02i.arg.%02i", i, p, a); @@ -207,13 +207,13 @@ int rtapi_app_main(void){ } for (i = 0; i < lcd->num_insts; i++){ - retval = hal_pin_new_ui32(comp_id, HAL_IN, &(lcd->insts[i].page_num), 0, + retval = hal_pin_new_uint(comp_id, HAL_IN, &(lcd->insts[i].page_num), 0, "lcd.%02i.page_num", i); if (retval != 0) { return retval; } lcd->insts[i].last_page = -1; // force screen refresh - retval = hal_pin_new_ui32(comp_id, HAL_OUT, &(lcd->insts[i].out), 0, + retval = hal_pin_new_uint(comp_id, HAL_OUT, &(lcd->insts[i].out), 0, "lcd.%02i.out",i); if (retval != 0) { return retval; @@ -223,7 +223,7 @@ int rtapi_app_main(void){ if (retval != 0) { return retval; } - retval = hal_param_new_ui32(comp_id, HAL_RW, &(lcd->insts[i].dp), '.', + retval = hal_param_new_uint(comp_id, HAL_RW, &(lcd->insts[i].dp), '.', "lcd.%02i.decimal-separator",i); if (retval != 0) { return retval; @@ -276,18 +276,18 @@ static void write_one(lcd_inst_t *inst){ return;} if (inst->buff[inst->c_ptr] != 0){ - hal_set_ui32(inst->out, inst->buff[inst->c_ptr++]); + hal_set_uint(inst->out, inst->buff[inst->c_ptr++]); return; } inst->c_ptr = 0; inst->buff[0] = 0; - if (hal_get_ui32(inst->page_num) >= inst->num_pages) return; // should this error? + if (hal_get_uint(inst->page_num) >= inst->num_pages) return; // should this error? - if (hal_get_ui32(inst->page_num) != inst->last_page){ - inst->last_page = hal_get_ui32(inst->page_num); - hal_set_ui32(inst->out, 0x11); //cursor off + if (hal_get_uint(inst->page_num) != inst->last_page){ + inst->last_page = hal_get_uint(inst->page_num); + hal_set_uint(inst->out, 0x11); //cursor off inst->buff[0] = 0x1E; //cursor home inst->buff[1] = 0x1A; //clear screen inst->buff[2] = 0; // end @@ -297,8 +297,8 @@ static void write_one(lcd_inst_t *inst){ return; } - if (inst->f_ptr >= inst->pages[hal_get_ui32(inst->page_num)].length){ - hal_set_ui32(inst->out, 0x1B); // ESC + if (inst->f_ptr >= inst->pages[hal_get_uint(inst->page_num)].length){ + hal_set_uint(inst->out, 0x1B); // ESC inst->buff[0] = 0x3D; // = inst->buff[1] = 0x20; // Line 0 inst->buff[2] = 0x20; // Column 0 @@ -314,7 +314,7 @@ static void write_one(lcd_inst_t *inst){ if (c > 0xBF) c = 0xBF; if (c < 0x20) c = 0x20; inst->last_contrast = hal_get_real(inst->contrast); - hal_set_ui32(inst->out, 0x1B); + hal_set_uint(inst->out, 0x1B); inst->buff[0] = 'C'; inst->buff[1] = c; inst->buff[2] = 0; @@ -322,9 +322,9 @@ static void write_one(lcd_inst_t *inst){ return; } - switch (inst->pages[hal_get_ui32(inst->page_num)].fmt[inst->f_ptr]){ + switch (inst->pages[hal_get_uint(inst->page_num)].fmt[inst->f_ptr]){ case '\\': //escape chars - c1 = inst->pages[hal_get_ui32(inst->page_num)].fmt[++inst->f_ptr]; + c1 = inst->pages[hal_get_uint(inst->page_num)].fmt[++inst->f_ptr]; switch (c1){ case 'n': case 'N': @@ -350,7 +350,7 @@ static void write_one(lcd_inst_t *inst){ /* Fallthrough */ default: //check for hex - c2 = inst->pages[hal_get_ui32(inst->page_num)].fmt[++inst->f_ptr]; + c2 = inst->pages[hal_get_uint(inst->page_num)].fmt[++inst->f_ptr]; inst->f_ptr++; if (c1 > '9') c1 &= 0xDF; //upper case if (c2 > '9') c2 &= 0xDF; @@ -362,24 +362,24 @@ static void write_one(lcd_inst_t *inst){ inst->buff[0] = 0; } } - hal_set_ui32(inst->out, inst->buff[0]); + hal_set_uint(inst->out, inst->buff[0]); inst->c_ptr = 1; return; case '%': - retval = parse_fmt(inst->pages[hal_get_ui32(inst->page_num)].fmt, + retval = parse_fmt(inst->pages[hal_get_uint(inst->page_num)].fmt, &inst->f_ptr, inst->buff, - &(inst->pages[hal_get_ui32(inst->page_num)].args[inst->a_ptr++]), - (char)hal_get_ui32(inst->dp)); + &(inst->pages[hal_get_uint(inst->page_num)].args[inst->a_ptr++]), + (char)hal_get_uint(inst->dp)); if (retval >= 0) { - hal_set_ui32(inst->out, inst->buff[0]); + hal_set_uint(inst->out, inst->buff[0]); inst->c_ptr = 1; inst->f_ptr++; return; } /* Fallthrough */ default: - hal_set_ui32(inst->out, inst->pages[hal_get_ui32(inst->page_num)].fmt[inst->f_ptr++]); + hal_set_uint(inst->out, inst->pages[hal_get_uint(inst->page_num)].fmt[inst->f_ptr++]); } } @@ -473,9 +473,9 @@ static int parse_fmt(char *in, int *ptr, char *out, hal_refs_u *val, char dp){ case 'u': if (out == NULL || val == NULL) return 'u'; { - unsigned int tmp; + rtapi_uint tmp; int i; - unsigned int v = hal_get_ui32(val->u); + rtapi_uint v = hal_get_uint(val->u); if (c < 1) c = num_digits_baseN(v, base); @@ -501,16 +501,17 @@ static int parse_fmt(char *in, int *ptr, char *out, hal_refs_u *val, char dp){ case 'i': if (out == NULL || val == NULL) return 's'; { - int tmp, s = 0; + rtapi_sint tmp; + int s = 0; int i; - int v = hal_get_si32(val->s); + rtapi_sint v = hal_get_sint(val->s); if (sgn == '+') s = 1; if (v < 0) {s = 1; sgn = '-'; v = -v;} if (c < 1) c = num_digits_baseN(v, base) + s; - tmp = abs(v); + tmp = v < 0 ? -v : v; for (i = c - 1; i >= s; i--){ if (tmp != 0 || i == c - 1){ out[i] = digits[tmp % 10]; @@ -607,7 +608,7 @@ static int parse_fmt(char *in, int *ptr, char *out, hal_refs_u *val, char dp){ if (out == NULL || val == NULL) return 'c'; { int i; - unsigned char v = hal_get_ui32(val->u); + unsigned char v = hal_get_uint(val->u) & 0xff; if (c == 0) c = 1; for (i = 0; i < c; i++){ diff --git a/src/hal/components/lut5.comp b/src/hal/components/lut5.comp index 20720893c53..38cb5e190fa 100644 --- a/src/hal/components/lut5.comp +++ b/src/hal/components/lut5.comp @@ -5,7 +5,7 @@ pin in bool in_2; pin in bool in_3; pin in bool in_4; pin out bool out; -param rw ui32 function; +param rw uint function; function _; description """ *lut5* diff --git a/src/hal/components/matrix_kb.c b/src/hal/components/matrix_kb.c index 1d49516ee09..ba2036d15f9 100644 --- a/src/hal/components/matrix_kb.c +++ b/src/hal/components/matrix_kb.c @@ -45,8 +45,8 @@ typedef struct { char name[HAL_NAME_LEN + 1]; struct input_dev *key_dev; rtapi_u32 index; - unsigned keydown; - unsigned keyup; + rtapi_uint keydown; + rtapi_uint keyup; unsigned rowshift; unsigned row; unsigned num_keys; @@ -69,10 +69,10 @@ RTAPI_MP_ARRAY_STRING(names, MAX_CHAN, "component names"); void keyup(kb_inst_t *inst){ unsigned r, c; - unsigned keycode = hal_get_ui32(inst->hal.keycode) & ~(inst->keydown | inst->keyup); + rtapi_uint keycode = hal_get_uint(inst->hal.keycode) & ~(inst->keydown | inst->keyup); r = keycode >> inst->rowshift; - c = keycode & ~(0xFFFFFFFF << inst->rowshift); + c = keycode & ((1ul << inst->rowshift) - 1); if ( r >= inst->nrows || c >= inst->ncols @@ -86,10 +86,10 @@ void keyup(kb_inst_t *inst){ } void keydown(kb_inst_t *inst){ unsigned r, c; - unsigned keycode = hal_get_ui32(inst->hal.keycode) & ~(inst->keydown | inst->keyup); + rtapi_uint keycode = hal_get_uint(inst->hal.keycode) & ~(inst->keydown | inst->keyup); r = keycode >> inst->rowshift; - c = keycode & ~(0xFFFFFFFF << inst->rowshift); + c = keycode & ((1ul << inst->rowshift) - 1); if ( r >= inst->nrows || c >= inst->ncols @@ -97,7 +97,7 @@ void keydown(kb_inst_t *inst){ return; } - if (inst->num_keys >= hal_get_ui32(inst->param.rollover)) return; + if (inst->num_keys >= hal_get_uint(inst->param.rollover)) return; inst->num_keys++; hal_set_bool(inst->hal.key[r * inst->ncols + c], 1); @@ -118,13 +118,13 @@ void loop(void *arg, long period){ for (c = 0; c < inst->ncols; c++){ int mask = 1 << c; if ((inst->then[inst->row] & mask) && !(scan & mask)){ //keyup - hal_set_ui32(inst->hal.keycode, inst->keyup + hal_set_uint(inst->hal.keycode, inst->keyup + (inst->row << inst->rowshift) + c); keyup(inst); } else if (!(inst->then[inst->row] & mask) && (scan & mask)){//keydown - hal_set_ui32(inst->hal.keycode, inst->keydown + hal_set_uint(inst->hal.keycode, inst->keydown + (inst->row << inst->rowshift) + c); @@ -133,7 +133,7 @@ void loop(void *arg, long period){ } } else { - hal_set_ui32(inst->hal.keycode, 0x40);//nochange + hal_set_uint(inst->hal.keycode, 0x40);//nochange } inst->then[inst->row] = inst->now[inst->row]; @@ -146,7 +146,7 @@ void loop(void *arg, long period){ } else { - rtapi_u32 keycode = hal_get_ui32(inst->hal.keycode); + rtapi_uint keycode = hal_get_uint(inst->hal.keycode); if (keycode == 0x40) return; if ((keycode & inst->keydown) == inst->keydown){ keydown(inst); @@ -293,7 +293,7 @@ int rtapi_app_main(void){ } } - retval = hal_pin_new_ui32(comp_id, HAL_OUT, + retval = hal_pin_new_uint(comp_id, HAL_OUT, &(inst->hal.keycode), 0, "%s.keycode",inst->name); if (retval != 0) { @@ -314,7 +314,7 @@ int rtapi_app_main(void){ } - retval = hal_param_new_ui32(comp_id, HAL_RW, + retval = hal_param_new_uint(comp_id, HAL_RW, &(inst->param.rollover), 2, "%s.key_rollover",inst->name); if (retval != 0) { @@ -327,7 +327,7 @@ int rtapi_app_main(void){ } else // scanning by 7i73 or similar { - retval = hal_pin_new_ui32(comp_id, HAL_IN, + retval = hal_pin_new_uint(comp_id, HAL_IN, &(inst->hal.keycode), 0, "%s.keycode",inst->name); if (retval != 0) { diff --git a/src/hal/components/millturn.comp b/src/hal/components/millturn.comp index 23f538b33ac..864a4cd82f8 100644 --- a/src/hal/components/millturn.comp +++ b/src/hal/components/millturn.comp @@ -74,8 +74,8 @@ EXTRA_SETUP() { if (!haldata) goto error; // hal pin examples: - res += hal_pin_new_ui32(comp_id, HAL_IN, &haldata->in, 0, "%s.in", HAL_PREFIX); - res += hal_pin_new_ui32(comp_id, HAL_OUT, &haldata->out, 0, "%s.out", HAL_PREFIX); + res += hal_pin_new_uint(comp_id, HAL_IN, &haldata->in, 0, "%s.in", HAL_PREFIX); + res += hal_pin_new_uint(comp_id, HAL_OUT, &haldata->out, 0, "%s.out", HAL_PREFIX); // hal parameter examples: //res += hal_param_new_real(comp_id, HAL_RW, &haldata->param_rw, 0.0, "%s.param-rw", HAL_PREFIX); //res += hal_param_new_real(comp_id, HAL_RO, &haldata->param_ro, 0.0, "%s.param-ro", HAL_PREFIX); @@ -182,7 +182,7 @@ int kinematicsForward(const double *j, pos->v = 0; pos->w = 0; - if (hal_get_ui32(haldata->in) && !is_ready && !gave_msg) { + if (hal_get_uint(haldata->in) && !is_ready && !gave_msg) { rtapi_print_msg(RTAPI_MSG_ERR, "%s the 'in' pin not echoed until Inverse called\n", __FILE__); @@ -220,7 +220,7 @@ int kinematicsInverse(const EmcPose * pos, } //example hal pin update (homing reqd before kinematicsInverse) - hal_set_ui32(haldata->out, hal_get_ui32(haldata->in)); //dereference + hal_set_uint(haldata->out, hal_get_uint(haldata->in)); //dereference //read from param example: *haldata->out = hal_get_real(haldata->param_rw); return 0; diff --git a/src/hal/components/modmath.c b/src/hal/components/modmath.c index c24ca3608e2..0714487a3c3 100644 --- a/src/hal/components/modmath.c +++ b/src/hal/components/modmath.c @@ -118,20 +118,20 @@ static void mod_dir_funct(void *arg, long period) (void)period; mod_dir_t *mod = (mod_dir_t *)arg; /* point to block data */ - rtapi_s32 min_num = hal_get_si32(mod->min_num); - rtapi_s32 max_num = hal_get_si32(mod->max_num); + rtapi_sint min_num = hal_get_sint(mod->min_num); + rtapi_sint max_num = hal_get_sint(mod->max_num); - rtapi_s32 range = max_num - min_num + 1; - rtapi_s32 act = hal_get_si32(mod->actual); + rtapi_sint range = max_num - min_num + 1; + rtapi_sint act = hal_get_sint(mod->actual); if (act > max_num || act < min_num) { act = min_num + ((act-min_num) % (range)); } - rtapi_s32 des = hal_get_si32(mod->desired); + rtapi_sint des = hal_get_sint(mod->desired); if (des > max_num || des < min_num) { des = min_num + ((des-min_num) % (range)); } - rtapi_s32 to_go = des-act; + rtapi_sint to_go = des-act; if ((hal_get_bool(mod->wrap)) && (to_go > range/2)) { to_go -= range; @@ -187,12 +187,12 @@ static int export_mod_dir(int num) CHK(hal_pin_new_bool(comp_id, HAL_OUT, &(moddir->on_target), 1, "%s.on-target", base), "on-target"); /* export input pins */ - CHK(hal_pin_new_si32(comp_id, HAL_IN, &(moddir->actual), 0, "%s.actual", base), "actual"); - CHK(hal_pin_new_si32(comp_id, HAL_IN, &(moddir->desired), 0, "%s.desired", base), "desired"); + CHK(hal_pin_new_sint(comp_id, HAL_IN, &(moddir->actual), 0, "%s.actual", base), "actual"); + CHK(hal_pin_new_sint(comp_id, HAL_IN, &(moddir->desired), 0, "%s.desired", base), "desired"); /* export pins for max and min values */ - CHK(hal_pin_new_si32(comp_id, HAL_IO, &(moddir->min_num), 0, "%s.min-num", base), "min-num"); - CHK(hal_pin_new_si32(comp_id, HAL_IO, &(moddir->max_num), 15, "%s.max-num", base), "max-num"); + CHK(hal_pin_new_sint(comp_id, HAL_IO, &(moddir->min_num), 0, "%s.min-num", base), "min-num"); + CHK(hal_pin_new_sint(comp_id, HAL_IO, &(moddir->max_num), 15, "%s.max-num", base), "max-num"); CHK(hal_pin_new_bool(comp_id, HAL_IO, &(moddir->wrap), 1, "%s.wrap", base), "wrap"); /* export function */ diff --git a/src/hal/components/orient.comp b/src/hal/components/orient.comp index 514d0b52223..d6359c61efb 100644 --- a/src/hal/components/orient.comp +++ b/src/hal/components/orient.comp @@ -10,7 +10,7 @@ pin out bool is-oriented "This pin goes high when poserr < tolerance. Use to d pin in real tolerance = 0.5 "The tolerance in degrees for considering the align completed"; pin io bool index-enable "Connect to the spindle encoder counter to reset to index before orienting"; -param r ui32 state "state machine for index homing"; +param r uint state "state machine for index homing"; variable rtapi_bool last_enable = 0; variable int debounce = 0; // to prevent the in-position triggering with the spindle moving diff --git a/src/hal/components/pid.c b/src/hal/components/pid.c index fb0b7c87f61..9bdf2d26299 100644 --- a/src/hal/components/pid.c +++ b/src/hal/components/pid.c @@ -244,8 +244,8 @@ typedef struct { /* Private data */ State state; - rtapi_u32 cycleCount; - rtapi_u32 cyclePeriod; + rtapi_uint cycleCount; + rtapi_uint cyclePeriod; rtapi_real cycleAmplitude; rtapi_real totalTime; rtapi_real avgAmplitude; @@ -350,7 +350,7 @@ static void Pid_CycleEnd(hal_pid_t *pid) { pid->cycleCount++; - pid->avgAmplitude += pid->cycleAmplitude / hal_get_ui32(pid->tuneCycles); + pid->avgAmplitude += pid->cycleAmplitude / hal_get_uint(pid->tuneCycles); pid->cycleAmplitude = 0; pid->totalTime += pid->cyclePeriod * 0.000000001; pid->cyclePeriod = 0; @@ -440,16 +440,16 @@ Pid_AutoTune(hal_pid_t *pid, long period) // Check if the last cycle just ended. This is really the number // of half cycles. - if(pid->cycleCount < hal_get_ui32(pid->tuneCycles)) + if(pid->cycleCount < hal_get_uint(pid->tuneCycles)) break; // Calculate PID using Relay (Åström-Hägglund) method hal_set_real(pid->ultimateGain, (4.0 * fabs(hal_get_real(pid->tuneEffort)))/(PI * pid->avgAmplitude)); - hal_set_real(pid->ultimatePeriod, 2.0 * pid->totalTime / hal_get_ui32(pid->tuneCycles)); + hal_set_real(pid->ultimatePeriod, 2.0 * pid->totalTime / hal_get_uint(pid->tuneCycles)); hal_set_real(pid->ff0gain, 0); hal_set_real(pid->ff2gain, 0); - if(hal_get_ui32(pid->tuneType) == TYPE_PID){ + if(hal_get_uint(pid->tuneType) == TYPE_PID){ // insert ultimate gain and period in Ziegler-Nichols PID method hal_set_real(pid->pgain, 0.6 * hal_get_real(pid->ultimateGain)); hal_set_real(pid->igain, 1.2 * hal_get_real(pid->ultimateGain) / (hal_get_real(pid->ultimatePeriod))); @@ -677,12 +677,16 @@ static void calc_pid(void *arg, long period) if(pid->limit_state) { hal_set_bool(pid->saturated, 1); hal_set_real(pid->saturated_s, hal_get_real(pid->saturated_s) + period * 1e-9); - if(hal_get_si32(pid->saturated_count) != 2147483647) - hal_set_si32(pid->saturated_count, hal_get_si32(pid->saturated_count) + 1); + // FIXME: This comparison can now be extended to 2**63-1, but should we? + // It can also be removed... + // The time it takes to reach the top would be more than the Universe + // has existed if we counted nanoseconds. + if(hal_get_sint(pid->saturated_count) != 2147483647) + hal_set_sint(pid->saturated_count, hal_get_sint(pid->saturated_count) + 1); } else { hal_set_bool(pid->saturated, 0); hal_set_real(pid->saturated_s, 0); - hal_set_si32(pid->saturated_count, 0); + hal_set_sint(pid->saturated_count, 0); } /* done */ } @@ -722,7 +726,7 @@ static int export_pid(hal_pid_t * addr, char * prefix) CHK(hal_pin_new_real(comp_id, HAL_OUT, &(addr->output), 0.0, "%s.output", prefix)); CHK(hal_pin_new_bool(comp_id, HAL_OUT, &(addr->saturated), 0, "%s.saturated", prefix)); CHK(hal_pin_new_real(comp_id, HAL_OUT, &(addr->saturated_s), 0.0, "%s.saturated-s", prefix)); - CHK(hal_pin_new_si32(comp_id, HAL_OUT, &(addr->saturated_count), 0, "%s.saturated-count", prefix)); + CHK(hal_pin_new_sint(comp_id, HAL_OUT, &(addr->saturated_count), 0, "%s.saturated-count", prefix)); CHK(hal_pin_new_real(comp_id, HAL_IN, &(addr->pgain), 1.0, "%s.Pgain", prefix)); CHK(hal_pin_new_real(comp_id, HAL_IN, &(addr->igain), 0.0, "%s.Igain", prefix)); CHK(hal_pin_new_real(comp_id, HAL_IN, &(addr->dgain), 0.0, "%s.Dgain", prefix)); @@ -745,8 +749,8 @@ static int export_pid(hal_pid_t * addr, char * prefix) #ifdef AUTO_TUNER /* Auto tune related */ CHK(hal_pin_new_real(comp_id, HAL_IO, &(addr->tuneEffort), 0.5, "%s.tune-effort", prefix)); - CHK(hal_pin_new_ui32(comp_id, HAL_IO, &(addr->tuneCycles), 50, "%s.tune-cycles", prefix)); - CHK(hal_pin_new_ui32(comp_id, HAL_IO, &(addr->tuneType), TYPE_PID, "%s.tune-type", prefix)); + CHK(hal_pin_new_uint(comp_id, HAL_IO, &(addr->tuneCycles), 50, "%s.tune-cycles", prefix)); + CHK(hal_pin_new_uint(comp_id, HAL_IO, &(addr->tuneType), TYPE_PID, "%s.tune-type", prefix)); CHK(hal_pin_new_bool(comp_id, HAL_IN, &(addr->pTuneMode), 0, "%s.tune-mode", prefix)); CHK(hal_pin_new_bool(comp_id, HAL_IO, &(addr->pTuneStart), 0, "%s.tune-start", prefix)); #endif /* AUTO_TUNER */ diff --git a/src/hal/components/plasmac.comp b/src/hal/components/plasmac.comp index b7146429cd6..bd09760d2ce 100644 --- a/src/hal/components/plasmac.comp +++ b/src/hal/components/plasmac.comp @@ -70,12 +70,12 @@ pin in bool ignore_arc_ok_1 "Do not require arc ok for start or pin in real kerf_width "placeholder for better G-code portability between GUIs"; pin in bool laser_mode "laser mode for fiber lasers"; pin in sint laser_recovery_start "start laser offset for cut recovery"; -pin in si32 laser_x_offset "alignment laser x axis offset (scaled units)"; -pin in si32 laser_y_offset "alignment laser y axis offset (scaled units)"; +pin in sint laser_x_offset "alignment laser x axis offset (scaled units)"; +pin in sint laser_y_offset "alignment laser y axis offset (scaled units)"; pin in real lowpass_frequency "lowpass cutoff frequency for arc voltage output"; pin in bool machine_is_on "machine is on signal, connect to halui.machine.is-on"; pin in real material_thickness "material thickness (machine units)"; -pin in si32 max_offset = 5 "maximum height offset (mm)"; +pin in sint max_offset = 5 "maximum height offset (mm)"; pin in bool mesh_arc_ok = FALSE "Do not require arc ok for mesh mode."; pin in bool mesh_enable "enable mesh cutting mode"; pin in sint mode "operating mode"; @@ -95,11 +95,11 @@ pin in sint ohmic_max_attempts "maximum ohmic probe attempts before pin in bool ohmic_probe "ohmic probe input, from ohmic-sense-out or external component/pin"; pin in bool ohmic_probe_enable "enable ohmic probe"; pin in real ohmic_probe_offset "Z axis offset for ohmic probe (machine units)"; -pin in si32 ohmic_sense_on_delay = 3 "debounce cycles for ohmic sense on"; -pin in si32 ohmic_sense_off_delay = 3 "debounce cycles for ohmic sense off"; +pin in sint ohmic_sense_on_delay = 3 "debounce cycles for ohmic sense on"; +pin in sint ohmic_sense_off_delay = 3 "debounce cycles for ohmic sense off"; pin in bool ohmic_sense_in "ohmic sense relay input"; pin in bool ohmic_test "test for shorted torch"; -pin in si32 ok_sample_counts = 10 "arc_ok number of valid samples required [mode 0]"; +pin in sint ok_sample_counts = 10 "arc_ok number of valid samples required [mode 0]"; pin in real ok_sample_threshold = 10 "arc_ok maximum arc voltage deviation allowed [mode 0]"; pin in bool override_jog "override jog inhibit"; pin in real pause_at_end "time to pause at end of cut"; @@ -110,7 +110,7 @@ pin in real pid_p_gain "proportional gain input [mode 0 & m pin in real pierce_delay "time required to pierce stock (seconds)"; pin in real pierce_height "pierce height (machine units)"; pin in real probe_feed_rate "probe down velocity (machine units per minute)"; -pin in si32 probe_final_speed = 1 "final probe speed (steps per servo period)"; +pin in sint probe_final_speed = 1 "final probe speed (steps per servo period)"; pin in real probe_start_height "probe starting height"; pin in bool probe_test "probe test only"; pin in bool program_is_idle "program is idle, connect to halui.program.is-idle"; @@ -120,7 +120,7 @@ pin in real puddle_jump_delay "Delay move from pierce height to cu pin in real puddle_jump_height "Puddle jump height (percentage of pierce height), leave disconnected if not required."; /* requested_velocity is deprecated in favour of feed_upm, the pin is kept so as not to break existing configs */ pin in real requested_velocity "deprecated"; -pin in si32 resolution = 100 "multiplier for resolution of the offset counts"; +pin in sint resolution = 100 "multiplier for resolution of the offset counts"; pin in real restart_delay "time from arc failure till next restart attempt"; pin in real safe_height "requested safe traverse height (machine units)"; pin in real scribe_arm_delay "delay from scribe arm to scribe on"; @@ -137,7 +137,7 @@ pin in real thc_delay "delay from cut feed rate reached to pin in bool thc_disable "thc disable"; pin in bool thc_enable "enable/disable thc and set the IHS skip type"; pin in real thc_feed_rate "maximum feed rate for thc (machine units per minute)"; -pin in si32 thc_sample_counts = 50 "thc number of valid samples required [auto THC]"; +pin in sint thc_sample_counts = 50 "thc number of valid samples required [auto THC]"; pin in real thc_sample_threshold = 1 "thc maximum arc voltage deviation allowed [auto THC]"; pin in real thc_threshold "thc threshold (volts), changes below this have no effect"; pin in bool torch_enable "enable torch"; @@ -150,18 +150,18 @@ pin in bool tube_cut "set the current job as tube cutting pin in real units_per_mm "for scale calcs, connect to halui.machine.units-per-mm"; pin in bool use_auto_volts "use calculated voltage for thc baseline"; pin in bool voidlock_enable "enable voidlock [mode 0 & mode 1]"; -pin in si32 voidlock_off_cycles = 10 "number of sampling cycles to deactivate voidlock"; -pin in si32 voidlock_on_cycles = 2 "number of sampling cycles to activate voidlock "; -pin in si32 voidlock_slope = 500 "voidlock slope in volts per second"; -pin in si32 x_offset "offset to apply to axis x for consumable change and cut recovery (scaled units)"; +pin in sint voidlock_off_cycles = 10 "number of sampling cycles to deactivate voidlock"; +pin in sint voidlock_on_cycles = 2 "number of sampling cycles to activate voidlock "; +pin in sint voidlock_slope = 500 "voidlock slope in volts per second"; +pin in sint x_offset "offset to apply to axis x for consumable change and cut recovery (scaled units)"; pin in real x_offset_current "current x axis offset, connect to axis.x.eoffset"; pin in real xy_feed_rate "feed-rate for consumable change"; -pin in si32 y_offset "offset to apply to axis y for consumable change and cut recovery (scaled units)"; +pin in sint y_offset "offset to apply to axis y for consumable change and cut recovery (scaled units)"; pin in real y_offset_current "current y axis offset, connect to axis.y.eoffset"; pin in real z_offset_current "current z axis offset, connect to axis.z.eoffset"; pin in real zero_window = 0.1 "sets window that voltage fluctuations show as zero (-0.1 to 0.1 at default value)"; // Pierce type user control pins -pin in si32 pierce_type = 0 "allows motion to progress during pierce. 0=No movement, 1=Wiggle, 2=Ramp"; +pin in sint pierce_type = 0 "allows motion to progress during pierce. 0=No movement, 1=Wiggle, 2=Ramp"; pin in real pierce_motion_delay = 0 "delay starting motion during pierce delay period. This is a % of Pierce Delay. Only used when pierce-with-motion is True."; pin in real cut_height_delay = 0 "at the end of transition to end-pierce-height how long to pause before transition to cut height."; pin in real pierce_end_height = 0 "height at end of piercing (in machine units). Can be different to Cut Height. Default 0 means not used. i.e. no change in height."; @@ -213,11 +213,11 @@ pin out bool thc_enabled "thc is enabled"; pin out bool torch_on "turn torch on, connect to your torch on input"; pin out real torch_time "torch on time of current job"; pin out bool voidlock_is_locked "voidlock is locked indicator [mode 0 & mode 1]"; -pin out si32 x_offset_counts "x offset for consumable change, connect to axis.x.eoffset-counts"; +pin out sint x_offset_counts "x offset for consumable change, connect to axis.x.eoffset-counts"; pin out bool xy_offset_enable "enable x and y offsets, connect to axis..eoffset-enable"; -pin out si32 y_offset_counts "y offset for consumable change, connect to axis.y.eoffset-counts"; +pin out sint y_offset_counts "y offset for consumable change, connect to axis.y.eoffset-counts"; pin out real z_height "current z axis height relative to the probed zero height"; -pin out si32 z_offset_counts "z offset for height control, connect to axis.z.eoffset-counts"; +pin out sint z_offset_counts "z offset for height control, connect to axis.z.eoffset-counts"; pin out bool z_offset_enable "enable z offsets, connect to axis.z.eoffset-enable"; pin out real z_relative "distance of Z from last probed height"; @@ -225,7 +225,7 @@ pin out real z_relative "distance of Z from last probed heig variable double angle_x_y; /* angle for x/y velocity calcs in radians*/ variable double arc_fail_timer; /* arc failure timer */ variable double arc_lost_timer; /* arc lost timer */ -variable int arc_starts; /* number of attempts to start torch */ +variable rtapi_sint arc_starts; /* number of attempts to start torch */ variable double arc_valid_timer; /* timer to wait for valid arc_voltage_in */ variable double arc_voltage_raw; /* filtered arc voltage to be scaled */ variable int arc_voltage_buffer_index; /* arc voltage sampler write index */ @@ -235,73 +235,72 @@ variable double axis_x_start; /* axis x position at start of cut * variable double axis_y_finish; /* axis y position at end of cut */ variable double axis_y_start; /* axis y position at start of cut */ variable int cons_change_clear; /* consumable change is clearing */ -variable int count; /* for counting */ -variable int cut_height_first; /* cut height at start of cut */ -variable int cut_height_last; /* cut height at end of cut */ +variable rtapi_sint count; /* for counting */ +variable rtapi_sint cut_height_first; /* cut height at start of cut */ +variable rtapi_sint cut_height_last; /* cut height at end of cut */ variable double cut_offset; /* offset from last cut end to this cut start */ variable bool cut_started; /* cut has started */ -variable int cut_target; /* cut height target offset */ +variable rtapi_sint cut_target; /* cut height target offset */ variable bool error_message; /* 1 if error message has been sent */ variable bool first_cut_finished; /* first cut is complete */ variable bool float_detected; /* float switch detected */ -variable int height_ovr_counts; /* number of counts to change height via override */ +variable rtapi_sint height_ovr_counts; /* number of counts to change height via override */ variable double height_ovr_old; /* old height override value */ variable bool initialized; /* initialization flag */ -variable int laser_x_target; /* target count for laser recovery x offset */ -variable int laser_y_target; /* target count for laser recovery y offset */ +variable rtapi_sint laser_x_target; /* target count for laser recovery x offset */ +variable rtapi_sint laser_y_target; /* target count for laser recovery y offset */ variable double last_arc_voltage; /* last sensed arc voltage */ variable bool manual_cut; /* manual cut mode is active */ -variable int offset_datum; /* datum for safe height calcs */ +variable rtapi_sint offset_datum; /* datum for safe height calcs */ variable bool offset_limit_error = false; /* has an offset error been reported (prevents repeat messages)*/ -variable int offset_max; /* maximum allowed offset */ -variable int offset_min; /* minimum allowed offset */ +variable rtapi_sint offset_max; /* maximum allowed offset */ +variable rtapi_sint offset_min; /* minimum allowed offset */ variable double offset_probe_timer; /* offset probe deployment delay time */ variable bool offset_probing; /* offset probing is enabled */ -variable int offset_res; /* resolution for comparing offset move to target*/ +variable rtapi_sint offset_res; /* resolution for comparing offset move to target*/ variable bool offset_set; /* probe or scribe is being offset*/ -variable int offset_velocity; /* velocity for probe offset moves */ -variable int ohmic_attempts; /* current ohmic probe attempts */ +variable rtapi_sint offset_velocity; /* velocity for probe offset moves */ +variable rtapi_sint ohmic_attempts; /* current ohmic probe attempts */ variable bool ohmic_detected; /* true if ohmic probe detected */ -variable int ohmic_sense_counts; /* ohmic sense debounce counter */ -variable int ok_sampler_samples; /* required number of arc ok samples [mode0] */ -variable int old_resolution; /* previous resolution value */ -variable int op_x_start; /* x offset when offset probing started */ -variable int op_x_target; /* target offset for x probe offset */ -variable int op_x_velocity; /* velocity for x probe offset */ +variable rtapi_sint ohmic_sense_counts; /* ohmic sense debounce counter */ +variable rtapi_sint ok_sampler_samples; /* required number of arc ok samples [mode0] */ +variable rtapi_sint op_x_start; /* x offset when offset probing started */ +variable rtapi_sint op_x_target; /* target offset for x probe offset */ +variable rtapi_sint op_x_velocity; /* velocity for x probe offset */ variable double op_xy_angle; /* angle for x/y probe offset calcs in radians*/ -variable int op_y_start; /* y offset when offset probing started */ -variable int op_y_target; /* target offset for y probe offset */ -variable int op_y_velocity; /* velocity for y probe offset */ +variable rtapi_sint op_y_start; /* y offset when offset probing started */ +variable rtapi_sint op_y_target; /* target offset for y probe offset */ +variable rtapi_sint op_y_velocity; /* velocity for y probe offset */ variable double pause_at_end_timer; /* pause at end of cut timer */ variable double paused_motion_timer; /* minimum run timer for paused motion */ variable double pid_error_now; /* current error for pid calcs */ variable double pid_error_old; /* old error for pid calcs */ variable double pid_output; /* calculated pid output value */ -variable int pierce_target; /* pierce height target offset */ +variable rtapi_sint pierce_target; /* pierce height target offset */ variable double pierce_timer; /* pierce delay timer */ variable double probe_at_bottom; /* probe is at bottom limit */ variable bool probe_inhibit; /* inhibit probing */ -variable int probe_offset; /* offset for active probe */ +variable rtapi_sint probe_offset; /* offset for active probe */ variable bool probe_required = 1; /* a probe sequence is required */ variable bool probe_retry; /* probe will retry after contact before probe height */ -variable int probe_start_target; /* probe start height target */ +variable rtapi_sint probe_start_target; /* probe start height target */ variable bool probe_testing; /* probe test active */ -variable int probe_velocity; /* probe down velocity */ +variable rtapi_sint probe_velocity; /* probe down velocity */ variable int puddle_jump_percent; /* puddle jump height as percentage of pierce height */ -variable int puddle_jump_target; /* puddle jump height target offset */ +variable rtapi_sint puddle_jump_target; /* puddle jump height target offset */ variable double puddle_jump_timer; /* puddle jump delay timer */ variable double recovery_velocity; /* cut recovery step velocity */ -variable int res; /* resolution of offset move*/ +variable rtapi_sint res; /* resolution of offset move*/ variable double restart_timer; /* time between torch on attempts*/ -variable int safe_alarm; /* warn if safe_available falls below this value during a cut */ -variable int safe_available; /* available safe height */ -variable int safe_min; /* minimum safe height allowed */ -variable int safe_preferred; /* preferred safe height offset */ -variable int safe_target; /* safe height target offset */ +variable rtapi_sint safe_alarm; /* warn if safe_available falls below this value during a cut */ +variable rtapi_sint safe_available; /* available safe height */ +variable rtapi_sint safe_min; /* minimum safe height allowed */ +variable rtapi_sint safe_preferred; /* preferred safe height offset */ +variable rtapi_sint safe_target; /* safe height target offset */ variable double scribe_arm_timer; /* scribe timer from arm to on*/ variable double scribe_on_timer; /* scribe timer from on to motion*/ variable bool scribe_pause; /* scribe pause flag */ -variable int setup_velocity; /* velocity for setup moves */ +variable rtapi_sint setup_velocity; /* velocity for setup moves */ variable bool spotting; /* spotting flag */ variable double spotting_timer; /* spotting timer */ variable int state_old = -1; /* old state */ @@ -314,27 +313,27 @@ variable double target_total; /* total voltage of samples for sett variable bool thc_activated; /* thc was activated */ variable double thc_activated_timer; /* timer to reset thc_activated - end of cut is detected from userspace :( */ variable double thc_delay_timer; /* thc delay timer [non auto THC] */ -variable int thc_sampler_samples; /* required number of thc samples [auto THC] */ -variable int thc_velocity; /* velocity for thc moves */ +variable rtapi_sint thc_sampler_samples; /* required number of thc samples [auto THC] */ +variable rtapi_sint thc_velocity; /* velocity for thc moves */ variable double torch_off_timer; /* arc off delay timer */ variable double torch_pulse_timer; /* torch pulse timer */ variable double velocity_scale; /* the velocity multiplier */ variable double voidlock_change; /* voltage change this cycle */ -variable double voidlock_off_count; /* current count of voidlock deactivate cycles */ -variable int voidlock_on_count; /* current count of voidlock activate cycles */ +variable rtapi_sint voidlock_off_count; /* current count of voidlock deactivate cycles */ +variable rtapi_sint voidlock_on_count; /* current count of voidlock activate cycles */ variable double voidlock_threshold; /* voidlock threshold voltage per cycle */ -variable int x_velocity; /* velocity for x motion for consumable change */ -variable int y_velocity; /* velocity for y motion for consumable change */ -variable int z_max; /* max height for testing against pierce height*/ -variable int z_pierce; /* pierce height for testing against max height*/ -variable int zero_target; /* zero height target offset */ +variable rtapi_sint x_velocity; /* velocity for x motion for consumable change */ +variable rtapi_sint y_velocity; /* velocity for y motion for consumable change */ +variable rtapi_sint z_max; /* max height for testing against pierce height*/ +variable rtapi_sint z_pierce; /* pierce height for testing against max height*/ +variable rtapi_sint zero_target; /* zero height target offset */ // Pierce type user control variables variable double creep_speed_dist_travelled; /* Sum of distance traveled during creep stage */ variable double creep_speed_scale; /* scale of creep speed in proportion to standard cut feed rate */ variable double cut_height_delay_timer; /* at the end of transition to end-perice-height how long to pause before transition to cut height*/ variable double gouge_speed_dist_travelled; /* Sum of distance traveled during gouge stage */ variable double gouge_speed_scale; /* scale of gouge speed in proportion to standard cut feed rate */ -variable int pierce_end_target; /* Target pierce height at end of pierce motion. Usually less than the starting pierce height */ +variable rtapi_sint pierce_end_target; /* Target pierce height at end of pierce motion. Usually less than the starting pierce height */ variable double pierce_motion_delay_timer; /* delay starting motion during pierce delay period. Only used when pierce-type is 2. Is calced from a % of Pierce Delay*/ variable double pierce_old_x; /* tracking the last x location during pierce */ variable double pierce_old_y; /* tracking the last y location during pierce */ @@ -342,8 +341,8 @@ variable double total_pierce_state_delay; /* Total of pierce delay and cut mot // temp for testing forum post #210558 // https://forum.linuxcnc.org/plasmac/42690-is-this-qtplasmac-expected-behaviour-cycle-start-and-jog-disabled?start=0#210558 -pin in si32 low_cut_volts "low cut voltage threshold while thc active"; -pin in si32 target_samples = 6 "number of samples for setting target_volts"; +pin in sint low_cut_volts "low cut voltage threshold while thc active"; +pin in sint target_samples = 6 "number of samples for setting target_volts"; pin out real target_volts "target voltage for thc, set by arc voltage at cut height"; @@ -438,10 +437,10 @@ laser_recovery_state_t laser_recovery = OFF; #define BUFFERSIZE 1000 #define READ_OK 0 #define READ_THC 1 -float arc_voltage_buffer[BUFFERSIZE]; +double arc_voltage_buffer[BUFFERSIZE]; /* read the arc voltage buffer */ -float read_arc_voltage_buffer(int caller, int size, int index, float target, float threshold){ +double read_arc_voltage_buffer(int caller, rtapi_sint size, int index, double target, double threshold){ int reads = 0; double sum = 0; int errors = 0; @@ -469,7 +468,7 @@ float read_arc_voltage_buffer(int caller, int size, int index, float target, flo } /* set an axis eoffset position at a set velocity */ -int offset_move(int offset, int vel, int target){ +rtapi_sint offset_move(rtapi_sint offset, rtapi_sint vel, rtapi_sint target){ if(offset - vel > target){ offset -= vel; }else if(offset + vel < target){ @@ -803,7 +802,7 @@ FUNCTION(_) { probe_required = TRUE; rtapi_print_msg(RTAPI_MSG_ERR,"arc voltage fell below safe level while THC active\n" "target voltage = %.2f\n" - "low cut volts = %d\n" + "low cut volts = %ld\n" "arc voltage = %.2f\n" "program is paused.\n", target_volts, low_cut_volts, arc_voltage_out); probe_inhibit = TRUE; @@ -1457,7 +1456,7 @@ FUNCTION(_) { if(pierce_height && cut_height && (use_auto_volts || (!use_auto_volts && cut_volts))){ feed_hold_set(TRUE); if(z_offset_counts == pierce_target){ - if((int)(z_offset_current * offset_res) == (int)(pierce_target * offset_scale * offset_res) && + if((rtapi_sint)(z_offset_current * offset_res) == (rtapi_sint)(pierce_target * offset_scale * offset_res) && (((offset_probing && x_offset_counts == op_x_start && y_offset_counts == op_y_start)) || !offset_probing)){ arc_starts = 0; if(probe_testing){ @@ -1473,8 +1472,8 @@ FUNCTION(_) { pierce_old_y = axis_y_position; }else if((tool == CUTTING || tool == SPOTTING) && (!offset_probing || (offset_probing && - (int)(x_offset_current * offset_res) == (int)(op_x_start * offset_scale * offset_res) && - (int)(y_offset_current * offset_res) == (int)(op_y_start * offset_scale * offset_res)))){ + (rtapi_sint)(x_offset_current * offset_res) == (rtapi_sint)(op_x_start * offset_scale * offset_res) && + (rtapi_sint)(y_offset_current * offset_res) == (rtapi_sint)(op_y_start * offset_scale * offset_res)))){ state = TORCH_ON; } } @@ -1682,7 +1681,7 @@ FUNCTION(_) { z_offset_enable_set(TRUE); feed_hold_set(FALSE); if(z_offset_counts == puddle_jump_target){ - if((int)(z_offset_current * offset_res) == (int)(puddle_jump_target * offset_scale * offset_res)){ + if((rtapi_sint)(z_offset_current * offset_res) == (rtapi_sint)(puddle_jump_target * offset_scale * offset_res)){ count = 0; if(puddle_jump_timer > 0){ puddle_jump_timer -= fperiod; @@ -1704,7 +1703,7 @@ FUNCTION(_) { // feed_hold = FALSE; // } if(z_offset_counts == cut_target){ - if((int)(z_offset_current * offset_res) == (int)(cut_target * offset_scale * offset_res)){ + if((rtapi_sint)(z_offset_current * offset_res) == (rtapi_sint)(cut_target * offset_scale * offset_res)){ count = 0; if(cut_recovering){ angle_x_y = atan2(-y_offset_counts, -x_offset_counts); @@ -2012,7 +2011,7 @@ FUNCTION(_) { cornerlock_is_locked_set(FALSE); if(!probe_test || probe_test_error){ if(z_offset_counts == safe_target){ - if((int)(z_offset_current * offset_res) == (int)(safe_target * offset_scale * offset_res)){ + if((rtapi_sint)(z_offset_current * offset_res) == (rtapi_sint)(safe_target * offset_scale * offset_res)){ if(stop_type == WAIT){ feed_hold_set(FALSE); } @@ -2035,7 +2034,7 @@ FUNCTION(_) { cornerlock_is_locked_set(FALSE); if(!probe_test || probe_test_error){ if(z_offset_counts == 0){ - if((int)(z_offset_current * offset_res) == 0){ + if((rtapi_sint)(z_offset_current * offset_res) == 0){ if(stop_type == WAIT){ feed_hold_set(FALSE); } @@ -2251,8 +2250,8 @@ FUNCTION(_) { } consumable_changing_set(TRUE); }else{ - if(((int)(x_offset_current * offset_res) == (int)(x_offset * offset_scale * offset_res) && - (int)(y_offset_current * offset_res) == (int)(y_offset * offset_scale * offset_res)) || + if(((rtapi_sint)(x_offset_current * offset_res) == (rtapi_sint)(x_offset * offset_scale * offset_res) && + (rtapi_sint)(y_offset_current * offset_res) == (rtapi_sint)(y_offset * offset_scale * offset_res)) || !consumable_change){ state = IDLE; }else if(consumable_change){ @@ -2302,7 +2301,7 @@ FUNCTION(_) { } error_message = FALSE; if(x_offset_counts == 0 && y_offset_counts == 0){ - if((int)(x_offset_current * offset_res) == 0 && (int)(y_offset_current * offset_res) == 0){ + if((rtapi_sint)(x_offset_current * offset_res) == 0 && (rtapi_sint)(y_offset_current * offset_res) == 0){ consumable_changing_set(FALSE); cons_change_clear = FALSE; feed_hold_set(FALSE); @@ -2410,7 +2409,7 @@ FUNCTION(_) { y_velocity = fabs(recovery_velocity * sin(angle_x_y)); } if(x_offset_counts == 0 && y_offset_counts == 0){ - if((int)(x_offset_current * offset_res) == 0 && (int)(y_offset_current * offset_res) == 0){ + if((rtapi_sint)(x_offset_current * offset_res) == 0 && (rtapi_sint)(y_offset_current * offset_res) == 0){ laser_recovery_state_set(OFF); if(cut_recovering){ cut_recovering_set(FALSE); diff --git a/src/hal/components/sampler.c b/src/hal/components/sampler.c index 9d273a4993f..34e84bfc412 100644 --- a/src/hal/components/sampler.c +++ b/src/hal/components/sampler.c @@ -157,7 +157,7 @@ static void sample(void *arg, long period) /* are we enabled? */ if (!hal_get_bool(samp->enable)) { - hal_set_si32(samp->curr_depth, hal_stream_depth(&samp->fifo)); + hal_set_sint(samp->curr_depth, hal_stream_depth(&samp->fifo)); hal_set_bool(samp->full, !hal_stream_writable(&samp->fifo)); return; } @@ -178,12 +178,12 @@ static void sample(void *arg, long period) if ( hal_stream_write(&samp->fifo, data) < 0) { /* fifo is full, data is lost */ /* log the overrun */ - hal_set_si32(samp->overruns, hal_get_si32(samp->overruns) + 1); + hal_set_sint(samp->overruns, hal_get_sint(samp->overruns) + 1); hal_set_bool(samp->full, 1); - hal_set_si32(samp->curr_depth, hal_stream_maxdepth(&samp->fifo)); + hal_set_sint(samp->curr_depth, hal_stream_maxdepth(&samp->fifo)); } else { hal_set_bool(samp->full, 0); - hal_set_si32(samp->curr_depth, hal_stream_depth(&samp->fifo)); + hal_set_sint(samp->curr_depth, hal_stream_depth(&samp->fifo)); } } @@ -207,17 +207,17 @@ static int init_sampler(int num, sampler_t *str) rtapi_print_msg(RTAPI_MSG_ERR, "SAMPLER: ERROR: 'enable' pin export failed\n"); return -EIO; } - retval = hal_pin_new_si32(comp_id, HAL_OUT, &str->curr_depth, 0, "%s%d.curr-depth", strbase, num); + retval = hal_pin_new_sint(comp_id, HAL_OUT, &str->curr_depth, 0, "%s%d.curr-depth", strbase, num); if (retval != 0 ) { rtapi_print_msg(RTAPI_MSG_ERR, "SAMPLER: ERROR: 'curr_depth' pin export failed\n"); return -EIO; } - retval = hal_pin_new_si32(comp_id, HAL_IO, &str->overruns, 0, "%s%d.overruns", strbase, num); + retval = hal_pin_new_sint(comp_id, HAL_IO, &str->overruns, 0, "%s%d.overruns", strbase, num); if (retval != 0 ) { rtapi_print_msg(RTAPI_MSG_ERR, "SAMPLER: ERROR: 'overruns' parameter export failed\n"); return -EIO; } - retval = hal_pin_new_si32(comp_id, HAL_IO, &str->sample_num, 0, "%s%d.sample-num", strbase, num); + retval = hal_pin_new_sint(comp_id, HAL_IO, &str->sample_num, 0, "%s%d.sample-num", strbase, num); if (retval != 0 ) { rtapi_print_msg(RTAPI_MSG_ERR, "SAMPLER: ERROR: 'sample-num' parameter export failed\n"); return -EIO; diff --git a/src/hal/components/sim_encoder.c b/src/hal/components/sim_encoder.c index 1e02030b178..fc9802b9c13 100644 --- a/src/hal/components/sim_encoder.c +++ b/src/hal/components/sim_encoder.c @@ -257,7 +257,7 @@ static void make_pulses(void *arg, long period) /* get direction bit, 1 if negative, 0 if positive */ dir = sim_enc->addval >> 31; if ( dir ) { - hal_set_si32(sim_enc->rawcounts, hal_get_si32(sim_enc->rawcounts) - 1); + hal_set_sint(sim_enc->rawcounts, hal_get_sint(sim_enc->rawcounts) - 1); /* negative rotation, decrement state, detect underflow */ if (--(sim_enc->state) < 0) { /* state underflow, roll over */ @@ -265,19 +265,19 @@ static void make_pulses(void *arg, long period) /* decrement cycle, detect underflow */ if (--(sim_enc->cycle) < 0) { /* cycle underflow, roll over */ - sim_enc->cycle += hal_get_ui32(sim_enc->ppr); + sim_enc->cycle += hal_get_uint(sim_enc->ppr); } } } else { - hal_set_si32(sim_enc->rawcounts, hal_get_si32(sim_enc->rawcounts) + 1); + hal_set_sint(sim_enc->rawcounts, hal_get_sint(sim_enc->rawcounts) + 1); /* positive rotation, increment state, detect overflow */ if (++(sim_enc->state) > 3) { /* state overflow, roll over */ sim_enc->state = 0; /* increment cycle, detect overflow */ - if (++(sim_enc->cycle) >= hal_get_ui32(sim_enc->ppr)) { + if (++(sim_enc->cycle) >= (long)hal_get_uint(sim_enc->ppr)) { /* cycle overflow, roll over */ - sim_enc->cycle -= hal_get_ui32(sim_enc->ppr); + sim_enc->cycle -= hal_get_uint(sim_enc->ppr); } } } @@ -348,7 +348,7 @@ static void update_speed(void *arg, long period) /* convert speed command (user units) to revs/sec */ rev_sec = hal_get_real(sim_enc->speed) * sim_enc->scale_mult; /* convert speed command (revs per sec) to counts/sec */ - freq = rev_sec * (hal_get_ui32(sim_enc->ppr)) * 4.0; + freq = rev_sec * (hal_get_uint(sim_enc->ppr)) * 4.0; /* limit the commanded frequency */ if (freq > maxf) { freq = maxf; @@ -377,7 +377,7 @@ static int export_sim_enc(sim_enc_t * addr, char *prefix) msg = rtapi_get_msg_level(); rtapi_set_msg_level(RTAPI_MSG_WARN); /* export param variable for pulses per rev */ - retval = hal_pin_new_ui32(comp_id, HAL_IO, &(addr->ppr), 100, + retval = hal_pin_new_uint(comp_id, HAL_IO, &(addr->ppr), 100, "%s.ppr", prefix); if (retval != 0) { return retval; @@ -411,7 +411,7 @@ static int export_sim_enc(sim_enc_t * addr, char *prefix) return retval; } /* export pin for rawcounts */ - retval = hal_pin_new_si32(comp_id, HAL_IN, &(addr->rawcounts), 0, + retval = hal_pin_new_sint(comp_id, HAL_IN, &(addr->rawcounts), 0, "%s.rawcounts", prefix); if (retval != 0) { return retval; diff --git a/src/hal/components/streamer.c b/src/hal/components/streamer.c index 12b2d363abf..73749257542 100644 --- a/src/hal/components/streamer.c +++ b/src/hal/components/streamer.c @@ -176,7 +176,7 @@ static void update(void *arg, long period) /* are we enabled? - generate doclock if enabled and right mode */ if (hal_get_bool(str->enable)) { doclk = 1; - switch (hal_get_si32(str->clock_mode)) { + switch (hal_get_sint(str->clock_mode)) { /* clock-mode 0 means do clock if enabled */ case 0: break; @@ -204,19 +204,19 @@ static void update(void *arg, long period) } /* point at user/RT fifo in other shmem */ int depth = hal_stream_depth(&str->fifo); - hal_set_si32(str->curr_depth, depth); + hal_set_sint(str->curr_depth, depth); hal_set_bool(str->empty, depth == 0); if(!doclk) return; /* done - output pins retain current values */ if(depth == 0) { /* increase underrun only for valid clock*/ - hal_set_si32(str->underruns, hal_get_si32(str->underruns) + 1); + hal_set_sint(str->underruns, hal_get_sint(str->underruns) + 1); return; } union hal_stream_data data[HAL_STREAM_MAX_PINS]; if(hal_stream_read(&str->fifo, data, NULL) < 0) { /* should not happen (single reader invariant) */ - hal_set_si32(str->underruns, hal_get_si32(str->underruns) + 1); + hal_set_sint(str->underruns, hal_get_sint(str->underruns) + 1); return; } int num_pins = hal_stream_element_count(&str->fifo); @@ -248,12 +248,12 @@ static int init_streamer(int num, streamer_t *str) rtapi_print_msg(RTAPI_MSG_ERR, "STREAMER: ERROR: 'enable' pin export failed\n"); return -EIO; } - retval = hal_pin_new_si32(comp_id, HAL_OUT, &str->curr_depth, 0, "%s%d.curr-depth", strbase, num); + retval = hal_pin_new_sint(comp_id, HAL_OUT, &str->curr_depth, 0, "%s%d.curr-depth", strbase, num); if (retval != 0 ) { rtapi_print_msg(RTAPI_MSG_ERR, "STREAMER: ERROR: 'curr_depth' pin export failed\n"); return -EIO; } - retval = hal_pin_new_si32(comp_id, HAL_IO, &str->underruns, 0, "%s%d.underruns", strbase, num); + retval = hal_pin_new_sint(comp_id, HAL_IO, &str->underruns, 0, "%s%d.underruns", strbase, num); if (retval != 0 ) { rtapi_print_msg(RTAPI_MSG_ERR, "STREAMER: ERROR: 'underruns' pin export failed\n"); return -EIO; @@ -263,7 +263,7 @@ static int init_streamer(int num, streamer_t *str) rtapi_print_msg(RTAPI_MSG_ERR, "STREAMER: ERROR: 'clock' pin export failed\n"); return -EIO; } - retval = hal_pin_new_si32(comp_id, HAL_IN, &str->clock_mode, 0, "%s%d.clock-mode", strbase, num); + retval = hal_pin_new_sint(comp_id, HAL_IN, &str->clock_mode, 0, "%s%d.clock-mode", strbase, num); if (retval != 0 ) { rtapi_print_msg(RTAPI_MSG_ERR, "STREAMER: ERROR: 'clock_mode' pin export failed\n"); return -EIO; diff --git a/src/hal/components/userkins.comp b/src/hal/components/userkins.comp index 0df38910f5a..a9cdd374bac 100644 --- a/src/hal/components/userkins.comp +++ b/src/hal/components/userkins.comp @@ -107,8 +107,8 @@ EXTRA_SETUP() { if (!haldata) goto error; // hal pin examples: - res += hal_pin_new_ui32(comp_id, HAL_IN , &(haldata->in) , 0, "%s.in" , HAL_PREFIX); - res += hal_pin_new_ui32(comp_id, HAL_OUT, &(haldata->out), 0, "%s.out", HAL_PREFIX); + res += hal_pin_new_uint(comp_id, HAL_IN , &(haldata->in) , 0, "%s.in" , HAL_PREFIX); + res += hal_pin_new_uint(comp_id, HAL_OUT, &(haldata->out), 0, "%s.out", HAL_PREFIX); // hal parameter examples: res += hal_param_new_real(comp_id, HAL_RW, &haldata->param_rw, 0.0, "%s.param-rw", HAL_PREFIX); @@ -160,7 +160,7 @@ int kinematicsForward(const double *j, pos->v = 0; pos->w = 0; - if (hal_get_ui32(haldata->in) && !is_ready && !gave_msg) { + if (hal_get_uint(haldata->in) && !is_ready && !gave_msg) { rtapi_print_msg(RTAPI_MSG_ERR, "%s The 'in' pin not echoed until Inverse called\n", __FILE__); @@ -190,8 +190,8 @@ int kinematicsInverse(const EmcPose * pos, j[2] = pos->tran.z; // joint 2 //example hal pin update (homing reqd before kinematicsInverse) - hal_set_ui32(haldata->out, hal_get_ui32(haldata->in)); //dereference - //read from param example: hal_set_ui32(haldata->out, hal_get_real(haldata->param_rw)); + hal_set_uint(haldata->out, hal_get_uint(haldata->in)); //dereference + //read from param example: hal_set_uint(haldata->out, hal_get_real(haldata->param_rw)); return 0; } // kinematicsInverse() diff --git a/src/hal/drivers/hal_gm.c b/src/hal/drivers/hal_gm.c index 0e7b02ccffb..4b7c4133ee2 100644 --- a/src/hal/drivers/hal_gm.c +++ b/src/hal/drivers/hal_gm.c @@ -256,9 +256,9 @@ typedef struct { //stepgen_t hal_real_t position_scale; //Saved Parameters - rtapi_u32 curr_steplen; - rtapi_u32 curr_stepspace; - rtapi_u32 curr_dirdelay; + rtapi_uint curr_steplen; + rtapi_uint curr_stepspace; + rtapi_uint curr_dirdelay; rtapi_real curr_maxaccel; rtapi_real curr_maxvel; rtapi_real curr_position_scale; @@ -695,10 +695,10 @@ ExportStepgen(void *arg, int comp_id, int version) //Export Parameters. if(error == 0) error = hal_param_new_bool(comp_id, HAL_RW, &(device->stepgen[i].control_type), 0, "gm.%1d.stepgen.%1d.control-type", boardId, i); //0: position, 1: velocity - if(error == 0) error = hal_param_new_ui32(comp_id, HAL_RW, &(device->stepgen[i].step_type), 0, "gm.%1d.stepgen.%1d.step-type", boardId, i); //0: StepDir, 1: UpDown, 2: Quadrature - if(error == 0) error = hal_param_new_ui32(comp_id, HAL_RW, &(device->stepgen[i].steplen), 0, "gm.%1d.stepgen.%1d.steplen", boardId, i); - if(error == 0) error = hal_param_new_ui32(comp_id, HAL_RW, &(device->stepgen[i].stepspace), 0, "gm.%1d.stepgen.%1d.stepspace", boardId, i); - if(error == 0) error = hal_param_new_ui32(comp_id, HAL_RW, &(device->stepgen[i].dirdelay), 0, "gm.%1d.stepgen.%1d.dirdelay", boardId, i); + if(error == 0) error = hal_param_new_uint(comp_id, HAL_RW, &(device->stepgen[i].step_type), 0, "gm.%1d.stepgen.%1d.step-type", boardId, i); //0: StepDir, 1: UpDown, 2: Quadrature + if(error == 0) error = hal_param_new_uint(comp_id, HAL_RW, &(device->stepgen[i].steplen), 0, "gm.%1d.stepgen.%1d.steplen", boardId, i); + if(error == 0) error = hal_param_new_uint(comp_id, HAL_RW, &(device->stepgen[i].stepspace), 0, "gm.%1d.stepgen.%1d.stepspace", boardId, i); + if(error == 0) error = hal_param_new_uint(comp_id, HAL_RW, &(device->stepgen[i].dirdelay), 0, "gm.%1d.stepgen.%1d.dirdelay", boardId, i); if(error == 0) error = hal_param_new_real(comp_id, HAL_RW, &(device->stepgen[i].maxaccel), 0.0, "gm.%1d.stepgen.%1d.maxaccel", boardId, i); if(error == 0) error = hal_param_new_real(comp_id, HAL_RW, &(device->stepgen[i].maxvel), 0.0, "gm.%1d.stepgen.%1d.maxvel", boardId, i); if(error == 0) error = hal_param_new_bool(comp_id, HAL_RW, &(device->stepgen[i].polarity_A), 0, "gm.%1d.stepgen.%1d.invert-step1", boardId, i); @@ -1039,7 +1039,7 @@ ExportMixed(void *arg, int comp_id) //Watchdog pins and parameters if(error == 0) error = hal_param_new_bool(comp_id, HAL_RW, &(device->cardMgr.watchdog_enable), 0, "gm.%1d.watchdog-enable", boardId); - if(error == 0) error = hal_param_new_ui32(comp_id, HAL_RW, &(device->cardMgr.watchdog_timeout_ns), 0, "gm.%1d.watchdog-timeout-ns", boardId); + if(error == 0) error = hal_param_new_uint(comp_id, HAL_RW, &(device->cardMgr.watchdog_timeout_ns), 0, "gm.%1d.watchdog-timeout-ns", boardId); if(error == 0) error = hal_pin_new_bool(comp_id, HAL_OUT, &(device->cardMgr.watchdog_expired), 0, "gm.%1d.watchdog-expired", boardId); //Export pins and parameters for parallel IOs @@ -1408,8 +1408,8 @@ card_mgr(void *arg, long period) if(hal_get_bool(device->cardMgr.watchdog_enable)) //watchdog timeout in ns*256 unit. 0 if watchdog is disabled { - if(hal_get_ui32(device->cardMgr.watchdog_timeout_ns) < 256) temp |= 0x100; - else temp |= (hal_get_ui32(device->cardMgr.watchdog_timeout_ns) & 0xFFFFFF00); + if(hal_get_uint(device->cardMgr.watchdog_timeout_ns) < 256) temp |= 0x100; + else temp |= (hal_get_uint(device->cardMgr.watchdog_timeout_ns) & 0xFFFFFF00); } if(temp != device->cardMgr.card_control_reg) @@ -1598,10 +1598,10 @@ stepgenCheckParameters(void *arg, long period, unsigned int channel) } //If steplen, stepspace, position_scale or max_vel changed : update max_vel - if((hal_get_ui32(device->stepgen[channel].steplen) != device->stepgen[channel].curr_steplen) || (hal_get_ui32(device->stepgen[channel].stepspace) != device->stepgen[channel].curr_stepspace) || + if((hal_get_uint(device->stepgen[channel].steplen) != device->stepgen[channel].curr_steplen) || (hal_get_uint(device->stepgen[channel].stepspace) != device->stepgen[channel].curr_stepspace) || (hal_get_real(device->stepgen[channel].maxvel) != device->stepgen[channel].curr_maxvel) || (device->stepgen[channel].curr_position_scale != hal_get_real(device->stepgen[channel].position_scale))) { - min_period = (hal_get_ui32(device->stepgen[channel].steplen) + hal_get_ui32(device->stepgen[channel].stepspace)) * 0.000000001; + min_period = (hal_get_uint(device->stepgen[channel].steplen) + hal_get_uint(device->stepgen[channel].stepspace)) * 0.000000001; max_vel = 1.0/((rtapi_real)min_period * fabs(hal_get_real(device->stepgen[channel].position_scale))); if(hal_get_real(device->stepgen[channel].maxvel) <= 0) @@ -1619,13 +1619,13 @@ stepgenCheckParameters(void *arg, long period, unsigned int channel) } //If steplen or dirdelay changed : update FPGA time parameter regs - if((hal_get_ui32(device->stepgen[channel].steplen) != device->stepgen[channel].curr_steplen) || (hal_get_ui32(device->stepgen[channel].dirdelay) != device->stepgen[channel].curr_dirdelay)) + if((hal_get_uint(device->stepgen[channel].steplen) != device->stepgen[channel].curr_steplen) || (hal_get_uint(device->stepgen[channel].dirdelay) != device->stepgen[channel].curr_dirdelay)) { //Init time constants, send them to PCI - temp1= (hal_get_ui32(device->stepgen[channel].steplen) <= 1900000) ? (hal_get_ui32(device->stepgen[channel].steplen)/30) : 63333; - temp2= (hal_get_ui32(device->stepgen[channel].dirdelay) <= 1900000) ? (hal_get_ui32(device->stepgen[channel].dirdelay)/30) : 63333; + temp1= (hal_get_uint(device->stepgen[channel].steplen) <= 1900000) ? (hal_get_uint(device->stepgen[channel].steplen)/30) : 63333; + temp2= (hal_get_uint(device->stepgen[channel].dirdelay) <= 1900000) ? (hal_get_uint(device->stepgen[channel].dirdelay)/30) : 63333; - if((hal_get_ui32(device->stepgen[channel].steplen) > 1900000) || (hal_get_ui32(device->stepgen[channel].dirdelay) > 1900000)) + if((hal_get_uint(device->stepgen[channel].steplen) > 1900000) || (hal_get_uint(device->stepgen[channel].dirdelay) > 1900000)) { rtapi_print_msg(RTAPI_MSG_ERR, "GM: stepgen: 'steplen' and 'dirdelay' must be lower than 1 900 000 ns.\n"); } @@ -1635,9 +1635,9 @@ stepgenCheckParameters(void *arg, long period, unsigned int channel) //If enable, step_type or polarity bits changed : update fpga status reg if (hal_get_bool(device->stepgen[channel].enable)) device->stepgen_status |= (0x1 << channel); //Bit 0-5 is the enable bit else device->stepgen_status &= ~(0x1 << channel); - if (hal_get_ui32(device->stepgen[channel].step_type) == 1) device->stepgen_status |= (0x1 << (channel + 6)); //Bits 6-17 are the step_mode bits + if (hal_get_uint(device->stepgen[channel].step_type) == 1) device->stepgen_status |= (0x1 << (channel + 6)); //Bits 6-17 are the step_mode bits else device->stepgen_status &= ~(0x1 << (channel + 6)); - if (hal_get_ui32(device->stepgen[channel].step_type) == 2) device->stepgen_status |= (0x1 << (channel + 12)); + if (hal_get_uint(device->stepgen[channel].step_type) == 2) device->stepgen_status |= (0x1 << (channel + 12)); else device->stepgen_status &= ~(0x1 << (channel + 12)); if (hal_get_bool(device->stepgen[channel].polarity_A)) device->stepgen_status |= (0x1 << (channel + 18)); //18-23. bit is polarity of channel A else device->stepgen_status &= ~(0x1 << (channel + 18)); @@ -1665,11 +1665,11 @@ stepgenCheckParameters(void *arg, long period, unsigned int channel) //Update current values device->period_ns = period; device->stepgen[channel].curr_position_scale = hal_get_real(device->stepgen[channel].position_scale); - device->stepgen[channel].curr_stepspace = hal_get_ui32(device->stepgen[channel].stepspace); + device->stepgen[channel].curr_stepspace = hal_get_uint(device->stepgen[channel].stepspace); device->stepgen[channel].curr_maxvel = hal_get_real(device->stepgen[channel].maxvel); device->stepgen[channel].curr_maxaccel = hal_get_real(device->stepgen[channel].maxaccel); - device->stepgen[channel].curr_steplen = hal_get_ui32(device->stepgen[channel].steplen); - device->stepgen[channel].curr_dirdelay= hal_get_ui32(device->stepgen[channel].dirdelay); + device->stepgen[channel].curr_steplen = hal_get_uint(device->stepgen[channel].steplen); + device->stepgen[channel].curr_dirdelay= hal_get_uint(device->stepgen[channel].dirdelay); } diff --git a/src/hal/drivers/hal_ppmc.c b/src/hal/drivers/hal_ppmc.c index 3d3e9981ade..83e65900f2e 100644 --- a/src/hal/drivers/hal_ppmc.c +++ b/src/hal/drivers/hal_ppmc.c @@ -1244,14 +1244,12 @@ static void write_encoders(slot_data_t *slot) value in 10MHz clock pulses. */ static unsigned int ns2cp( hal_uint_t pns, unsigned int min_ns ) { - unsigned ns, cp; - - ns = hal_get_ui32(pns); + rtapi_uint ns = hal_get_uint(pns); if ( ns < min_ns ) ns = min_ns; if ( ns > 25400 ) ns = 25400; - cp = ns / 100; + unsigned cp = ns / 100; ns = cp * 100; - hal_set_ui32(pns, ns); + hal_set_uint(pns, ns); return cp; } @@ -1903,19 +1901,19 @@ static int export_USC_stepgen(slot_data_t *slot, bus_data_t *bus) } /* export params that apply to all four stepgens */ /* 10uS default setup time */ - retval = hal_param_new_ui32(comp_id, HAL_RW, &(slot->stepgen->setup_time_ns), 10000, + retval = hal_param_new_uint(comp_id, HAL_RW, &(slot->stepgen->setup_time_ns), 10000, "ppmc.%d.stepgen.%02d-%02d.setup-time-ns", bus->busnum, bus->last_stepgen, bus->last_stepgen+3); if (retval != 0) { return retval; } /* 4uS default pulse width */ - retval = hal_param_new_ui32(comp_id, HAL_RW, &(slot->stepgen->pulse_width_ns), 4000, + retval = hal_param_new_uint(comp_id, HAL_RW, &(slot->stepgen->pulse_width_ns), 4000, "ppmc.%d.stepgen.%02d-%02d.pulse-width-ns", bus->busnum, bus->last_stepgen, bus->last_stepgen+3); if (retval != 0) { return retval; } /* 4uS default pulse spacing */ - retval = hal_param_new_ui32(comp_id, HAL_RW, &(slot->stepgen->pulse_space_ns), 4000, + retval = hal_param_new_uint(comp_id, HAL_RW, &(slot->stepgen->pulse_space_ns), 4000, "ppmc.%d.stepgen.%02d-%02d.pulse-space-min-ns", bus->busnum, bus->last_stepgen, bus->last_stepgen+3); if (retval != 0) { return retval; diff --git a/src/hal/drivers/mesa-hostmot2/hm2_modbus.c b/src/hal/drivers/mesa-hostmot2/hm2_modbus.c index 01b982cc5e9..fd4a8e64970 100644 --- a/src/hal/drivers/mesa-hostmot2/hm2_modbus.c +++ b/src/hal/drivers/mesa-hostmot2/hm2_modbus.c @@ -371,7 +371,7 @@ static void setup_icdelay(hm2_modbus_inst_t *inst, unsigned baudrate, unsigned p } else { inst->maxicharbits = 0; } - hal_set_ui32(inst->hal->icdelay, inst->maxicharbits); + hal_set_uint(inst->hal->icdelay, inst->maxicharbits); } // @@ -440,12 +440,12 @@ static int send_comms_change(hm2_modbus_inst_t *inst) inst->cfg_tx.drivedelay = cc->cmd.idrvdelay ? cc->cmd.idrvdelay : 1; // Expose to HAL - hal_set_ui32(inst->hal->baudrate, baudrate); - hal_set_ui32(inst->hal->parity, parity); - hal_set_ui32(inst->hal->stopbits, stopbits); - hal_set_ui32(inst->hal->rxdelay, inst->cfg_rx.ifdelay); - hal_set_ui32(inst->hal->txdelay, inst->cfg_tx.ifdelay); - hal_set_ui32(inst->hal->drvdelay, inst->cfg_tx.drivedelay); + hal_set_uint(inst->hal->baudrate, baudrate); + hal_set_uint(inst->hal->parity, parity); + hal_set_uint(inst->hal->stopbits, stopbits); + hal_set_uint(inst->hal->rxdelay, inst->cfg_rx.ifdelay); + hal_set_uint(inst->hal->txdelay, inst->cfg_tx.ifdelay); + hal_set_uint(inst->hal->drvdelay, inst->cfg_tx.drivedelay); // Redo the inter-character delay settings setup_icdelay(inst, baudrate, parity, stopbits, cc->cmd.iicdelay); @@ -461,17 +461,17 @@ static void set_error(hm2_modbus_inst_t *inst, int errcode) if(handling_inits(inst)) { // No individual pins for init commands, use global hal_set_bool(inst->hal->fault, 1); - hal_set_ui32(inst->hal->faultcmd, inst->cmdidx); - hal_set_ui32(inst->hal->lasterror, errcode); + hal_set_uint(inst->hal->faultcmd, inst->cmdidx); + hal_set_uint(inst->hal->lasterror, errcode); return; } hm2_modbus_cmd_t *cc = current_cmd(inst); if(++cc->errors >= MAX_ERRORS || cc->disabled) { cc->disabled = 1; hal_set_bool(inst->hal->cmds[inst->cmdidx].disabled, 1); - hal_set_ui32(inst->hal->cmds[inst->cmdidx].errorcode, errcode); + hal_set_uint(inst->hal->cmds[inst->cmdidx].errorcode, errcode); } - hal_set_ui32(inst->hal->cmds[inst->cmdidx].error, cc->errors); + hal_set_uint(inst->hal->cmds[inst->cmdidx].error, cc->errors); } // @@ -619,8 +619,8 @@ static inline int next_command(hm2_modbus_inst_t *inst) inst->cmds[i].disabled = 0; inst->cmds[i].errors = 0; hal_set_bool(inst->hal->cmds[i].disabled, 0); - hal_set_ui32(inst->hal->cmds[i].error, 0); - hal_set_ui32(inst->hal->cmds[i].errorcode, 0); + hal_set_uint(inst->hal->cmds[i].error, 0); + hal_set_uint(inst->hal->cmds[i].errorcode, 0); // Honor the writeflush flag when coming out of disable. write_flush_cmd(inst, i); } @@ -635,8 +635,8 @@ static inline int next_command(hm2_modbus_inst_t *inst) inst->cmds[i].disabled = 1; inst->cmds[i].errors = 0; hal_set_bool(inst->hal->cmds[i].disabled, 1); - hal_set_ui32(inst->hal->cmds[i].error, 0); - hal_set_ui32(inst->hal->cmds[i].errorcode, EAGAIN); + hal_set_uint(inst->hal->cmds[i].error, 0); + hal_set_uint(inst->hal->cmds[i].errorcode, EAGAIN); } } } while(inst->cmdidx < inst->ncmds && inst->cmds[inst->cmdidx].disabled); @@ -721,9 +721,9 @@ static void do_timeout(hm2_modbus_inst_t *inst) MSG_DBG("Timeout reset cmd=%u %s(%d)\n", inst->cmdidx, state_names[inst->state], inst->state); force_resend(inst); queue_reset(inst); - hal_set_ui32(inst->hal->lasterror, ETIMEDOUT); + hal_set_uint(inst->hal->lasterror, ETIMEDOUT); hal_set_bool(inst->hal->fault, 1); - hal_set_ui32(inst->hal->faultcmd, inst->cmdidx); + hal_set_uint(inst->hal->faultcmd, inst->cmdidx); set_error(inst, ETIMEDOUT); set_state(inst, STATE_START); } @@ -782,8 +782,8 @@ static void process(void *arg, long period) hal_set_bool(inst->hal->cmds[i].disabled, 0); write_flush_cmd(inst, i); } - hal_set_ui32(inst->hal->cmds[i].errorcode, 0); - hal_set_ui32(inst->hal->cmds[i].error, 0); + hal_set_uint(inst->hal->cmds[i].errorcode, 0); + hal_set_uint(inst->hal->cmds[i].error, 0); inst->cmds[i].errors = 0; } } @@ -864,9 +864,9 @@ static void process(void *arg, long period) // If the next command is again the first, then we have no // messages we can send. if(next_command(inst)) { - hal_set_ui32(inst->hal->lasterror, ENODATA); + hal_set_uint(inst->hal->lasterror, ENODATA); hal_set_bool(inst->hal->fault, 1); - hal_set_ui32(inst->hal->faultcmd, 0); + hal_set_uint(inst->hal->faultcmd, 0); break; } } @@ -1098,8 +1098,8 @@ static void process(void *arg, long period) default: MSG_ERR("%s: error: Unknown state (%d) in process(), setting START state\n", inst->name, inst->state); hal_set_bool(inst->hal->fault, 1); - hal_set_ui32(inst->hal->lasterror, EINVAL); - hal_set_ui32(inst->hal->faultcmd, inst->cmdidx); + hal_set_uint(inst->hal->lasterror, EINVAL); + hal_set_uint(inst->hal->faultcmd, inst->cmdidx); set_state(inst, STATE_START); break; } @@ -2698,21 +2698,21 @@ int rtapi_app_main(void) goto errout; \ } \ } while(0) - CHECK(hal_param_new_ui32(comp_id, HAL_RO, &(inst->hal->baudrate), 0, "%s.baudrate", inst->name)); - CHECK(hal_param_new_ui32(comp_id, HAL_RO, &(inst->hal->parity), 0, "%s.parity", inst->name)); - CHECK(hal_param_new_ui32(comp_id, HAL_RO, &(inst->hal->stopbits), 0, "%s.stopbits", inst->name)); - CHECK(hal_param_new_ui32(comp_id, HAL_RO, &(inst->hal->icdelay), 0, "%s.icdelay", inst->name)); - CHECK(hal_param_new_ui32(comp_id, HAL_RO, &(inst->hal->txdelay), 0, "%s.txdelay", inst->name)); - CHECK(hal_param_new_ui32(comp_id, HAL_RO, &(inst->hal->rxdelay), 0, "%s.rxdelay", inst->name)); - CHECK(hal_param_new_ui32(comp_id, HAL_RO, &(inst->hal->drvdelay), 0, "%s.drivedelay", inst->name)); + CHECK(hal_param_new_uint(comp_id, HAL_RO, &(inst->hal->baudrate), 0, "%s.baudrate", inst->name)); + CHECK(hal_param_new_uint(comp_id, HAL_RO, &(inst->hal->parity), 0, "%s.parity", inst->name)); + CHECK(hal_param_new_uint(comp_id, HAL_RO, &(inst->hal->stopbits), 0, "%s.stopbits", inst->name)); + CHECK(hal_param_new_uint(comp_id, HAL_RO, &(inst->hal->icdelay), 0, "%s.icdelay", inst->name)); + CHECK(hal_param_new_uint(comp_id, HAL_RO, &(inst->hal->txdelay), 0, "%s.txdelay", inst->name)); + CHECK(hal_param_new_uint(comp_id, HAL_RO, &(inst->hal->rxdelay), 0, "%s.rxdelay", inst->name)); + CHECK(hal_param_new_uint(comp_id, HAL_RO, &(inst->hal->drvdelay), 0, "%s.drivedelay", inst->name)); CHECK(hal_pin_new_bool(comp_id, HAL_IN, &(inst->hal->suspend), 0, "%s.suspend", inst->name)); CHECK(hal_pin_new_bool(comp_id, HAL_IN, &(inst->hal->reset), 0, "%s.reset", inst->name)); CHECK(hal_pin_new_bool(comp_id, HAL_OUT, &(inst->hal->fault), 0, "%s.fault", inst->name)); - CHECK(hal_pin_new_ui32(comp_id, HAL_OUT, &(inst->hal->faultcmd), 0, "%s.fault-command", inst->name)); - CHECK(hal_pin_new_ui32(comp_id, HAL_OUT, &(inst->hal->lasterror), 0, "%s.last-error-code", inst->name)); + CHECK(hal_pin_new_uint(comp_id, HAL_OUT, &(inst->hal->faultcmd), 0, "%s.fault-command", inst->name)); + CHECK(hal_pin_new_uint(comp_id, HAL_OUT, &(inst->hal->lasterror), 0, "%s.last-error-code", inst->name)); - hal_set_ui32(inst->hal->baudrate, inst->cfg_rx.baudrate = inst->cfg_tx.baudrate = inst->mbccb->baudrate); + hal_set_uint(inst->hal->baudrate, inst->cfg_rx.baudrate = inst->cfg_tx.baudrate = inst->mbccb->baudrate); unsigned parity = 0; if(inst->mbccb->format & MBCCB_FORMAT_PARITYEN) { inst->cfg_rx.flags |= HM2_PKTUART_CONFIG_PARITYEN; @@ -2730,22 +2730,22 @@ int rtapi_app_main(void) inst->cfg_tx.flags |= HM2_PKTUART_CONFIG_STOPBITS2; stopbits = 2; } - hal_set_ui32(inst->hal->parity, parity); - hal_set_ui32(inst->hal->stopbits, stopbits); + hal_set_uint(inst->hal->parity, parity); + hal_set_uint(inst->hal->stopbits, stopbits); if(!inst->mbccb->rxdelay) // Auto - inst->cfg_rx.ifdelay = hal_set_ui32(inst->hal->rxdelay, calc_ifdelay(inst, inst->mbccb->baudrate, parity, stopbits) - 1); + inst->cfg_rx.ifdelay = hal_set_uint(inst->hal->rxdelay, calc_ifdelay(inst, inst->mbccb->baudrate, parity, stopbits) - 1); else // Manual - inst->cfg_rx.ifdelay = hal_set_ui32(inst->hal->rxdelay, inst->mbccb->rxdelay); + inst->cfg_rx.ifdelay = hal_set_uint(inst->hal->rxdelay, inst->mbccb->rxdelay); if(!inst->mbccb->txdelay) // Auto - inst->cfg_tx.ifdelay = hal_set_ui32(inst->hal->txdelay, calc_ifdelay(inst, inst->mbccb->baudrate, parity, stopbits) + 1); + inst->cfg_tx.ifdelay = hal_set_uint(inst->hal->txdelay, calc_ifdelay(inst, inst->mbccb->baudrate, parity, stopbits) + 1); else // Manual - inst->cfg_tx.ifdelay = hal_set_ui32(inst->hal->txdelay, inst->mbccb->txdelay); + inst->cfg_tx.ifdelay = hal_set_uint(inst->hal->txdelay, inst->mbccb->txdelay); if(!inst->mbccb->drvdelay) // Auto - inst->cfg_tx.drivedelay = hal_set_ui32(inst->hal->drvdelay, 1); + inst->cfg_tx.drivedelay = hal_set_uint(inst->hal->drvdelay, 1); else // Manual - inst->cfg_tx.drivedelay = hal_set_ui32(inst->hal->drvdelay, inst->mbccb->drvdelay); + inst->cfg_tx.drivedelay = hal_set_uint(inst->hal->drvdelay, inst->mbccb->drvdelay); inst->cfg_rx.filterrate = 0; // Zero means 2 times baudrate inst->cfg_rx.flags |= HM2_PKTUART_CONFIG_RXEN; @@ -2833,9 +2833,9 @@ int rtapi_app_main(void) 0, "%s.command.%02d.disable", inst->name, c)); CHECK(hal_pin_new_bool(comp_id, HAL_OUT, &(inst->hal->cmds[c].disabled), 0, "%s.command.%02d.disabled", inst->name, c)); - CHECK(hal_pin_new_ui32(comp_id, HAL_OUT, &(inst->hal->cmds[c].error), + CHECK(hal_pin_new_uint(comp_id, HAL_OUT, &(inst->hal->cmds[c].error), 0, "%s.command.%02d.errors", inst->name, c)); - CHECK(hal_pin_new_ui32(comp_id, HAL_OUT, &(inst->hal->cmds[c].errorcode), + CHECK(hal_pin_new_uint(comp_id, HAL_OUT, &(inst->hal->cmds[c].errorcode), 0, "%s.command.%02d.error-code", inst->name, c)); CHECK(hal_pin_new_bool(comp_id, HAL_IN, &(inst->hal->cmds[c].reset), 0, "%s.command.%02d.reset", inst->name, c)); @@ -2846,7 +2846,7 @@ int rtapi_app_main(void) if(hasdisabled(cc)) { cc->disabled = 1; hal_set_bool(inst->hal->cmds[c].disabled, 1); - hal_set_ui32(inst->hal->cmds[c].errorcode, EAGAIN); + hal_set_uint(inst->hal->cmds[c].errorcode, EAGAIN); } // Now create the pins associated with the command diff --git a/src/hal/utils/halcmd_commands.cc b/src/hal/utils/halcmd_commands.cc index 4132335a775..679c1605204 100644 --- a/src/hal/utils/halcmd_commands.cc +++ b/src/hal/utils/halcmd_commands.cc @@ -1767,8 +1767,8 @@ static void print_thread_info_print(const hal_query_t *q, const char **patterns) q->thread.period, "YES", // Always uses FP q->name, - (long)hal_get_si32(qt.pp.ref.s), - (long)hal_get_si32(qm.pp.ref.s)); + hal_get_sint(qt.pp.ref.s), + hal_get_sint(qm.pp.ref.s)); } else { rtapi_print_msg(RTAPI_MSG_ERR, "unexpected: cannot find time/tmax pin for %s thread\n", q->name); } diff --git a/src/hal/utils/halcompile.g b/src/hal/utils/halcompile.g index 6bd2afab225..1481b16ae02 100644 --- a/src/hal/utils/halcompile.g +++ b/src/hal/utils/halcompile.g @@ -41,6 +41,7 @@ parser Hal: rule Declaration: "pin" PINDIRECTION TYPE HALNAME OptArray OptSAssign OptPersonality OptString ";" {{ pin(HALNAME, TYPE, OptArray, PINDIRECTION, OptString, OptSAssign, OptPersonality) }} | "param" PARAMDIRECTION TYPE HALNAME OptArray OptSAssign OptPersonality OptString ";" {{ param(HALNAME, TYPE, OptArray, PARAMDIRECTION, OptString, OptSAssign, OptPersonality) }} + | "alias" HALNAME OptArray {{ ppname = HALNAME; pparr = OptArray }} HALNAME OptArray ";" {{ alias(ppname, pparr, HALNAME, OptArray) }} | "function" NAME OptFP OptString ";" {{ function(NAME, OptFP, OptString) }} | "variable" NAME STARREDNAME OptSimpleArray OptAssign ";" {{ variable(NAME, STARREDNAME, OptSimpleArray, OptAssign) }} | "option" NAME OptValue ";" {{ option(NAME, OptValue) }} @@ -166,11 +167,14 @@ typemap = { def initialize(): global functions, params, pins, comp_name, names, docs, variables - global modparams, includes, hal_pin_names, hal_funct_names + global modparams, includes + global hal_pin_names, hal_funct_names global funct_derived_claims + global aliases functions = []; params = []; pins = []; options = {}; variables = [] modparams = []; docs = []; includes = []; + aliases = {} comp_name = None names = {} @@ -307,6 +311,22 @@ def param(name, type_, array, dir_, doc, value, personality): names[name] = 'param' params.append((name, type_, array, dir_, value, personality)) +def alias(name, namearr, aliasname, aliasarr): + if namearr != aliasarr: + Error(f"Alias arrays for pin '{namearr}' != '{aliasarr}'") + checkarray(name, namearr) + checkarray(aliasname, aliasarr) + if aliasname in names: + Error(f"Alias name '{aliasname}' already in use") + if name not in names: + Error(f"Pin/param name '{name}' not found, cannot alias") + if name in aliases: + Error(f"Alias for pin/param '{name}' already exists as '{aliases[name][2]}'") + if names[name] not in ('pin', 'param'): + Error(f"Expected '{name}' to be pin or param, but got '{names[name]}'"); + aliases[name] = (name, namearr, aliasname, aliasarr, names[name]) + names[aliasname] = 'alias' # Must register to prevent collision + def function(name, fp, doc): check_name_ok(name) hal_name = to_hal(name) @@ -577,6 +597,35 @@ static int comp_id; if personality: print("}", file=f) + if len(aliases) > 0: + print(" {", file=f) + print(" char pinname[HAL_NAME_LEN+1], alsname[HAL_NAME_LEN+1];", file=f) + for k, v in aliases.items(): + name, namearr, aliasname, aliasarr, nametype = v + if isinstance(array, tuple): + lim, cnt = array + print(" if((%s) > (%s)) {" % (cnt, lim), file=f) + print(' rtapi_print_msg(RTAPI_MSG_ERR,' \ + '"Alias %s: Requested size %%d exceeds max size %%d\\n",' + '(int)(%s), (int)(%s));' % (name, cnt, lim), file=f) + print(" return -ENOSPC;", file=f) + print(" }", file=f) + else: + cnt = array + if namearr: + print( " for(j = 0; j < (%s); j++) {" % cnt, file=f) + print(f" rtapi_snprintf(pinname, sizeof(pinname), \"%s.{to_hal(name)}\", prefix, j);", file=f) + print(f" rtapi_snprintf(alsname, sizeof(alsname), \"%s.{to_hal(aliasname)}\", prefix, j);", file=f) + print(f" r = {nametype}(pinname, alsname);", file=f) + print( " if(r != 0) return r;", file=f) + print( " }" % cnt, file=f) + else: + print(f" rtapi_snprintf(pinname, sizeof(pinname), \"%s.{to_hal(name)}\", prefix);", file=f) + print(f" rtapi_snprintf(alsname, sizeof(alsname), \"%s.{to_hal(aliasname)}\", prefix);", file=f) + print(f" r = hal_{nametype}_alias(pinname, alsname);", file=f) + print( " if(r != 0) return r;", file=f) + print(" }", file=f) + for type_, name, array, value in variables: if value is None: continue if array: