Module ioLabs :: Class Commands
[frames] | no frames]

Class Commands

source code

class to handle sending reports to device and parsing incoming reports. dynamically looks up/creates method for sending reports when none is found on the class. this will let us override the default behavior to make things friendlier when appropriate. all received messages are queued up and require a call to 'process_received_reports' to trigger the user's callbacks, so as to avoid thread issues.

Instance Methods
 
__init__(self, device) source code
 
process_received_reports(self, block=False, timeout=10)
process all reports that have been received and call the relevant callbacks.
source code
 
get_received_reports(self)
return a list of received reports (removes them from the queue)
source code
 
clear_received_reports(self)
remove all received reports from the queue
source code
 
add_callback(self, report_id, report_callback)
add a callback function that will be called when a report with the given id arrives.
source code
 
remove_callback(self, report_id, report_callback) source code
 
add_default_callback(self, report_callback) source code
 
remove_default_callback(self, report_callback) source code
 
wait_for_report(self, report_id)
blocks until we receive a report with the given id from the box and then returns it (may trigger other callbacks)
source code
 
send_wait_reply(self, command_id, report_id, *args)
send a command with the given arguments and wait for the reply
source code
 
send_wait_field(self, command_id, report_id, field_name, *args)
send a command (with the args), wait for the report and return the field on the report
source code
 
__getattr__(self, name)
return a function to send the named command to the device
source code
Method Details

process_received_reports(self, block=False, timeout=10)

source code 
process all reports that have been received and call the relevant callbacks. by default this method returns immediately if no reports are on the queue, but can be made to block and wait for a report if needeed

add_callback(self, report_id, report_callback)

source code 
add a callback function that will be called when a report with the given id arrives. callback should take a single value that is the report that was received