Package pololu :: Package motors :: Module qik :: Class Qik
[hide private]
[frames] | no frames]

Class Qik

source code


Instance Methods [hide private]
 
__init__(self, device, baud, readTimeout, writeTimeout, log)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_genTimeoutList(self, const)
Generates a dict of the valid timeout values for the given const. The const value may change for different versions or types of Pololu boards.
source code
 
findConnectedDevices(self)
Find all the devices on the serial buss and store the results in a class member object.
source code
 
_deviceCallback(self, device) source code
 
getConfigForDevice(self, device)
Get a dictionary of the current hardware configuration options for the device.
source code
 
close(self)
Closes the serial connection.
source code
 
isOpen(self)
Check if the serial connection is open.
source code
 
setCompactProtocol(self)
Set the compact protocol.
source code
 
isCompactProtocol(self)
Check if currently using the compact protocol.
source code
 
setPololuProtocol(self)
Set the pololu protocol.
source code
 
isPololuProtocol(self)
Check if currently using the pololu protocol.
source code
 
setCRC(self, value)
Enable or disable cyclic redundancy check.
source code
 
isCRC(self)
Check if CRC is enabled.
source code
 
_writeData(self, command, device, params=())
Write the data to the device.
source code
 
_getFirmwareVersion(self, device)
Get the firmware version.
source code
 
_getError(self, device, message)
Get the error message or value stored in the Qik hardware.
source code
 
_getConfig(self, num, device)
Low level method used for all get config commands.
source code
 
_getDeviceID(self, device)
Get the device ID.
source code
 
_getPWMFrequency(self, device, message)
Get the PWM frequency stored on the hardware device.
source code
 
_getMotorShutdown(self, device)
Get the motor shutdown on error status stored on the hardware device.
source code
 
_getSerialTimeout(self, device)
Get the serial timeout stored on the hardware device.
source code
 
_setConfig(self, num, value, device, message)
Low level method used for all set config commands.
source code
 
_setDeviceID(self, value, device, message)
Set the hardware device number. This is only needed if more that one device is on the same serial buss.
source code
 
_setPWMFrequency(self, pwm, device, message)
Set the PWM frequency.
source code
 
_setMotorShutdown(self, value, device, message)
Set the motor shutdown on error status stored on the hardware device.
source code
 
_setSerialTimeout(self, timeout, device, message)
Set the serial timeout on the hardware device.
source code
 
_setM0Speed(self, speed, device)
Set motor 0 speed.
source code
 
_setM1Speed(self, speed, device)
Set motor 1 speed.
source code
 
_setSpeed(self, speed, motor, device)
Set motor speed. This method takes into consideration the PWM frequency that the hardware is currently running at and limits the values passed to the hardware accordingly.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _BAUD_DETECT = 170
  _CONFIG_RETURN = {0: 'OK', 1: 'Invalid Parameter', 2: 'Invalid...
  _BOOL_TO_INT = {False: 0, True: 1}
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, device, baud, readTimeout, writeTimeout, log)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

getConfigForDevice(self, device)

source code 
Get a dictionary of the current hardware configuration options for the device.
Returns:
Dictionary of current configuration options.

isOpen(self)

source code 
Check if the serial connection is open.
Returns:
If True the serial connction is open else if False it is closed.

isCompactProtocol(self)

source code 
Check if currently using the compact protocol.
Returns:
if True the compact protocol is currently being used else if False it is not currently being used.

isPololuProtocol(self)

source code 
Check if currently using the pololu protocol.
Returns:
if True the pololu protocol is currently being used else if False it is not currently being used.

setCRC(self, value)

source code 
Enable or disable cyclic redundancy check.
Parameters:
  • value (bool) - If True CRC is enabled else if False CRC is disabled.

isCRC(self)

source code 
Check if CRC is enabled.
Returns:
If True CRC is enabled else if False CRC is disabled.

_writeData(self, command, device, params=())

source code 
Write the data to the device.
Parameters:
  • command (int) - The command to write to the device.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • params (tuple) - Sequence of bytes to write.
Raises:
  • SerialTimeoutException - If the low level serial package times out.
  • SerialException - IO error when the port is not open.

_getFirmwareVersion(self, device)

source code 
Get the firmware version.
Parameters:
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
Returns:
An integer indicating the version number.

