@@ -94,8 +94,7 @@ def _handle_trash(self, buffer, index):
9494 self .trashdataf += f" { byte :02x} "
9595 else :
9696 self .trashdata = True
97- self .trashdataf = f"\033 [33mWarning \033 [0m: Ignoring data: [{
98- byte :02x} "
97+ self .trashdataf = f"\033 [33mWarning \033 [0m: Ignoring data: [{ byte :02x} "
9998 self .bufferIndex = index + 1
10099
101100 def _log_raw (self , buffer , start , end ):
@@ -165,8 +164,7 @@ def _handle_read_bits(self, buffer, start, sid, fc):
165164 return None
166165 self ._log_raw (buffer , start , self .bufferIndex )
167166 self ._log_data (
168- f"Master\t -> ID: { sid } , FC: 0x{
169- fc :02x} , Read address: { read_address } , Read Quantity: { read_qty } "
167+ f"Master\t -> ID: { sid } , FC: 0x{ fc :02x} , Read address: { read_address } , Read Quantity: { read_qty } "
170168 )
171169 self ._log_csv (
172170 datetime .now ().isoformat (), sid , "READ" , read_address , read_qty , []
@@ -203,8 +201,7 @@ def _handle_read_registers(self, buffer, start, sid, fc):
203201 )
204202 fname = "Read Holding Registers" if fc == 3 else "Read Input Registers"
205203 self ._log_data (
206- f"Master\t -> ID: { sid } , FC: 0x{
207- fc :02x} , Read address: { read_address } , Read Quantity: { read_qty } "
204+ f"Master\t -> ID: { sid } , FC: 0x{ fc :02x} , Read address: { read_address } , Read Quantity: { read_qty } "
208205 )
209206 self ._log_csv (
210207 datetime .now ().isoformat (), sid , "READ" , read_address , read_qty , []
@@ -234,10 +231,7 @@ def _handle_write_single(self, buffer, start, sid, fc):
234231 return None
235232 self ._log_raw (buffer , start , self .bufferIndex )
236233 self ._log_data (
237- f"Master\t -> ID: { sid } , FC: 0x{
238- fc :02x} , Write addr: { addr } , Data: {
239- int .from_bytes (
240- data , 'big' )} "
234+ f"Master\t -> ID: { sid } , FC: 0x{ fc :02x} , Write addr: { addr } , Data: { int .from_bytes (data , 'big' )} "
241235 )
242236 fname = "Write Single Coil" if fc == 5 else "Write Single Register"
243237 frame = self ._common_frame (
@@ -445,10 +439,7 @@ def _handle_write_single_response(self, buffer, start, sid, fc):
445439 self ._log_raw (buffer , start , self .bufferIndex )
446440 fname = "Write Single Coil" if fc == 5 else "Write Single Register"
447441 self ._log_data (
448- f"Slave\t -> ID: { sid } , FC: 0x{
449- fc :02x} , Echo addr: { addr } , Data: {
450- int .from_bytes (
451- data , 'big' )} "
442+ f"Slave\t -> ID: { sid } , FC: 0x{ fc :02x} , Echo addr: { addr } , Data: { int .from_bytes (data , 'big' )} "
452443 )
453444 self ._log_csv (
454445 datetime .now ().isoformat (),
0 commit comments