Skip to content

Commit c59b9fd

Browse files
Always set exclusive serial port access. (#1964)
Should prevent two applications from trying to access the same serial port simultaneously.
1 parent d552c1b commit c59b9fd

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

pymodbus/client/serial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def connect(self):
210210
stopbits=self.comm_params.stopbits,
211211
baudrate=self.comm_params.baudrate,
212212
parity=self.comm_params.parity,
213+
exclusive=True,
213214
)
214215
if self.params.strict:
215216
self.socket.interCharTimeout = self.inter_char_timeout

pymodbus/transport/transport.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def init_setup_connect_listen(self, host: str, port: int) -> None:
202202
parity=self.comm_params.parity,
203203
stopbits=self.comm_params.stopbits,
204204
timeout=self.comm_params.timeout_connect,
205+
exclusive=True,
205206
)
206207
return
207208
if self.comm_params.comm_type == CommType.UDP:

0 commit comments

Comments
 (0)