_getError(self, device, message)

source code 
Get the error message or value stored in the Qik hardware.
Parameters:
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • message (bool) - If set to True a text message will be returned, if set to False the integer stored in the Qik will be returned.
Returns:
A list of text messages, integers, or and empty list. See the message parameter above.

_getConfig(self, num, device)

source code 
Low level method used for all get config commands.
Parameters:
  • num (int) - Number that indicates the config option to get from the hardware.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
Returns:
An integer representing the value stored in the hardware device.

_getDeviceID(self, device)

source code 
Get the device ID.
Parameters:
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
Returns:
An integer number of the hardware device ID.

_getPWMFrequency(self, device, message)

source code 
Get the PWM frequency stored on the hardware device.
Parameters:
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • message (bool) - If set to True a text message will be returned, if set to False the integer stored in the Qik will be returned.
Returns:
A text message or an int. See the message parameter above.

_getMotorShutdown(self, device)

source code 
Get the motor shutdown on error status stored on the hardware device.
Parameters:
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
Returns:
Returns True when morot will shutdown on and error, else False.

_getSerialTimeout(self, device)

source code 

Get the serial timeout stored on the hardware device.

Caution, more that one value returned from the Qik can have the same actual timeout value according the the formula below. I have verified this as an idiosyncrasy of the Qik itself. There are only a total of 72 unique values that the Qik can logically use the remaining 56 values are repeats of the 72.

Parameters:
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
Returns:
The timeout value in seconds.

_setConfig(self, num, value, device, message)

source code 
Low level method used for all set config commands.
Parameters:
  • num (int) - Number that indicates the config option to get from the hardware.
  • value (int) - The value to set in the hardware device.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • message (bool) - If set to True a text message will be returned, if set to False the integer stored in the Qik will be returned.
Returns:
A text message or an int. See the message parameter above.
Raises:
  • SerialException - IO error indicating there was a problem reading from the serial connection.

_setDeviceID(self, value, device, message)

source code 
Set the hardware device number. This is only needed if more that one device is on the same serial buss.
Parameters:
  • value (int) - The device ID to set in the range of 0 - 127.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • message (bool) - If set to True a text message will be returned, if set to False the integer stored in the Qik will be returned.
Returns:
A text message or an int. See the message parameter above. If value and device are the same OK or 0 will be returned depending on the value of message.

_setPWMFrequency(self, pwm, device, message)

source code 
Set the PWM frequency.
Parameters:
  • pwm (int) - The PWN frequency to set in hertz.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • message (bool) - If set to True a text message will be returned, if set to False the integer stored in the Qik will be returned.
Returns:
A text message or an int. See the message parameter above.

_setMotorShutdown(self, value, device, message)

source code 
Set the motor shutdown on error status stored on the hardware device.
Parameters:
  • value (int) - An integer indicating the effect on the motors when an error occurs.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • message (bool) - If set to True a text message will be returned, if set to False the integer stored in the Qik will be returned.
Returns:
Text message indicating the status of the shutdown error.

_setSerialTimeout(self, timeout, device, message)

source code 
Set the serial timeout on the hardware device.
Parameters:
  • timeout (float or int) - The timeout value as defined by the hardware manual.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.
  • message (bool) - If set to True a text message will be returned, if set to False the integer stored in the Qik will be returned.
Returns:
Text message indicating the status of the shutdown error.

_setM0Speed(self, speed, device)

source code 
Set motor 0 speed.
Parameters:
  • speed (int) - Motor speed as an integer.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.

_setM1Speed(self, speed, device)

source code 
Set motor 1 speed.
Parameters:
  • speed (int) - Motor speed as an integer.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.

_setSpeed(self, speed, motor, device)

source code 
Set motor speed. This method takes into consideration the PWM frequency that the hardware is currently running at and limits the values passed to the hardware accordingly.
Parameters:
  • speed (int) - Motor speed as an integer. Negative numbers indicate reverse speeds.
  • motor (str) - A string value indicating the motor to set the speed on.
  • device (int) - The device is the integer number of the hardware devices ID and is only used with the Pololu Protocol.

Class Variable Details [hide private]

_CONFIG_RETURN

Value:
{0: 'OK', 1: 'Invalid Parameter', 2: 'Invalid Value'}