Skip to content

Commit

Permalink
Update hwp_pcu.py
Browse files Browse the repository at this point in the history
  • Loading branch information
17-sugiyama authored Dec 6, 2023
1 parent 6ff9f82 commit 9c5ca71
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions socs/agents/hwp_pcu/drivers/hwp_pcu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class PCU:
Args:
port (str): Path to USB device in '/dev/'
Attributes:
status (str): The status of the unit (off/on_1/on_2/hold)
"""
Expand All @@ -29,21 +29,21 @@ def relay_off(self, channel):
cmd = "relay off " + str(channel) + "\n\r"
self.port.write(cmd.encode('utf-8'))
time.sleep(.1)

def relay_read(self, channel):
cmd = "relay read " + str(channel) + "\n\r"
self.port.write(cmd.encode('utf-8'))
response = self.port.read(21)
time.sleep(.1)
response = self.port.read(25)
time.sleep(.1)
response = response.decode('utf-8')
if response.find("on") > 0:
return True

elif response.find("off") > 0:
return False

else:
return -1

def get_status(self):
"""get_status()
Expand All @@ -52,11 +52,10 @@ def get_status(self):
on_1:The compensation phase is +120 deg.
on_2: The compensation phase is -120 deg.
hold: Stop the HWP spin.
"""
channel = [0, 1, 2, 5, 6, 7]
channel_switch = []

for i in channel:
channel_switch.append(self.relay_read(i))
if channel_switch == [False, False, False, False, False, False]:
Expand All @@ -69,7 +68,3 @@ def get_status(self):
return 'hold'
else:
return 'undefined'




0 comments on commit 9c5ca71

Please sign in to comment.