INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Create a new community or update an existing one using the uuid.
def create_community(self, token, name, **kwargs): """ Create a new community or update an existing one using the uuid. :param token: A valid token for the user in question. :type token: string :param name: The community name. :type name: string :param descriptio...
Get a community based on its name.
def get_community_by_name(self, name, token=None): """ Get a community based on its name. :param name: The name of the target community. :type name: string :param token: (optional) A valid token for the user in question. :type token: None | string :returns: The r...
Get a community based on its id.
def get_community_by_id(self, community_id, token=None): """ Get a community based on its id. :param community_id: The id of the target community. :type community_id: int | long :param token: (optional) A valid token for the user in question. :type token: None | string ...
Get the non - recursive children of the passed in community_id.
def get_community_children(self, community_id, token=None): """ Get the non-recursive children of the passed in community_id. :param community_id: The id of the requested community. :type community_id: int | long :param token: (optional) A valid token for the user in question. ...
List all communities visible to a user.
def list_communities(self, token=None): """ List all communities visible to a user. :param token: (optional) A valid token for the user in question. :type token: None | string :returns: The list of communities. :rtype: list[dict] """ parameters = dict() ...
Get the attributes of the specified folder.
def folder_get(self, token, folder_id): """ Get the attributes of the specified folder. :param token: A valid token for the user in question. :type token: string :param folder_id: The id of the requested folder. :type folder_id: int | long :returns: Dictionary of...
Get the non - recursive children of the passed in folder_id.
def folder_children(self, token, folder_id): """ Get the non-recursive children of the passed in folder_id. :param token: A valid token for the user in question. :type token: string :param folder_id: The id of the requested folder. :type folder_id: int | long :re...
Delete the folder with the passed in folder_id.
def delete_folder(self, token, folder_id): """ Delete the folder with the passed in folder_id. :param token: A valid token for the user in question. :type token: string :param folder_id: The id of the folder to be deleted. :type folder_id: int | long :returns: No...
Move a folder to the destination folder.
def move_folder(self, token, folder_id, dest_folder_id): """ Move a folder to the destination folder. :param token: A valid token for the user in question. :type token: string :param folder_id: The id of the folder to be moved. :type folder_id: int | long :param ...
Create an item to the server.
def create_item(self, token, name, parent_id, **kwargs): """ Create an item to the server. :param token: A valid token for the user in question. :type token: string :param name: The name of the item to be created. :type name: string :param parent_id: The id of th...
Get the attributes of the specified item.
def item_get(self, token, item_id): """ Get the attributes of the specified item. :param token: A valid token for the user in question. :type token: string :param item_id: The id of the requested item. :type item_id: int | string :returns: Dictionary of the item ...
Download an item to disk.
def download_item(self, item_id, token=None, revision=None): """ Download an item to disk. :param item_id: The id of the item to be downloaded. :type item_id: int | long :param token: (optional) The authentication token of the user requesting the download. :t...
Delete the item with the passed in item_id.
def delete_item(self, token, item_id): """ Delete the item with the passed in item_id. :param token: A valid token for the user in question. :type token: string :param item_id: The id of the item to be deleted. :type item_id: int | long :returns: None. :r...
Get the metadata associated with an item.
def get_item_metadata(self, item_id, token=None, revision=None): """ Get the metadata associated with an item. :param item_id: The id of the item for which metadata will be returned :type item_id: int | long :param token: (optional) A valid token for the user in question. ...
Set the metadata associated with an item.
def set_item_metadata(self, token, item_id, element, value, qualifier=None): """ Set the metadata associated with an item. :param token: A valid token for the user in question. :type token: string :param item_id: The id of the item for which metadata wi...
Share an item to the destination folder.
def share_item(self, token, item_id, dest_folder_id): """ Share an item to the destination folder. :param token: A valid token for the user in question. :type token: string :param item_id: The id of the item to be shared. :type item_id: int | long :param dest_fol...
Move an item from the source folder to the destination folder.
def move_item(self, token, item_id, src_folder_id, dest_folder_id): """ Move an item from the source folder to the destination folder. :param token: A valid token for the user in question. :type token: string :param item_id: The id of the item to be moved :type item_id: ...
Return all items.
def search_item_by_name(self, name, token=None): """ Return all items. :param name: The name of the item to search by. :type name: string :param token: (optional) A valid token for the user in question. :type token: None | string :returns: A list of all items wit...
Return all items with a given name and parent folder id.
def search_item_by_name_and_folder(self, name, folder_id, token=None): """ Return all items with a given name and parent folder id. :param name: The name of the item to search by. :type name: string :param folder_id: The id of the parent folder to search by. :type folder...
Return all items with a given name and parent folder name.
def search_item_by_name_and_folder_name(self, name, folder_name, token=None): """ Return all items with a given name and parent folder name. :param name: The name of the item to search by. :type name: string :param folder_name: The nam...
Create a link bitstream.
def create_link(self, token, folder_id, url, **kwargs): """ Create a link bitstream. :param token: A valid token for the user in question. :type token: string :param folder_id: The id of the folder in which to create a new item that will contain the link. The new ite...
Generate a token to use for upload.
def generate_upload_token(self, token, item_id, filename, checksum=None): """ Generate a token to use for upload. Midas Server uses a individual token for each upload. The token corresponds to the file specified and that file only. Passing the MD5 checksum allows the server to d...
Upload a file into a given item ( or just to the public folder if the item is not specified.
def perform_upload(self, upload_token, filename, **kwargs): """ Upload a file into a given item (or just to the public folder if the item is not specified. :param upload_token: The upload token (returned by generate_upload_token) :type upload_token: string :p...
Get the resources corresponding to a given query.
def search(self, search, token=None): """ Get the resources corresponding to a given query. :param search: The search criterion. :type search: string :param token: (optional) The credentials to use when searching. :type token: None | string :returns: Dictionary c...
Add a Condor DAG to the given Batchmake task.
def add_condor_dag(self, token, batchmaketaskid, dagfilename, dagmanoutfilename): """ Add a Condor DAG to the given Batchmake task. :param token: A valid token for the user in question. :type token: string :param batchmaketaskid: id of the Batchmake task f...
Add a Condor DAG job to the Condor DAG associated with this Batchmake task
def add_condor_job(self, token, batchmaketaskid, jobdefinitionfilename, outputfilename, errorfilename, logfilename, postfilename): """ Add a Condor DAG job to the Condor DAG associated with this Batchmake task :param token: A valid token for...
Extract DICOM metadata from the given item
def extract_dicommetadata(self, token, item_id): """ Extract DICOM metadata from the given item :param token: A valid token for the user in question. :type token: string :param item_id: id of the item to be extracted :type item_id: int | long :return: the item re...
Log in to get the real token using the temporary token and otp.
def mfa_otp_login(self, temp_token, one_time_pass): """ Log in to get the real token using the temporary token and otp. :param temp_token: The temporary token or id returned from normal login :type temp_token: string :param one_time_pass: The one-time pass to be sent to the unde...
Create a big thumbnail for the given bitstream with the given width. It is used as the main image of the given item and shown in the item view page.
def create_big_thumbnail(self, token, bitstream_id, item_id, width=575): """ Create a big thumbnail for the given bitstream with the given width. It is used as the main image of the given item and shown in the item view page. :param token: A valid token for the user in question....
Create a 100x100 small thumbnail for the given item. It is used for preview purpose and displayed in the preview and thumbnails sidebar sections.
def create_small_thumbnail(self, token, item_id): """ Create a 100x100 small thumbnail for the given item. It is used for preview purpose and displayed in the 'preview' and 'thumbnails' sidebar sections. :param token: A valid token for the user in question. :type token: ...
Search item metadata using Apache Solr.
def solr_advanced_search(self, query, token=None, limit=20): """ Search item metadata using Apache Solr. :param query: The Apache Lucene search query. :type query: string :param token: (optional) A valid token for the user in question. :type token: None | string ...
Associate a result item with a particular scalar value.
def associate_item_with_scalar_data(self, token, item_id, scalar_id, label): """ Associate a result item with a particular scalar value. :param token: A valid token for the user in question. :type token: string :param item_id: The id of th...
Associate a result item with a particular scalar value.
def create_submission(self, token, **kwargs): """ Associate a result item with a particular scalar value. :param token: A valid token for the user in question. :type token: string :param uuid (optional) The uuid of the submission (must be unique) :type uuid: string ...
Create a new scalar data point.
def add_scalar_data(self, token, community_id, producer_display_name, metric_name, producer_revision, submit_time, value, **kwargs): """ Create a new scalar data point. :param token: A valid token for the user in question. :type token: str...
Upload a JSON file containing numeric scoring results to be added as scalars. File is parsed and then deleted from the server.
def upload_json_results(self, token, filepath, community_id, producer_display_name, metric_name, producer_revision, submit_time, **kwargs): """ Upload a JSON file containing numeric scoring results to be added as scalars. File is parsed and...
Obtain particular version of the doc at key.
def __get_rev(self, key, version, **kwa): '''Obtain particular version of the doc at key.''' if '_doc' in kwa: doc = kwa['_doc'] else: if type(version) is int: if version == 0: order = pymongo.ASCENDING elif version == -1: order = pymongo.DESCENDING do...
Round a datetime object to a multiple of a timedelta dt: datetime. datetime object default now.
def __round_time(self, dt): """Round a datetime object to a multiple of a timedelta dt : datetime.datetime object, default now. """ round_to = self._resolution.total_seconds() seconds = (dt - dt.min).seconds rounding = (seconds + round_to / 2) // round_to * round_to return dt + timedelta(0,...
Find a hash value for the linear combination of invocation methods.
def _hashkey(self, method, url, **kwa): '''Find a hash value for the linear combination of invocation methods. ''' to_hash = ''.join([str(method), str(url), str(kwa.get('data', '')), str(kwa.get('params', '')) ]) return hashlib.md5(to_hash.encode()).hexdigest()
Connects to a Siemens S7 PLC.
def setup(self, address, rack=0, slot=1, port=102): """Connects to a Siemens S7 PLC. Connects to a Siemens S7 using the Snap7 library. See [the snap7 documentation](http://snap7.sourceforge.net/) for supported models and more details. It's not currently possible to query the de...
Connects to an Arduino UNO on serial port port.
def setup(self, port): """Connects to an Arduino UNO on serial port `port`. @throw RuntimeError can't connect to Arduino """ port = str(port) # timeout is used by all I/O operations self._serial = serial.Serial(port, 115200, timeout=2) time.sleep(2) # time to Ar...
Returns a map of nodename to average fitness value for this block. Assumes that required resources have been checked on all nodes.
def block_resource_fitnesses(self, block: block.Block): """Returns a map of nodename to average fitness value for this block. Assumes that required resources have been checked on all nodes.""" # Short-circuit! My algorithm is terrible, so it doesn't work well for the edge case where # t...
Returns a list of available drivers names.
def available_drivers(): """Returns a list of available drivers names. """ global __modules global __available if type(__modules) is not list: __modules = list(__modules) if not __available: __available = [d.ahioDriverInfo.NAME for d in __modules ...
Tries to load the driver named @arg name.
def __load_driver(name): """Tries to load the driver named @arg name. A driver is considered valid if it has a ahioDriverInfo object. It should however implement all APIs described in `ahio.abstract_driver`, as they'll be needed to use the driver. @returns the driver package, or False if it failed...
Searchs __modules for a driver named @arg name.
def __locate_driver_named(name): """Searchs __modules for a driver named @arg name. @returns the package for driver @arg name or None if one can't be found. """ global __modules if type(__modules) is not list: __modules = list(__modules) ms = [d for d in __modules if d.ahioDriverInfo....
Maps a pin number to a physical device pin.
def map_pin(self, abstract_pin_id, physical_pin_id): """Maps a pin number to a physical device pin. To make it easy to change drivers without having to refactor a lot of code, this library does not use the names set by the driver to identify a pin. This function will map a number, that ...
Interpolates input and output values for pin.
def set_pin_interpolation(self, pin, read_min, read_max, write_min, write_max): """Interpolates input and output values for `pin`. Changes the output and...
Sets pin pin to direction.
def set_pin_direction(self, pin, direction): """Sets pin `pin` to `direction`. The pin should support the requested mode. Calling this function on a unmapped pin does nothing. Calling it with a unsupported direction throws RuntimeError. If you're developing a driver, you should...
Gets the ahio. Direction this pin was set to.
def pin_direction(self, pin): """Gets the `ahio.Direction` this pin was set to. If you're developing a driver, implement _pin_direction(self, pin) @arg pin the pin you want to see the mode @returns the `ahio.Direction` the pin is set to @throw KeyError if pin isn't mapped. ...
Sets pin pin to type.
def set_pin_type(self, pin, ptype): """Sets pin `pin` to `type`. The pin should support the requested mode. Calling this function on a unmapped pin does nothing. Calling it with a unsupported mode throws RuntimeError. If you're developing a driver, you should implement ...
Gets the ahio. PortType this pin was set to.
def pin_type(self, pin): """Gets the `ahio.PortType` this pin was set to. If you're developing a driver, implement _pin_type(self, pin) @arg pin the pin you want to see the mode @returns the `ahio.PortType` the pin is set to @throw KeyError if pin isn't mapped. """ ...
Sets the output to the given value.
def write(self, pin, value, pwm=False): """Sets the output to the given value. Sets `pin` output to given value. If the pin is in INPUT mode, do nothing. If it's an analog pin, value should be in write_range. If it's not in the allowed range, it will be clamped. If pin is in dig...
Reads value from pin pin.
def read(self, pin): """Reads value from pin `pin`. Returns the value read from pin `pin`. If it's an analog pin, returns a number in analog.input_range. If it's digital, returns `ahio.LogicValue`. If you're developing a driver, implement _read(self, pin) @arg pin the ...
Sets the analog reference to reference
def set_analog_reference(self, reference, pin=None): """Sets the analog reference to `reference` If the driver supports per pin reference setting, set pin to the desired reference. If not, passing None means set to all, which is the default in most hardware. If only per pin reference is...
Returns the analog reference.
def analog_reference(self, pin=None): """Returns the analog reference. If the driver supports per pin analog reference setting, returns the reference for pin `pin`. If pin is None, returns the global analog reference. If only per pin reference is supported and pin is None, raise...
Sets PWM frequency if supported by hardware
def set_pwm_frequency(self, frequency, pin=None): """Sets PWM frequency, if supported by hardware If the driver supports per pin frequency setting, set pin to the desired frequency. If not, passing None means set to all. If only per pin frequency is supported and pin is None, raise Runt...
priority ( - 2 - 1 0 1 2 ) sound ( bike bugle cashregister classical cosmic falling gamelan incoming intermission magic mechanical pianobar siren spacealarm tugboat alien climb persistent echo updown none )
def notify(self, message, title="", **kwargs): """ priority (-2 -1 0 1 2) sound (bike,bugle,cashregister,classical,cosmic,falling,gamelan, incoming,intermission,magic,mechanical,pianobar,siren,spacealarm, tugboat,alien,climb,persistent,echo,updown,none) """ ...
Integrate SIR epidemic model
def SIRode(y0, time, beta, gamma): """Integrate SIR epidemic model Simulate a very basic deterministic SIR system. :param 2x1 numpy array y0: initial conditions :param Ntimestep length numpy array time: Vector of time points that \ solution is returned at :param float beta: transmission rate ...
Return the URL of the server.
def url(self): """ Return the URL of the server. :returns: URL of the server :rtype: string """ if len(self.drivers) > 0: return self.drivers[0].url else: return self._url
Returns an estimate for the maximum amount of memory to be consumed by numpy arrays.
def guess_array_memory_usage( bam_readers, dtype, use_strand=False ): """Returns an estimate for the maximum amount of memory to be consumed by numpy arrays.""" ARRAY_COUNT = 5 if not isinstance( bam_readers, list ): bam_readers = [ bam_readers ] if isinstance( dtype, basestring ): dtype...
Detect the version of the Raspberry Pi. Returns either 1 2 or None depending on if it s a Raspberry Pi 1 ( model A B A + B + ) Raspberry Pi 2 ( model B + ) or not a Raspberry Pi. https:// github. com/ adafruit/ Adafruit_Python_GPIO/ blob/ master/ Adafruit_GPIO/ Platform. py
def pi_version(): """Detect the version of the Raspberry Pi. Returns either 1, 2 or None depending on if it's a Raspberry Pi 1 (model A, B, A+, B+), Raspberry Pi 2 (model B+), or not a Raspberry Pi. https://github.com/adafruit/Adafruit_Python_GPIO/blob/master/Adafruit_GPIO/Platform.py """ if no...
commands. getoutput () replacement that also works on windows.
def system(command, input=None): """commands.getoutput() replacement that also works on windows. Code mostly copied from zc.buildout. """ logger.debug("Executing command: %s", command) p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE...
Create coverage reports and open them in the browser.
def main(): """Create coverage reports and open them in the browser.""" usage = "Usage: %prog PATH_TO_PACKAGE" parser = optparse.OptionParser(usage=usage) parser.add_option( "-v", "--verbose", action="store_true", dest="verbose", default=False, help="Show debug output") parse...
Start a Modbus server.
def setup( self, configuration="ModbusSerialClient(method='rtu',port='/dev/cu.usbmodem14101',baudrate=9600)" ): """Start a Modbus server. The following classes are available with their respective named parameters: ModbusTcpClient host: Th...
Connects to server at address: port.
def setup(self, address, port): """Connects to server at `address`:`port`. Connects to a TCP server listening at `address`:`port` that implements the protocol described in the file "Generic TCP I:O Protocol.md" @arg address IP or address to connect to. @arg port port to connect...
Return an exception given status and error codes.
def get_exception_from_status_and_error_codes(status_code, error_code, value): """ Return an exception given status and error codes. :param status_code: HTTP status code. :type status_code: None | int :param error_code: Midas Server error code. :type error_code: None | int :param value: Mes...
Retrieve the last analog data value received for the specified pin.
def analog_read(self, pin): """ Retrieve the last analog data value received for the specified pin. :param pin: Selected pin :return: The last value entered into the analog response table. """ with self.data_lock: data = self._command_handler.analog_response...
Set the specified pin to the specified value.
def analog_write(self, pin, value): """ Set the specified pin to the specified value. :param pin: Pin number :param value: Pin value :return: No return value """ if self._command_handler.ANALOG_MESSAGE + pin < 0xf0: command = [self._command_handler...
This method will close the transport ( serial port ) and exit: return: No return value but sys. exit ( 0 ) is called.
def close(self): """ This method will close the transport (serial port) and exit :return: No return value, but sys.exit(0) is called. """ self._command_handler.system_reset() self._command_handler.stop() self.transport.stop() self.transport.close() ...
Retrieve the last digital data value received for the specified pin. NOTE: This command will return values for digital pwm etc pin types
def digital_read(self, pin): """ Retrieve the last digital data value received for the specified pin. NOTE: This command will return values for digital, pwm, etc, pin types :param pin: Selected pin :return: The last value entered into the digital response table. """ ...
Set the specified pin to the specified value.
def digital_write(self, pin, value): """ Set the specified pin to the specified value. :param pin: pin number :param value: pin value :return: No return value """ # The command value is not a fixed value, but needs to be calculated using the # pin's por...
Disables analog reporting for a single analog pin.
def disable_analog_reporting(self, pin): """ Disables analog reporting for a single analog pin. :param pin: Analog pin number. For example for A0, the number is 0. :return: No return value """ command = [self._command_handler.REPORT_ANALOG + pin, self.REPORTING_DISABLE]...
Disables digital reporting. By turning reporting off for this pin reporting is disabled for all 8 bits in the port -
def disable_digital_reporting(self, pin): """ Disables digital reporting. By turning reporting off for this pin, reporting is disabled for all 8 bits in the "port" - :param pin: Pin and all pins for this port :return: No return value """ port = pin // 8 ...
Enables analog reporting. By turning reporting on for a single pin.
def enable_analog_reporting(self, pin): """ Enables analog reporting. By turning reporting on for a single pin. :param pin: Analog pin number. For example for A0, the number is 0. :return: No return value """ command = [self._command_handler.REPORT_ANALOG + pin, self.RE...
Enables digital reporting. By turning reporting on for all 8 bits in the port - this is part of Firmata s protocol specification.
def enable_digital_reporting(self, pin): """ Enables digital reporting. By turning reporting on for all 8 bits in the "port" - this is part of Firmata's protocol specification. :param pin: Pin and all pins for this port :return: No return value """ port = pin //...
This command enables the rotary encoder ( 2 pin + ground ) and will enable encoder reporting.
def encoder_config(self, pin_a, pin_b, cb=None): """ This command enables the rotary encoder (2 pin + ground) and will enable encoder reporting. NOTE: This command is not currently part of standard arduino firmata, but is provided for legacy support of CodeShield on an Arduino U...
This method will send an extended data analog output command to the selected pin
def extended_analog(self, pin, data): """ This method will send an extended data analog output command to the selected pin :param pin: 0 - 127 :param data: 0 - 0xfffff """ analog_data = [pin, data & 0x7f, (data >> 7) & 0x7f, (data >> 14) & 0x7f] self._command_ha...
This method returns the results of a previous call to pin_state_query () and then resets the pin state query data to None
def get_pin_state_query_results(self): """ This method returns the results of a previous call to pin_state_query() and then resets the pin state query data to None :return: Raw pin state query data """ r_data = self._command_handler.last_pin_query_results self._c...
Get the stepper library version number.
def get_stepper_version(self, timeout=20): """ Get the stepper library version number. :param timeout: specify a time to allow arduino to process and return a version :return: the stepper version number if it was set. """ # get current time start_time = time.tim...
NOTE: THIS METHOD MUST BE CALLED BEFORE ANY I2C REQUEST IS MADE This method initializes Firmata for I2c operations. It allows setting of a read time delay amount and to optionally track the pins as I2C in the appropriate response table. To track pins: Set the pin_type to ANALOG or DIGITAL and provide the pin numbers. I...
def i2c_config(self, read_delay_time=0, pin_type=None, clk_pin=0, data_pin=0): """ NOTE: THIS METHOD MUST BE CALLED BEFORE ANY I2C REQUEST IS MADE This method initializes Firmata for I2c operations. It allows setting of a read time delay amount, and to optionally track the pins a...
This method requests the read of an i2c device. Results are retrieved by a call to i2c_get_read_data (). If a callback method is provided when data is received from the device it will be sent to the callback method
def i2c_read(self, address, register, number_of_bytes, read_type, cb=None): """ This method requests the read of an i2c device. Results are retrieved by a call to i2c_get_read_data(). If a callback method is provided, when data is received from the device it will be sent to the callback ...
Write data to an i2c device.
def i2c_write(self, address, *args): """ Write data to an i2c device. :param address: i2c device address :param args: A variable number of bytes to be sent to the device """ data = [address, self.I2C_WRITE] for item in args: data.append(item & 0x7f) ...
This method stops an I2C_READ_CONTINUOUSLY operation for the i2c device address specified.
def i2c_stop_reading(self, address): """ This method stops an I2C_READ_CONTINUOUSLY operation for the i2c device address specified. :param address: address of i2c device """ data = [address, self.I2C_STOP_READING] self._command_handler.send_sysex(self._command_handler.I2...
This method retrieves the i2c read data as the result of an i2c_read () command.
def i2c_get_read_data(self, address): """ This method retrieves the i2c read data as the result of an i2c_read() command. :param address: i2c device address :return: raw data read from device """ if address in self._command_handler.i2c_map: map_entry = self....
This method issues a pin state query command. Data returned is retrieved via a call to get_pin_state_query_results (): param pin: pin number
def pin_state_query(self, pin): """ This method issues a pin state query command. Data returned is retrieved via a call to get_pin_state_query_results() :param pin: pin number """ self._command_handler.send_sysex(self._command_handler.PIN_STATE_QUERY, [pin])
This method will call the Tone library for the selected pin. If the tone command is set to TONE_TONE then the specified tone will be played. Else if the tone command is TONE_NO_TONE then any currently playing tone will be disabled. It is intended for a future release of Arduino Firmata
def play_tone(self, pin, tone_command, frequency, duration): """ This method will call the Tone library for the selected pin. If the tone command is set to TONE_TONE, then the specified tone will be played. Else, if the tone command is TONE_NO_TONE, then any currently playing tone will b...
This method will query firmata for the report version. Retrieve the report version via a call to get_firmata_version ()
def refresh_report_version(self): """ This method will query firmata for the report version. Retrieve the report version via a call to get_firmata_version() """ command = [self._command_handler.REPORT_VERSION] self._command_handler.send_command(command)
This command sends a reset message to the Arduino. The response tables will be reinitialized: return: No return value.
def reset(self): """ This command sends a reset message to the Arduino. The response tables will be reinitialized :return: No return value. """ # set all output pins to a value of 0 for pin in range(0, self._command_handler.total_pins_discovered): if self._com...
This method arms an analog pin for its data to be latched and saved in the latching table If a callback method is provided when latching criteria is achieved the callback function is called with latching data notification. In that case the latching table is not updated.
def set_analog_latch(self, pin, threshold_type, threshold_value, cb=None): """ This method "arms" an analog pin for its data to be latched and saved in the latching table If a callback method is provided, when latching criteria is achieved, the callback function is called with latching d...
This method arms a digital pin for its data to be latched and saved in the latching table If a callback method is provided when latching criteria is achieved the callback function is called with latching data notification. In that case the latching table is not updated.
def set_digital_latch(self, pin, threshold_type, cb=None): """ This method "arms" a digital pin for its data to be latched and saved in the latching table If a callback method is provided, when latching criteria is achieved, the callback function is called with latching data notification...
This method sets a pin to the desired pin mode for the pin_type. It automatically enables data reporting. NOTE: DO NOT CALL THIS METHOD FOR I2C. See i2c_config ().
def set_pin_mode(self, pin, mode, pin_type, cb=None): """ This method sets a pin to the desired pin mode for the pin_type. It automatically enables data reporting. NOTE: DO NOT CALL THIS METHOD FOR I2C. See i2c_config(). :param pin: Pin number (for analog use the analog number, ...
This method sends the desired sampling interval to Firmata. Note: Standard Firmata will ignore any interval less than 10 milliseconds
def set_sampling_interval(self, interval): """ This method sends the desired sampling interval to Firmata. Note: Standard Firmata will ignore any interval less than 10 milliseconds :param interval: Integer value for desired sampling interval in milliseconds :return: No return ...
Configure a pin as a servo pin. Set pulse min max in ms.
def servo_config(self, pin, min_pulse=544, max_pulse=2400): """ Configure a pin as a servo pin. Set pulse min, max in ms. :param pin: Servo Pin. :param min_pulse: Min pulse width in ms. :param max_pulse: Max pulse width in ms. :return: No return value """ ...
Configure the pins ping interval and maximum distance for an HC - SR04 type device. Single pin configuration may be used. To do so set both the trigger and echo pins to the same value. Up to a maximum of 6 SONAR devices is supported If the maximum is exceeded a message is sent to the console and the request is ignored....
def sonar_config(self, trigger_pin, echo_pin, cb=None, ping_interval=50, max_distance=200): """ Configure the pins,ping interval and maximum distance for an HC-SR04 type device. Single pin configuration may be used. To do so, set both the trigger and echo pins to the same value. Up to a ...
Configure stepper motor prior to operation.
def stepper_config(self, steps_per_revolution, stepper_pins): """ Configure stepper motor prior to operation. :param steps_per_revolution: number of steps per motor revolution :param stepper_pins: a list of control pin numbers - either 4 or 2 """ data = [self.STEPPER_CO...
Move a stepper motor for the number of steps at the specified speed
def stepper_step(self, motor_speed, number_of_steps): """ Move a stepper motor for the number of steps at the specified speed :param motor_speed: 21 bits of data to set motor speed :param number_of_steps: 14 bits for number of steps & direction positive ...
Request the stepper library version from the Arduino. To retrieve the version after this command is called call get_stepper_version
def stepper_request_library_version(self): """ Request the stepper library version from the Arduino. To retrieve the version after this command is called, call get_stepper_version """ data = [self.STEPPER_LIBRARY_VERSION] self._command_handler.send_sysex(self._com...
open the serial port using the configuration data returns a reference to this instance
def open(self, verbose): """ open the serial port using the configuration data returns a reference to this instance """ # open a serial port if verbose: print('\nOpening Arduino Serial port %s ' % self.port_id) try: # in case the port is ...
write the data to the serial port return: None
def write(self, data): """ write the data to the serial port return: None """ if sys.version_info[0] < 3: self.arduino.write(data) else: self.arduino.write(bytes([ord(data)]))
This method continually runs. If an incoming character is available on the serial port it is read and placed on the _command_deque
def run(self): """ This method continually runs. If an incoming character is available on the serial port it is read and placed on the _command_deque @return: Never Returns """ while not self.is_stopped(): # we can get an OSError: [Errno9] Bad file descriptor ...
Set the user s desired blink rate ( 0 - 3 )
def set_blink_rate(self, b): """ Set the user's desired blink rate (0 - 3) @param b: blink rate """ if b > 3: b = 0 # turn off if not sure self.firmata.i2c_write(self.board_address, (self.HT16K33_BLINK_CMD | self.HT16K33_BLINK_D...