Package ckbot :: Module hitec :: Class Bus
[hide private]
[frames] | no frames]

Class Bus

source code


Concrete class that provides the functionality needed to send messages to a Hitec servos over their serial connection.

It is responsible for correctly formatting certain inputs to hitec-understandable formats as documented in the Hitec datasheet

Instance Methods [hide private]
 
__init__(self, port='tty={ "baudrate":19200, "stopbits":2, "parity":"N", "timeout"..., *args, **kw)
Initialize hitec bus
source code
 
close(self)
Close communication with servo bus
source code
 
reset(self)
Reset communication with servo bus ...
source code
 
read(self)
read a single frame off the serial or returns None,None
source code
 
write(self, cmd, tx0, tx1)
Formats a message, sends it and returns a copy of header
source code
 
sync_write_read(self, pkt)
Synchronously send packet and read (same length) response
source code
 
send_cmd_sync(self, cmd, tx0, tx1, pause=0.01, retries=4)
Send a command in synchronous form, waiting for reply
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, port='tty={ "baudrate":19200, "stopbits":2, "parity":"N", "timeout"..., *args, **kw)
(Constructor)

source code 

Initialize hitec bus

INPUT: port -- serial port string, or None to autoconfig

ATTRIBUTES: ser -- serial handle

Overrides: object.__init__

reset(self)

source code 

Reset communication with servo bus ... note: this can be useful when serial fails after a power reset

read(self)

source code 

read a single frame off the serial or returns None,None

Makes sure that the framing and sync byte are in place. If a fragment is received -- stores it for future use, and returns None,None

send_cmd_sync(self, cmd, tx0, tx1, pause=0.01, retries=4)

source code 

Send a command in synchronous form, waiting for reply

If reply times out -- retries until retry count runs out