ckbot :: pololu :: Protocol :: Class Protocol
[hide private]
[frames] | no frames]

Class Protocol

source code


This is a concrete class that provides all the functionality needed to send messages to a pololu controller over a "pololu bus". This protocol follows the specifications provided by the Pololu Maestro Documentation found at: http://www.pololu.com/docs/0J40/all

For use with the Pololu Maestro 12pin, Firmware Version1.1

It is meant to mimic the can.Protocol class, except for the pololu device rather than a CAN network

This converts CKBot Module-specific commands into Pololu equivalents, and maintains the state of the Pololu device and its handles to modules via fake heartbeats u WARNING: Current version has only been tested with the 12-pin Pololu Maestro Firmwarev1.1 and does NOT support Pololu-styled commands (supports only MiniSSC2 and Compact), support for Pololu-styled commands will be included in a future release perhaps

Instance Methods [hide private]
 
__init__(self, bus=None, nodes=None, *args, **kw)
Initialize a pololu.Protocol
source code
 
pololu_setup(self)
Initialize the Pololu Maestro device to receive commands using Pololu Mode
source code
 
send_cmd(self, cmd_type, nid, cmd)
Sends command to the Pololu Maestro via the Bus.
source code
 
hintNodes(self, nodes)
Specify which nodes to expect on the bus
source code
 
update(self)
Updates the pololu.Protocol state that mimics the behaviour of can.Protocol.
source code
 
generatePNA(self, nid)
Generates a pololu.ProtocolNodeAdaptor, associating a pololu protocol with a specific node id and returns it
source code

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

Class Variables [hide private]
  POLOLU_BYTE = 0xAA
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, bus=None, nodes=None, *args, **kw)
(Constructor)

source code 

Initialize a pololu.Protocol

INPUT: bus -- pololu.Bus -- Serial bus used to communicate with Pololu Device nodes -- dictionary -- key:module node_id, value:pololu controller number

ATTRIBUTES: heartbeats -- dictionary -- key:nid, value:(timestamp) msgs -- dictionary -- a fake representation of a dictionary message, used so the pololu.Protocol can "dock" onto existing Cluster interfaces (provides the Module version) pna -- dictionary -- table of NodeID to ProtocolNodeAdaptor mappings

FUTURE: buses -- may be a list of buses (Protocol can communicate with multiple buses by changing servonums)

Overrides: object.__init__

send_cmd(self, cmd_type, nid, cmd)

source code 

Sends command to the Pololu Maestro via the Bus.

INPUTS: nid -- int -- Node ID to send the command to cmd -- tuple of ints -- tuple of integer command values to send cmd_type -- int -- Type of command (MiniSSC2, Pololu, and Compact types are supported)

hintNodes(self, nodes)

source code 

Specify which nodes to expect on the bus

Overrides: ckmodule.AbstractProtocol.hintNodes

update(self)

source code 

Updates the pololu.Protocol state that mimics the behaviour of can.Protocol. It updates timestamps of heartbeats heard on the bus.

Overrides: ckmodule.AbstractProtocol.update

generatePNA(self, nid)

source code 

Generates a pololu.ProtocolNodeAdaptor, associating a pololu protocol with a specific node id and returns it

Overrides: ckmodule.AbstractProtocol.generatePNA