#!/usr/bin/env python #Created 2/24/22 by Tega Edo '''Script to read/write to the XGS-600 Gauge Controller''' import serial import sys,os,math,time ser = serial.Serial('/dev/cu.usbserial-1410') # open serial port prefix = "#00" suffix = "\r" multiSensorReadCmdList = { "01" : "Read XGS contents", "03" : "Read Setpoint States", "05" : "Read software revision", "0F" : "Read Pressure Dump", "13" : "Read Pressure units", "22" : "Read Setup Lockout status" } singleSensorReadCmdList = { "02" : "Read Pressure", "04" : "Read assigned setpoints", "15" : "Read User Label of Sensor", "17" : "Read Sensor Tube Type", "32" : "Read Emission status", "34" : "Read Filament Lit", "37" : "Read Auto Fil Advance", "42" : "Read degas status", "4E" : "Read CVN gas type", "50" : "Read ion gauge gas correction", "52" : "Read Emission current", "54" : "Read Sensitivity", "B1" : "Read Auto-On" } sensorSetpointReadCmdList = { "5F" : "Read Setpoint", "8" : "Read Setpoint On pressure level", "9" : "Read Setpoint Off pressure level", "E" : "Read Setpoint On Delay time", "F" : "Read Setpoint Off Delay time" } print("\n----- Multiple Sensor Read Commands -----\n") for cmd in multiSensorReadCmdList.keys(): mscmd = prefix + cmd + suffix mscmd = mscmd.encode() ser.write(mscmd) print("Sent to XGS-600 -> " + mscmd.decode().replace("\r","\\r") + " : " + multiSensorReadCmdList[cmd]) time.sleep(1) response = ser.read(ser.inWaiting()) # response = "Oops!" print("response : " + response.decode() + "\n") print("\n----- Single Sensor Read Commands -----\n") sensorLabel = "AUX" sensorIDs = tuple(range(1,6)) sensorIdx = sensorIDs[0] for cmd in singleSensorReadCmdList.keys(): sscmd = prefix + cmd + "U" + sensorLabel + "{}".format(sensorIdx) + suffix sscmd = sscmd.encode() ser.write(sscmd) print("Sent to XGS-600 -> " + sscmd.decode().replace("\r","\\r") + " : " + singleSensorReadCmdList[cmd]) time.sleep(1) response = ser.read(ser.inWaiting()) # response = "Oops!" print("response : " + response.decode() + "\n") print("\n----- Setpoint Sensor Read Commands -----\n") setpointIDs = tuple(range(1,9)) setpointIdx = setpointIDs[0] for cmd in sensorSetpointReadCmdList.keys(): spcmd = prefix + cmd + "{}".format(setpointIdx) + suffix spcmd = spcmd.encode() ser.write(spcmd) print("Sent to XGS-600 -> " + spcmd.decode().replace("\r","\\r") + " : " + sensorSetpointReadCmdList[cmd]) time.sleep(1) response = ser.read(ser.inWaiting()) # response = "Oops!" print("response : " + response.decode() + "\n") ser.close()