Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def queryVoltage(port_name):
# Query the EBB motor power supply input voltage.
if port_name is not None:
version_status = ebb_serial.min_version(port_name,"2.2.3")
if not version_status:
return True # Unable to read version, or version is below 2.2.3.
# In these cases, issue no voltage warning.
else:
raw_string = (ebb_serial.query(port_name, 'QC\r'))
split_string = raw_string.split(",", 1)
split_len = len(split_string)
if split_len > 1:
voltage_value = int(split_string[1]) # Pick second value only
else:
return True # We haven't received a reasonable voltage string response.
# Ignore voltage test and return.
# Typical reading is about 300, for 9 V input.
if voltage_value < 250:
return False
return True
def QueryPenUp(port_name):
if port_name is not None:
pen_status = ebb_serial.query(port_name, 'QP\r')
if pen_status[0] == '0':
return False
else:
return True
def queryEBBLV(port_name):
# Query the EBB "Layer" Variable, an 8-bit number we can read and write.
# (Unrelated to our plot layers; name is an historical artifact.)
if port_name is not None:
value = ebb_serial.query(port_name, 'QL\r')
try:
ret_val = int(value)
return value
except:
return None
def QueryPRGButton(port_name):
if port_name is not None:
return ebb_serial.query(port_name, 'QB\r')