Have a linux setup, where I need 2 Python processes to use the same comport, how can I easily share that serial port resource between to separate processes? Its only the server program that need to open the serial port and then the client shall connect to server and use the same serial port. Shall i go after socket or something else? Any point to code example will be appreciated. Br Esben
Asked
Active
Viewed 367 times
0
-
2Sharing a resource in 2 or more processes is a bad idea because they are going to block, it is like everyone wants to eat with the same spoon, if it is busy we will have to wait our turn, and that is not pleasant. Instead it creates an exclusive process that manages the serial port, and the other processes that send or ask for information. – eyllanesc Jun 19 '18 at 05:14
-
Also, there's really nothing Python-specific about this. Two Python scripts grabbing the same serial port does the same thing as two C programs grabbing the same serial port. – abarnert Jun 19 '18 at 05:17
-
This solucion works very nice: https://stackoverflow.com/a/63537265/4702399 – Baurin Leza Aug 22 '20 at 15:29
1 Answers
0
My solution was to build a multiprocessing server handling the serial trafic, Then post message to and from the servers through a queue from my client programs.

Esben Jensen
- 39
- 1
- 8