mirror of
https://github.com/andreili/klipper.git
synced 2025-08-23 19:34:06 +02:00
serialqueue: name the threads per mcu
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
This commit is contained in:
parent
39d01158ba
commit
17ce45d212
@ -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);
|
||||
|
@ -47,6 +47,7 @@ struct serialqueue {
|
||||
pthread_mutex_t lock; // protects variables below
|
||||
pthread_cond_t cond;
|
||||
int receive_waiting;
|
||||
char name[16];
|
||||
// Baud / clock tracking
|
||||
int receive_window;
|
||||
double bittime_adjust, idle_time;
|
||||
@ -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,15 @@ 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));
|
||||
|
||||
int ret = pipe(sq->pipe_fds);
|
||||
if (ret)
|
||||
|
@ -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);
|
||||
|
@ -18,6 +18,8 @@ class SerialReader:
|
||||
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=self.warn_prefix)
|
||||
@ -85,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()
|
||||
@ -205,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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user