Compare commits

..

10 Commits

Author SHA1 Message Date
Andrei
765842ca8a
Merge branch 'Klipper3d:master' into master 2025-08-04 22:50:47 +02:00
Dmitry Butyugin
5eb07966b5 idex_modes: Fixed dual_carriage axis range calculation after homing
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-08-03 14:20:10 -04:00
Kevin O'Connor
e1ba7c17ce Revert "queuelogger: set thread name"
This reverts commit 73c6674306599000281064b599545aaaa24a5448.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-01 13:08:03 -04:00
Kevin O'Connor
0df40b43e8 serialqueue: Be sure sq->name is null terminated
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-01 12:46:32 -04:00
Timofey Titovets
17ce45d212 serialqueue: name the threads per mcu
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-01 12:42:53 -04:00
Timofey Titovets
39d01158ba serialhdl: name the threads per mcu
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-01 12:42:53 -04:00
Timofey Titovets
73c6674306 queuelogger: set thread name
Python 2.7 does not allow loading the cffi lib
inside the thread, but function calls are allowed

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-01 12:42:53 -04:00
Timofey Titovets
c78dd6a00a pyhelper: define set_thread_name() helper
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-08-01 12:42:53 -04:00
Contomo
d5c031bc13
idle_timeout: Add status field for current idle timeout (#6982)
Signed-off-by: Eric Billmeyer <eric.billmeyer@freenet.de>
2025-08-01 12:37:47 -04:00
Kevin O'Connor
2cbb895978 tmc2240: Add OTW_OV_VTH to list of ReadRegisters
Reported by @poernahi.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-08-01 12:33:50 -04:00
11 changed files with 45 additions and 14 deletions

View File

@ -291,6 +291,9 @@ is always available):
- `printing_time`: The amount of time (in seconds) the printer has
been in the "Printing" state (as tracked by the idle_timeout
module).
- `idle_timeout`: The current 'timeout' (in seconds)
to wait for the gcode to be triggered.
(as set by [SET_IDLE_TIMEOUT](G-Codes.md#set_idle_timeout))
## led

View File

@ -182,7 +182,7 @@ defs_serialqueue = """
};
struct serialqueue *serialqueue_alloc(int serial_fd, char serial_fd_type
, int client_id);
, int client_id, char name[16]);
void serialqueue_exit(struct serialqueue *sq);
void serialqueue_free(struct serialqueue *sq);
struct command_queue *serialqueue_alloc_commandqueue(void);
@ -219,6 +219,7 @@ defs_trdispatch = """
defs_pyhelper = """
void set_python_logging_callback(void (*func)(const char *));
double get_monotonic(void);
int set_thread_name(char name[16]);
"""
defs_std = """

View File

@ -10,6 +10,8 @@
#include <stdio.h> // fprintf
#include <string.h> // strerror
#include <time.h> // struct timespec
#include <linux/prctl.h> // PR_SET_NAME
#include <sys/prctl.h> // prctl
#include "compiler.h" // __visible
#include "pyhelper.h" // get_monotonic
@ -92,3 +94,10 @@ dump_string(char *outbuf, int outbuf_size, char *inbuf, int inbuf_size)
*o = '\0';
return outbuf;
}
// Set custom thread names
int __visible
set_thread_name(char name[16])
{
return prctl(PR_SET_NAME, name);
}

View File

@ -7,5 +7,6 @@ void set_python_logging_callback(void (*func)(const char *));
void errorf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
void report_errno(char *where, int rc);
char *dump_string(char *outbuf, int outbuf_size, char *inbuf, int inbuf_size);
int set_thread_name(char name[16]);
#endif // pyhelper.h

View File

@ -43,6 +43,7 @@ struct serialqueue {
uint8_t need_sync;
int input_pos;
// Threading
char name[16];
pthread_t tid;
pthread_mutex_t lock; // protects variables below
pthread_cond_t cond;
@ -612,6 +613,7 @@ static void *
background_thread(void *data)
{
struct serialqueue *sq = data;
set_thread_name(sq->name);
pollreactor_run(sq->pr);
pthread_mutex_lock(&sq->lock);
@ -623,13 +625,16 @@ background_thread(void *data)
// Create a new 'struct serialqueue' object
struct serialqueue * __visible
serialqueue_alloc(int serial_fd, char serial_fd_type, int client_id)
serialqueue_alloc(int serial_fd, char serial_fd_type, int client_id
, char name[16])
{
struct serialqueue *sq = malloc(sizeof(*sq));
memset(sq, 0, sizeof(*sq));
sq->serial_fd = serial_fd;
sq->serial_fd_type = serial_fd_type;
sq->client_id = client_id;
strncpy(sq->name, name, sizeof(sq->name));
sq->name[sizeof(sq->name)-1] = '\0';
int ret = pipe(sq->pipe_fds);
if (ret)

View File

@ -27,7 +27,7 @@ struct pull_queue_message {
struct serialqueue;
struct serialqueue *serialqueue_alloc(int serial_fd, char serial_fd_type
, int client_id);
, int client_id, char name[16]);
void serialqueue_exit(struct serialqueue *sq);
void serialqueue_free(struct serialqueue *sq);
struct command_queue *serialqueue_alloc_commandqueue(void);

View File

@ -35,7 +35,9 @@ class IdleTimeout:
printing_time = 0.
if self.state == "Printing":
printing_time = eventtime - self.last_print_start_systime
return { "state": self.state, "printing_time": printing_time }
return {"state": self.state,
"printing_time": printing_time,
"idle_timeout": self.idle_timeout}
def handle_ready(self):
self.toolhead = self.printer.lookup_object('toolhead')
self.timeout_timer = self.reactor.register_timer(self.timeout_handler)

View File

@ -58,8 +58,9 @@ Registers = {
ReadRegisters = [
"GCONF", "GSTAT", "IOIN", "DRV_CONF", "GLOBALSCALER", "IHOLD_IRUN",
"TPOWERDOWN", "TSTEP", "TPWMTHRS", "TCOOLTHRS", "THIGH", "ADC_VSUPPLY_AIN",
"ADC_TEMP", "MSCNT", "MSCURACT", "CHOPCONF", "COOLCONF", "DRV_STATUS",
"PWMCONF", "PWM_SCALE", "PWM_AUTO", "SG4_THRS", "SG4_RESULT", "SG4_IND"
"ADC_TEMP", "OTW_OV_VTH", "MSCNT", "MSCURACT", "CHOPCONF", "COOLCONF",
"DRV_STATUS", "PWMCONF", "PWM_SCALE", "PWM_AUTO", "SG4_THRS", "SG4_RESULT",
"SG4_IND"
]
Fields = {}

View File

@ -124,7 +124,7 @@ class DualCarriages:
self.toggle_active_dc_rail(dc)
kin.home_axis(homing_state, axis, dc.rail)
# Restore the original rails ordering
self.toggle_active_dc_rail(dcs[0])
self.activate_dc_mode(dcs[0], PRIMARY)
def get_status(self, eventtime=None):
status = {'carriages' : {dc.get_name() : dc.mode
for dc in self.dc_rails.values()}}

View File

@ -564,8 +564,8 @@ class MCU:
if self._name.startswith('mcu '):
self._name = self._name[4:]
# Serial port
wp = "mcu '%s': " % (self._name)
self._serial = serialhdl.SerialReader(self._reactor, warn_prefix=wp)
name = self._name
self._serial = serialhdl.SerialReader(self._reactor, mcu_name = name)
self._baud = 0
self._canbus_iface = None
canbus_uuid = config.get('canbus_uuid', None)

View File

@ -12,12 +12,17 @@ class error(Exception):
pass
class SerialReader:
def __init__(self, reactor, warn_prefix=""):
def __init__(self, reactor, mcu_name=""):
self.reactor = reactor
self.warn_prefix = warn_prefix
self.warn_prefix = ""
self.mcu_name = mcu_name
if self.mcu_name:
self.warn_prefix = "mcu '%s': " % (self.mcu_name)
sq_name = ("serialq %s" % (self.mcu_name))[:15]
self.sq_name = sq_name.encode("utf-8")
# Serial port
self.serial_dev = None
self.msgparser = msgproto.MessageParser(warn_prefix=warn_prefix)
self.msgparser = msgproto.MessageParser(warn_prefix=self.warn_prefix)
# C interface
self.ffi_main, self.ffi_lib = chelper.get_ffi()
self.serialqueue = None
@ -34,6 +39,8 @@ class SerialReader:
self.last_notify_id = 0
self.pending_notifications = {}
def _bg_thread(self):
name_short = ("serialhdl %s" % (self.mcu_name))[:15]
self.ffi_lib.set_thread_name(name_short.encode('utf-8'))
response = self.ffi_main.new('struct pull_queue_message *')
while 1:
self.ffi_lib.serialqueue_pull(self.serialqueue, response)
@ -80,7 +87,8 @@ class SerialReader:
self.serial_dev = serial_dev
self.serialqueue = self.ffi_main.gc(
self.ffi_lib.serialqueue_alloc(serial_dev.fileno(),
serial_fd_type, client_id),
serial_fd_type, client_id,
self.sq_name),
self.ffi_lib.serialqueue_free)
self.background_thread = threading.Thread(target=self._bg_thread)
self.background_thread.start()
@ -200,7 +208,8 @@ class SerialReader:
self.serial_dev = debugoutput
self.msgparser.process_identify(dictionary, decompress=False)
self.serialqueue = self.ffi_main.gc(
self.ffi_lib.serialqueue_alloc(self.serial_dev.fileno(), b'f', 0),
self.ffi_lib.serialqueue_alloc(self.serial_dev.fileno(), b'f', 0,
self.sq_name),
self.ffi_lib.serialqueue_free)
def set_clock_est(self, freq, conv_time, conv_clock, last_clock):
self.ffi_lib.serialqueue_set_clock_est(