Skip to content

Commit e0ede61

Browse files
committed
halcmd, plasmac: print 64-bit sint values arch-neutrally
The thread time/tmax and plasmac low_cut_volts prints used %ld with hal_get_sint() values (int64_t), which only matches on LP64. Use fmt::format for the halcmd thread print (fmt is already used in this file and formats int64_t natively) and a (long long) cast with %lld for the plasmac realtime component, where rtapi_print_msg is the only output channel.
1 parent eb7b036 commit e0ede61

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎src/hal/components/plasmac.comp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,9 @@ FUNCTION(_) {
802802
probe_required = TRUE;
803803
rtapi_print_msg(RTAPI_MSG_ERR,"arc voltage fell below safe level while THC active\n"
804804
"target voltage = %.2f\n"
805-
"low cut volts = %ld\n"
805+
"low cut volts = %lld\n"
806806
"arc voltage = %.2f\n"
807-
"program is paused.\n", target_volts, low_cut_volts, arc_voltage_out);
807+
"program is paused.\n", target_volts, (long long)low_cut_volts, arc_voltage_out);
808808
probe_inhibit = TRUE;
809809
state = MAX_HEIGHT;
810810
}

‎src/hal/utils/halcmd_commands.cc‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,12 +1763,21 @@ static void print_thread_info_print(const hal_query_t *q, const char **patterns)
17631763
int rvm = hal_getref_p(&qm);
17641764
if(!rvt && !rvm) {
17651765
// note that the scriptmode format string has no \n
1766-
halcmd_output((!scriptmode ? "%11ld %-3s %20s ( %8ld, %8ld )\n" : "%ld %s %s %8ld %ld"),
1767-
q->thread.period,
1768-
"YES", // Always uses FP
1769-
q->name,
1770-
hal_get_sint(qt.pp.ref.s),
1771-
hal_get_sint(qm.pp.ref.s));
1766+
if(!scriptmode) {
1767+
halcmd_output("%s", fmt::format("{:11d} {:<3s} {:>20s} ( {:8d}, {:8d} )\n",
1768+
q->thread.period,
1769+
"YES", // Always uses FP
1770+
q->name,
1771+
hal_get_sint(qt.pp.ref.s),
1772+
hal_get_sint(qm.pp.ref.s)).c_str());
1773+
} else {
1774+
halcmd_output("%s", fmt::format("{:d} {:s} {:s} {:8d} {:d}",
1775+
q->thread.period,
1776+
"YES", // Always uses FP
1777+
q->name,
1778+
hal_get_sint(qt.pp.ref.s),
1779+
hal_get_sint(qm.pp.ref.s)).c_str());
1780+
}
17721781
} else {
17731782
rtapi_print_msg(RTAPI_MSG_ERR, "unexpected: cannot find time/tmax pin for %s thread\n", q->name);
17741783
}

0 commit comments

Comments
 (0)