root 2 anni fa
parent
commit
e56b962ae7
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      main_2.py

+ 4 - 1
main_2.py

@@ -24,6 +24,7 @@ def read_diskstats():
 prev_stats = read_diskstats()
 current_stats = read_diskstats()
 print(current_stats)
+prev_data = bytearray()
 
 while True:
     current_stats = read_diskstats()
@@ -45,6 +46,8 @@ while True:
    #         print(counter+3)
             byte_array.append(counter+3)
         counter += 4
-    serial_port.write(byte_array)
+    if byte_array != prev_data: 
+        serial_port.write(byte_array)
+        prev_data = byte_array
     time.sleep(0.1)  # Adjust the frequency of checking disk activity (1 second in this example)
     prev_stats = current_stats