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
# The EBB will cut power to the pen-lift servo motor after a given
# time delay since the last X/Y/Z motion command.
# It can also optionally set an immediate on/off state.
#
# The time delay timeout_ms is given in ms. A value of 0 will
# disable the automatic power-off feature.
#
# The state parameter is given as 0 or 1, to turn off or on
# servo power immediately, respectively.
#
# This feature requires EBB hardware v 2.5.0 and firmware 2.6.0
#
# Reference: http://evil-mad.github.io/EggBot/ebb.html#SR
#
if port_name is not None:
version_status = ebb_serial.min_version(port_name,"2.6.0")
if not version_status:
return # Unable to read version, or version is below 2.6.0.
else:
if state is None:
str_output = 'SR,{0}\r'.format(timeout_ms)
else:
str_output = 'SR,{0},{1}\r'.format(timeout_ms, state)
ebb_serial.command(port_name, str_output)