Skip to content

Commit

Permalink
add set new id method
Browse files Browse the repository at this point in the history
  • Loading branch information
bluenex committed Oct 31, 2017
1 parent d7a6c88 commit 554289a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion dxl-cli.py → dxlcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ def getConnectIds(self):
self.connected_motor_ids = list(self.serial_connection.scan(range(self.scan_limit)))
print("Available ids are", self.connected_motor_ids)

###########
# Set Ids #
###########

def setNewIdOf(self, motor_id, new_id):
if motor_id == new_id or new_id < 1 or new_id > 254:
print("Please use id in range of 1-254 and not duplicated with old id: {0}".format(motor_id))
return

self.serial_connection.set_id(motor_id, new_id)
print("Motor id {0} is changed to id {1}.".format(motor_id, new_id))

#####################
# Print Information #
#####################
Expand Down Expand Up @@ -111,7 +123,7 @@ def help():
txt = '''List of methods available.
====== Connection ======
--- Import
from dxl-cli import MotorManager
from dxlcli import MotorManager
--- Instantiate class
m = MotorManager(p="/dev/ttyUSB0", baudRate=1000000, scanLimit=20, defaultSpeed=90)
Expand All @@ -123,6 +135,9 @@ def help():
--- Get connected motor ids
m.getConnectIds()
====== ID settings ======
m.setNewIdOf(self, motor_id, new_id):
====== Printing Information ======
--- All available baudrates
m.printAvailableBaudrates()
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can call information below anytime by calling `MotorManager.help()`.
# List of methods available.
====== Connection ======
# --- Import
from dxl-cli import MotorManager
from dxlcli import MotorManager

# --- Instantiate class
m = MotorManager(p="/dev/ttyUSB0", baudRate=1000000, scanLimit=20, defaultSpeed=90)
Expand Down

0 comments on commit 554289a

Please sign in to comment.