Motoron Motor Controller library for Raspberry Pi
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
motoron.MotoronSerial Class Reference
Inheritance diagram for motoron.MotoronSerial:
motoron.MotoronBase

Public Member Functions

def __init__ (self, *port=None, device_number=None)
 
def set_port (self, port)
 
def expect_7bit_responses (self)
 
def expect_8bit_responses (self)
 
def use_14bit_device_number (self)
 
def use_7bit_device_number (self)
 
def multi_device_error_check_start (self, starting_device_number, device_count)
 
def multi_device_error_check (self, starting_device_number, device_count)
 
def multi_device_write (self, starting_device_number, device_count, command_byte, data)
 
def __init__ (self, *port=None, device_number=None)
 
def set_port (self, port)
 
def expect_7bit_responses (self)
 
def expect_8bit_responses (self)
 
def use_14bit_device_number (self)
 
def use_7bit_device_number (self)
 
def multi_device_error_check_start (self, starting_device_number, device_count)
 
def multi_device_error_check (self, starting_device_number, device_count)
 
def multi_device_write (self, starting_device_number, device_count, command_byte, data)
 

Public Attributes

 device_number
 
 communication_options
 
 port
 

Protected Member Functions

def _send_command_core (self, cmd, send_crc)
 
def _read_response (self, length)
 
def _send_command_core (self, cmd, send_crc)
 
def _read_response (self, length)
 

Detailed Description

Represents a serial connection to a Pololu Motoron Motor Controller.

Definition at line 1761 of file motoron.py.

Constructor & Destructor Documentation

◆ __init__() [1/2]

def motoron.MotoronSerial.__init__ (   self,
port = None,
  device_number = None 
)

Creates a new MotoronSerial object.

The deviceNumber argument is optional. If it is omitted or None, the object will use the compact protocol.

The port argument specifies the serial port to use and is passed directly to set_port().

The bits in this variable are defined by the motoron.COMMUNICATION_OPTION_* constants. The bits that affect the behavior of this library are:

  • motoron.COMMUNICATION_OPTION_7BIT_RESPONSES
  • motoron.COMMUNICATION_OPTION_14BIT_DEVICE_NUMBER

Reimplemented from motoron.MotoronBase.

Definition at line 1766 of file motoron.py.

◆ __init__() [2/2]

def motoron.MotoronSerial.__init__ (   self,
port = None,
  device_number = None 
)

Creates a new MotoronSerial object.

The deviceNumber argument is optional. If it is omitted or None, the object will use the compact protocol.

The port argument specifies the serial port to use and is passed directly to set_port().

The bits in this variable are defined by the motoron.COMMUNICATION_OPTION_* constants. The bits that affect the behavior of this library are:

  • motoron.COMMUNICATION_OPTION_7BIT_RESPONSES
  • motoron.COMMUNICATION_OPTION_14BIT_DEVICE_NUMBER

Reimplemented from motoron.MotoronBase.

Definition at line 1766 of file motoron.py.

Member Function Documentation

◆ _read_response() [1/2]

def motoron.MotoronSerial._read_response (   self,
  length 
)
protected

Definition at line 1957 of file motoron.py.

◆ _read_response() [2/2]

def motoron.MotoronSerial._read_response (   self,
  length 
)
protected

Definition at line 1957 of file motoron.py.

◆ _send_command_core() [1/2]

def motoron.MotoronSerial._send_command_core (   self,
  cmd,
  send_crc 
)
protected

Definition at line 1937 of file motoron.py.

◆ _send_command_core() [2/2]

def motoron.MotoronSerial._send_command_core (   self,
  cmd,
  send_crc 
)
protected

Definition at line 1937 of file motoron.py.

◆ expect_7bit_responses() [1/2]

def motoron.MotoronSerial.expect_7bit_responses (   self)

Configures this object to work with Motorons that are configured to send 7-bit serial responses.

Definition at line 1813 of file motoron.py.

◆ expect_7bit_responses() [2/2]

def motoron.MotoronSerial.expect_7bit_responses (   self)

Configures this object to work with Motorons that are configured to send 7-bit serial responses.

Definition at line 1813 of file motoron.py.

◆ expect_8bit_responses() [1/2]

def motoron.MotoronSerial.expect_8bit_responses (   self)

Configures this object to work with Motorons that are configured to send responses in the normal 8-bit format.

Definition at line 1820 of file motoron.py.

◆ expect_8bit_responses() [2/2]

def motoron.MotoronSerial.expect_8bit_responses (   self)

Configures this object to work with Motorons that are configured to send responses in the normal 8-bit format.

Definition at line 1820 of file motoron.py.

◆ multi_device_error_check() [1/2]

def motoron.MotoronSerial.multi_device_error_check (   self,
  starting_device_number,
  device_count 
)

Sends a "Multi-device error check" command and reads the responses.

This function assumes that each addressed Motoron can see the responses sent by the other Motorons (e.g. they are in a half-duplex RS-485 network).

Returns the number of devices that indicated they have no errors. If the return value is less than device count, you can add the return value to the starting_device_number to get the device number of the first device where the check failed. This device either did not respond or it responded with an indication that it has an error, or an unexpected byte was received for some reason.

