How can you access a serial port from two different processes (Python)

后端 未结 1 1635
说谎
说谎 2021-01-19 12:00

I would like to use multiprocessing (to avoid GIL issues on multi core machines) and have a read process and a write process using the same serial port. Is that possible?

相关标签:
1条回答
  • 2021-01-19 12:34

    As stated in the comments, only one process can acquire the serial port at a time - therefore the way to go is to create yet another process, possibly using Python xmlrpc, or jsonrpc, that will do the actual hardware I/O, and modify your current read and write scripts to call remote functions on that other process.

    The example in the library documentation should be enough for implementing such "I/O server process" with xmlrpc: http://docs.python.org/library/simplexmlrpcserver.html

    0 讨论(0)
提交回复
热议问题