As far as I understand it is not possible to use a CAN bus with multiple clients where each client can receive all or a filtered subset of the messages of the CAN channel. In my understanding the thread_safe_bus can be used in multiple threads, but only one instance of this thread_safe_bus can receive a message. So it would not be possible to use python-can in a client based approach where you have for example one client that just logs all messages and another client that only performs communication over XCP and another over UDS. Right?!
In case I am not totally mistaken I would like to propose an approach for a (I would like to call it) 'client_bus' that is thread safe but can support independent clients over the same interface at the same time:
For this I would propose an singleton approach that holds a thread_safe_bus instance for every CAN bus interface in use. Every client that tries to create an client_bus performs a lookup if that interface is already instantiated and if so uses the existing thread_safe_bus instance. The singleton starts a receive thread for every CAN bus interface in use that reads messages and sends them via queues to all client bus instances (if not filtered on a per client basis) so that the client when performing a recv is just reading from a queue.
So 2 basic questions:
(a) does that sound more or less coherent?
(b1) if (a) is more or less a 'yes': is there an interest to a 'client_bus' implementation on your side?
(b2) In case my understanding is wrong, please try to educate me :-)
Thank you!
Best regards,
Chris