Note: Before using this, most users should make sure the MotoronSerial object is configured to use the compact protocol: construct the object without specifying a device number, or set device_number to None.

Definition at line 1871 of file motoron.py.

◆ multi_device_error_check() [2/2]

def motoron.MotoronSerial.multi_device_error_check (   self,
  starting_device_number,
  device_count 
)

Sends a "Multi-device error check" command and reads the responses.

This function assumes that each addressed Motoron can see the responses sent by the other Motorons (e.g. they are in a half-duplex RS-485 network).

Returns the number of devices that indicated they have no errors. If the return value is less than device count, you can add the return value to the starting_device_number to get the device number of the first device where the check failed. This device either did not respond or it responded with an indication that it has an error, or an unexpected byte was received for some reason.

Note: Before using this, most users should make sure the MotoronSerial object is configured to use the compact protocol: construct the object without specifying a device number, or set device_number to None.

Definition at line 1871 of file motoron.py.

◆ multi_device_error_check_start() [1/2]

def motoron.MotoronSerial.multi_device_error_check_start (   self,
  starting_device_number,
  device_count 
)

Sends a "Multi-device error check" command but does not read any responses.

Note: Before using this, most users should make sure the MotoronSerial object is configured to use the compact protocol: construct the object without specifying a device number, or set device_number to None.

Definition at line 1840 of file motoron.py.

◆ multi_device_error_check_start() [2/2]

def motoron.MotoronSerial.multi_device_error_check_start (   self,
  starting_device_number,
  device_count 
)

Sends a "Multi-device error check" command but does not read any responses.

Note: Before using this, most users should make sure the MotoronSerial object is configured to use the compact protocol: construct the object without specifying a device number, or set device_number to None.

Definition at line 1840 of file motoron.py.

◆ multi_device_write() [1/2]

def motoron.MotoronSerial.multi_device_write (   self,
  starting_device_number,
  device_count,
  command_byte,
  data 
)

Sends a "Multi-device write" command.

Note: Before using this, most users should make sure the MotoronSerial object is configured to use the compact protocol: construct the object without specifying a device number, or call setDeviceNumber with an argument of 0xFFFF.

Definition at line 1895 of file motoron.py.

◆ multi_device_write() [2/2]

def motoron.MotoronSerial.multi_device_write (   self,
  starting_device_number,
  device_count,
  command_byte,
  data 
)

Sends a "Multi-device write" command.

Note: Before using this, most users should make sure the MotoronSerial object is configured to use the compact protocol: construct the object without specifying a device number, or call setDeviceNumber with an argument of 0xFFFF.

Definition at line 1895 of file motoron.py.

◆ set_port() [1/2]

def motoron.MotoronSerial.set_port (   self,
  port 
)

Configures this object to use the specified serial port object.

The port argument should be one of the following:

  • The name of a serial port to open with pyserial (e.g. "COM6" or "/dev/ttyS0")
  • A Serial object from pyserial.
  • A machine.UART object from MicroPython.

Definition at line 1796 of file motoron.py.

◆ set_port() [2/2]

def motoron.MotoronSerial.set_port (   self,
  port 
)

Configures this object to use the specified serial port object.

The port argument should be one of the following:

  • The name of a serial port to open with pyserial (e.g. "COM6" or "/dev/ttyS0")
  • A Serial object from pyserial.
  • A machine.UART object from MicroPython.

Definition at line 1796 of file motoron.py.

◆ use_14bit_device_number() [1/2]

def motoron.MotoronSerial.use_14bit_device_number (   self)

Configures this object to send 14-bit device numbers when using the Pololu protocol, instead of the default 7-bit.

Definition at line 1827 of file motoron.py.

◆ use_14bit_device_number() [2/2]

def motoron.MotoronSerial.use_14bit_device_number (   self)

Configures this object to send 14-bit device numbers when using the Pololu protocol, instead of the default 7-bit.

Definition at line 1827 of file motoron.py.

◆ use_7bit_device_number() [1/2]

def motoron.MotoronSerial.use_7bit_device_number (   self)

Configures this object to send 7-bit device numbers, which is the default.

Definition at line 1834 of file motoron.py.

◆ use_7bit_device_number() [2/2]

def motoron.MotoronSerial.use_7bit_device_number (   self)

Configures this object to send 7-bit device numbers, which is the default.

Definition at line 1834 of file motoron.py.

Member Data Documentation

◆ communication_options

motoron.MotoronSerial.communication_options

The serial options used by this object.

This must match the serial options in the EEPROM of the Motoron you are communicating with. The default is 7-bit device numbers and 8-bit responses.

Definition at line 1788 of file motoron.py.

◆ device_number

motoron.MotoronSerial.device_number

The device number that will be included in commands sent by this object.

The default is None, which means to not send a device number and use the compact protocol instead.

Definition at line 1783 of file motoron.py.

◆ port

motoron.MotoronSerial.port

The serial port used by this object.

See set_port().

Definition at line 1808 of file motoron.py.


The documentation for this class was generated from the following files: