@@ -186,7 +186,10 @@ def execute(self, no_response_expected: bool, request: ModbusPDU): # noqa: C901
186186 ModbusTransactionState .to_string (self .client .state ),
187187 )
188188 retries = self .retries
189- request .transaction_id = self .getNextTID ()
189+ if isinstance (self .client .framer , FramerSocket ):
190+ request .transaction_id = self .getNextTID ()
191+ else :
192+ request .transaction_id = 0
190193 Log .debug ("Running transaction {}" , request .transaction_id )
191194 if _buffer := hexlify_packets (
192195 self .client .framer .databuffer
@@ -241,7 +244,7 @@ def execute(self, no_response_expected: bool, request: ModbusPDU): # noqa: C901
241244 self .addTransaction (pdu )
242245 if not (result := self .getTransaction (request .transaction_id )):
243246 if len (self .transactions ):
244- result = self .getTransaction (tid = 0 )
247+ result = self .getTransaction (0 )
245248 else :
246249 last_exception = last_exception or (
247250 "No Response received from the remote slave"
@@ -250,7 +253,7 @@ def execute(self, no_response_expected: bool, request: ModbusPDU): # noqa: C901
250253 result = ModbusIOException (
251254 last_exception , request .function_code
252255 )
253- self .client .close ()
256+ self .client .close ()
254257 if hasattr (self .client , "state" ):
255258 Log .debug (
256259 "Changing transaction state from "
0 commit comments