|
@@ -0,0 +1,135 @@
|
|
|
|
|
+#!/usr/bin/env python3
|
|
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
|
|
+"""
|
|
|
|
|
+Prod2U 6400 V2.0 - Simple GET_ALL Query Tool
|
|
|
|
|
+Sends standard GET_ALL frame (A5 5A 02 00 6D 7B) and prints all 35 PTC, 8 Fans, BMC, CT7428.
|
|
|
|
|
+"""
|
|
|
|
|
+
|
|
|
|
|
+import sys
|
|
|
|
|
+import os
|
|
|
|
|
+import glob
|
|
|
|
|
+import time
|
|
|
|
|
+import serial
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def crc16_ccitt(data: bytes) -> int:
|
|
|
|
|
+ crc = 0xFFFF
|
|
|
|
|
+ for b in data:
|
|
|
|
|
+ crc ^= (b << 8)
|
|
|
|
|
+ for _ in range(8):
|
|
|
|
|
+ if crc & 0x8000:
|
|
|
|
|
+ crc = ((crc << 1) ^ 0x1021) & 0xFFFF
|
|
|
|
|
+ else:
|
|
|
|
|
+ crc = (crc << 1) & 0xFFFF
|
|
|
|
|
+ return crc
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def find_port():
|
|
|
|
|
+ if len(sys.argv) > 1:
|
|
|
|
|
+ return sys.argv[1]
|
|
|
|
|
+ if os.path.exists('/dev/ttyUSB1'):
|
|
|
|
|
+ return '/dev/ttyUSB1'
|
|
|
|
|
+ if os.path.exists('/dev/ttyUSB0'):
|
|
|
|
|
+ return '/dev/ttyUSB0'
|
|
|
|
|
+ by_id = glob.glob('/dev/serial/by-id/*')
|
|
|
|
|
+ return by_id[-1] if by_id else '/dev/ttyUSB1'
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def main():
|
|
|
|
|
+ port = find_port()
|
|
|
|
|
+ baud = 921600
|
|
|
|
|
+
|
|
|
|
|
+ try:
|
|
|
|
|
+ ser = serial.Serial(port, baud, timeout=0.05)
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ print(f"[Error] Cannot open {port}: {e}")
|
|
|
|
|
+ sys.exit(1)
|
|
|
|
|
+
|
|
|
|
|
+ # Frame: A5 5A 02 00 6D 7B
|
|
|
|
|
+ GET_ALL_FRAME = bytes.fromhex('A5 5A 02 00 6D 7B')
|
|
|
|
|
+
|
|
|
|
|
+ ser.reset_input_buffer()
|
|
|
|
|
+ ser.write(GET_ALL_FRAME)
|
|
|
|
|
+
|
|
|
|
|
+ t0 = time.time()
|
|
|
|
|
+ buf = b''
|
|
|
|
|
+ got_ack = False
|
|
|
|
|
+ data_payload = None
|
|
|
|
|
+
|
|
|
|
|
+ while time.time() - t0 < 3.0:
|
|
|
|
|
+ c = ser.read(ser.in_waiting or 64)
|
|
|
|
|
+ if c:
|
|
|
|
|
+ buf += c
|
|
|
|
|
+ else:
|
|
|
|
|
+ time.sleep(0.02)
|
|
|
|
|
+
|
|
|
|
|
+ if b'\xA5\x5A\x82\x00\xF5\x60' in buf:
|
|
|
|
|
+ got_ack = True
|
|
|
|
|
+
|
|
|
|
|
+ idx = buf.find(b'\xA5\x5A\x42\x5E')
|
|
|
|
|
+ if idx >= 0 and len(buf) >= idx + 4 + 94 + 2:
|
|
|
|
|
+ frame = buf[idx : idx + 4 + 94 + 2]
|
|
|
|
|
+ payload = frame[4 : 4 + 94]
|
|
|
|
|
+ crc_rx = frame[-2] | (frame[-1] << 8)
|
|
|
|
|
+ crc_calc = crc16_ccitt(frame[2 : 4 + 94])
|
|
|
|
|
+ if crc_rx == crc_calc:
|
|
|
|
|
+ data_payload = payload
|
|
|
|
|
+ break
|
|
|
|
|
+
|
|
|
|
|
+ ser.close()
|
|
|
|
|
+
|
|
|
|
|
+ if not data_payload:
|
|
|
|
|
+ print(f"[!] No valid GET_DATA received on {port} (ACK={got_ack})")
|
|
|
|
|
+ sys.exit(1)
|
|
|
|
|
+
|
|
|
|
|
+ # Parse 94-byte payload
|
|
|
|
|
+ # 0..34 : PTC 0..34 (35 bytes)
|
|
|
|
|
+ # 35..38 : Front Fans 0..3 (4 bytes)
|
|
|
|
|
+ # 39..42 : Rear Fans 0..3 (4 bytes)
|
|
|
|
|
+ # 43..66 : BMC 24 channels (24 bytes)
|
|
|
|
|
+ # 67..93 : CT7428 27 channels (27 bytes)
|
|
|
|
|
+
|
|
|
|
|
+ ptc = list(data_payload[0:35])
|
|
|
|
|
+ front_fans = list(data_payload[35:39])
|
|
|
|
|
+ rear_fans = list(data_payload[39:43])
|
|
|
|
|
+ bmc = list(data_payload[43:67])
|
|
|
|
|
+ ct = list(data_payload[67:94])
|
|
|
|
|
+
|
|
|
|
|
+ print('=' * 68)
|
|
|
|
|
+ print(f' Prod2U 6400 V2.0 GET_ALL Telemetry ({port} @ {baud})')
|
|
|
|
|
+ print('=' * 68)
|
|
|
|
|
+
|
|
|
|
|
+ print('[PTC Outputs (35 Channels)]')
|
|
|
|
|
+ print(f' CON147 (PTC 0.. 9) : {ptc[0:10]}')
|
|
|
|
|
+ print(f' CON148 (PTC 10..19) : {ptc[10:20]}')
|
|
|
|
|
+ print(f' CON149 (PTC 20..29) : {ptc[20:30]}')
|
|
|
|
|
+ print(f' CON150 (PTC 30..34) : {ptc[30:35]}')
|
|
|
|
|
+
|
|
|
|
|
+ print('\n[Fan Connector Outputs (8 Channels)]')
|
|
|
|
|
+ print(f' Front Fans 0..3 : {front_fans}%')
|
|
|
|
|
+ print(f' Rear Fans 0..3 : {rear_fans}%')
|
|
|
|
|
+
|
|
|
|
|
+ print('\n[BMC Memory Temperatures (24 Channels)]')
|
|
|
|
|
+ bmc_valid = [(ch, val) for ch, val in enumerate(bmc) if val != 0xFF]
|
|
|
|
|
+ if bmc_valid:
|
|
|
|
|
+ lines = []
|
|
|
|
|
+ for ch, val in bmc_valid:
|
|
|
|
|
+ lines.append(f'CH{ch:02d}={val}°C')
|
|
|
|
|
+ print(' Active: ' + ', '.join(lines))
|
|
|
|
|
+ print(' Raw 24: ' + ' '.join([f'{v:02X}' if v != 0xFF else '--' for v in bmc]))
|
|
|
|
|
+ else:
|
|
|
|
|
+ print(' All 24 channels -- (Standby / Slots Unpopulated)')
|
|
|
|
|
+
|
|
|
|
|
+ print('\n[CT7428 Temperatures (27 Channels)]')
|
|
|
|
|
+ ct_valid = [(ch, val) for ch, val in enumerate(ct) if val != 0xFF]
|
|
|
|
|
+ if ct_valid:
|
|
|
|
|
+ print(f' Valid Sensors: {len(ct_valid)}/27 channels active')
|
|
|
|
|
+ print(' Raw 27: ' + ' '.join([f'{v:02d}°C' if v != 0xFF else '--' for v in ct]))
|
|
|
|
|
+ else:
|
|
|
|
|
+ print(' All 27 channels -- (Offline)')
|
|
|
|
|
+
|
|
|
|
|
+ print('=' * 68)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
|
+ main()
|