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 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
# 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)
def setPenUpRate(port_name, pen_up_rate):
if port_name is not None:
ebb_serial.command(port_name, 'SC,11,{0}\r'.format(pen_up_rate))
# Set the rate of change of the servo when going up.
def setEBBLV(port_name, ebb_lv):
# Set 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:
ebb_serial.command(port_name, 'SL,{0}\r'.format(ebb_lv))
def setPenDownRate(port_name, pen_down_rate):
if port_name is not None:
ebb_serial.command(port_name, 'SC,12,{0}\r'.format(pen_down_rate))
# Set the rate of change of the servo when going down.
def setPenUpPos(port_name, servo_min):
if port_name is not None:
ebb_serial.command(port_name, 'SC,4,{0}\r'.format(servo_min))
# servo_min may be in the range 1 to 65535, in units of 83 ns intervals. This sets the "Pen Up" position.
def PBOutValue(port_name, pin, state):
# Set state of the I/O pin. Pin: {0,1,2, or 3}. State: {0 or 1}.
# Set the pin as an output with OutputPinBConfigure before using this.
if port_name is not None:
str_output = 'PO,B,{0},{1}\r'.format(pin, state)
ebb_serial.command(port_name, str_output)
def TogglePen(port_name):
if port_name is not None:
ebb_serial.command(port_name, 'TP\r')
def doABMove(port_name, delta_a, delta_b, duration):
# Issue command to move A/B axes as: "XM,,,"
# Then, moves by + , and as -
if port_name is not None:
str_output = 'XM,{0},{1},{2}\r'.format(duration, delta_a, delta_b)
ebb_serial.command(port_name, str_output)