This class handles all data interchanges with Firmata The receive loop
runs in its own thread.
Messages to be sent to Firmata are queued through a deque to allow for
priority messages to take precedence. The deque is checked within the
receive loop for any outgoing messages.
There is no blocking in either communications direction.
|
__init__(self,
transport,
command_deque,
data_lock)
constructor for CommandHandler class |
source code
|
|
|
|
|
|
|
auto_discover_board(self,
max_wait_time=30)
This method will allow up to max_wait_time seconds for discovery
(communicating with) an Arduino board and then will determine a pin
configuration table for the board. |
source code
|
|
|
report_version(self,
data)
This method processes the report version message, sent
asynchronously by Firmata when it starts up or after
refresh_report_version() is called |
source code
|
|
|
|
|
|
|
get_analog_latch_data(self,
pin)
This method reads the analog latch table for the specified pin and
returns a list that contains: [latch_state, latched_data, and
time_stamp]. |
source code
|
|
|
get_digital_latch_data(self,
pin)
This method reads the digital latch table for the specified pin and
returns a list that contains: [latch_state, latched_data, and
time_stamp]. |
source code
|
|
|
report_firmware(self,
data)
This method processes the report firmware message, sent
asynchronously by Firmata when it starts up or after
refresh_report_firmware() is called |
source code
|
|
|
|
|
|
|
encoder_data(self,
data)
This method handles the incoming encoder data message and stores the
data in the response table. |
source code
|
|
|
sonar_data(self,
data)
This method handles the incoming sonar data message and stores the
data in the response table. |
source code
|
|
|
|
|
|
|
send_sysex(self,
sysex_command,
sysex_data=None)
This method will send a Sysex command to Firmata with any
accompanying data |
source code
|
|
|
|
|
|
|
|
|
|
|
capability_response(self,
data)
This method handles a capability response message and stores the
results to be retrieved via get_capability_query_results() in
pymata.py |
source code
|
|
|
pin_state_response(self,
data)
This method handles a pin state response message and stores the
results to be retrieved via get_pin_state_query_results() in
pymata.py |
source code
|
|
|
analog_mapping_response(self,
data)
This method handles an analog mapping query response message and
stores the results to be retrieved via
get_analog_mapping_request_results() in pymata.py |
source code
|
|
|
run(self)
This method starts the thread that continuously runs to receive and
interpret messages coming from Firmata. |
source code
|
|
Inherited from threading.Thread :
__repr__ ,
getName ,
isAlive ,
isDaemon ,
is_alive ,
join ,
setDaemon ,
setName ,
start
Inherited from threading.Thread (private):
_reset_internal_locks ,
_set_daemon ,
_set_ident
Inherited from threading._Verbose (private):
_note
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
|
MSG_CMD_MIN = 128
|
|
REPORT_ANALOG = 192
|
|
REPORT_DIGITAL = 208
|
|
SET_PIN_MODE = 244
|
|
START_SYSEX = 240
|
|
END_SYSEX = 247
|
|
SYSTEM_RESET = 255
|
|
DIGITAL_MESSAGE = 144
|
|
ANALOG_MESSAGE = 224
|
|
REPORT_VERSION = 249
|
|
ENCODER_CONFIG = 32
|
|
TONE_PLAY = 95
|
|
SONAR_CONFIG = 96
|
|
ENCODER_DATA = 33
|
|
SONAR_DATA = 97
|
|
SERVO_CONFIG = 112
|
|
STRING_DATA = 113
|
|
I2C_REQUEST = 118
|
|
I2C_REPLY = 119
|
|
I2C_CONFIG = 120
|
|
REPORT_FIRMWARE = 121
|
|
SAMPLING_INTERVAL = 122
|
|
EXTENDED_ANALOG = 111
|
|
PIN_STATE_QUERY = 109
|
|
PIN_STATE_RESPONSE = 110
|
|
CAPABILITY_QUERY = 107
|
|
CAPABILITY_RESPONSE = 108
|
|
ANALOG_MAPPING_QUERY = 105
|
|
ANALOG_MAPPING_RESPONSE = 106
|
|
SYSEX_NON_REALTIME = 126
|
|
SYSEX_REALTIME = 127
|
|
INPUT = 0
|
|
OUTPUT = 1
|
|
ANALOG = 2
|
|
PWM = 3
|
|
SERVO = 4
|
|
I2C = 6
|
|
ONEWIRE = 7
|
|
STEPPER = 8
|
|
TONE = 9
|
|
ENCODER = 10
|
|
SONAR = 11
|
|
IGNORE = 127
|
|
DIGITAL = 32
|
|
analog_response_table = [ ]
|
|
digital_response_table = [ ]
|
|
analog_latch_table = [ ]
|
|
digital_latch_table = [ ]
|
|
LATCH_STATE = 0
|
|
LATCHED_THRESHOLD_TYPE = 1
|
|
ANALOG_LATCH_DATA_TARGET = 2
|
|
ANALOG_LATCHED_DATA = 3
|
|
ANALOG_TIME_STAMP = 4
|
|
DIGITAL_LATCHED_DATA = 2
|
|
DIGITAL_TIME_STAMP = 3
|
|
LATCH_IGNORE = 0
|
|
LATCH_ARMED = 1
|
|
LATCH_LATCHED = 2
|
|
DIGITAL_LATCH_LOW = 0
|
|
DIGITAL_LATCH_HIGH = 1
|
|
ANALOG_LATCH_GT = 2
|
|
ANALOG_LATCH_LT = 3
|
|
ANALOG_LATCH_GTE = 4
|
|
ANALOG_LATCH_LTE = 5
|
|
RESPONSE_TABLE_MODE = 0
|
|
RESPONSE_TABLE_PIN_DATA_VALUE = 1
|
|
MSB = 2
|
|
LSB = 1
|
|
command_dispatch = { }
|
|
command_deque = None
|
|
firmata_version = [ ]
|
|
firmata_firmware = [ ]
|
|
data_lock = None
|
|
total_pins_discovered = 0
|
|
number_of_analog_pins_discovered = 0
|
|
i2c_map = { }
|
|
active_sonar_map = { }
|