From 5efe7bbfd78edd7ffeda1ba2a4af7a0329a9d90e Mon Sep 17 00:00:00 2001 From: MrYsLab Date: Sat, 20 Oct 2018 10:08:04 -0400 Subject: [PATCH] Version 2.26 changes --- documentation/changelog.md | 24 ++++++++++++++++-------- pymata_aio/private_constants.py | 2 +- pymata_aio/pymata_core.py | 28 ++++++++++++++++------------ setup.py | 2 +- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/documentation/changelog.md b/documentation/changelog.md index 5bdc8c1..ebadd32 100644 --- a/documentation/changelog.md +++ b/documentation/changelog.md @@ -1,5 +1,13 @@ # Change Log +## Release 2.26 +20 October 2018 + +* Incorporates changes for issues #82, 83, and 84 +* Default arduino_wait time increased from 2 to 4 seconds +* Timeout in get_firmware_version increased to 4 seconds + + ## Release 2.25 23 August 2018 @@ -29,8 +37,8 @@ ## Release 2.20 16 April 2018 -Modified comments to generate pdoc API documentation. -No functional changes. +* Modified comments to generate pdoc API documentation. +* No functional changes. 8 April 2018 @@ -67,7 +75,7 @@ No functional changes. * This release is now fully compatible with StandardFirmata 2.5.3 * On-Line API Documents Updated to reflect new command - + * Update pymata_iot.py to use websockets instead of autobahn. * setup.py added dependency of websockets and removed autobahn/txaio dependencies @@ -132,7 +140,7 @@ No functional changes. * [Pixy Cam](http://charmedlabs.com/default/pixy-cmucam5/) support courtesy of Dave Fisher and Leigh Andrew Mathews of the [Rose Hulman Institute of Technology](http://www.rose-hulman.edu/) * pymata_core and pymata3 updated for Pixy Cam support * A new firmata sketch, FirmataPlusRBPixy has been added to the Arduino libraries - + ### Updates * All FirmataPlus sketches have been updated for the latest dependencies libraries * The sleep_tune paramater default was modified to 0.0001 for pymata_core and added to pymata3 @@ -234,7 +242,7 @@ FirmataPlusRB updated to report encoder readings every 100 ms. * Callbacks for both pymata_core and pymata3 can selected to be either asyncio coroutines or direct calls. * Default is direct call. - + * Option provided in encoder_config() for support of hall effect wheel encoders. * Minor bug fixes. @@ -261,7 +269,7 @@ FirmataPlusRB updated to report encoder readings every 100 ms. 19 July 2015 -Data format returned from i2c_read_request was normalized from Firmata 2byte format to expected data +Data format returned from i2c_read_request was normalized from Firmata 2byte format to expected data representation. @@ -279,5 +287,5 @@ representation. * FirmataPlus updated to be in sync with StandardFirmata 2.4.3 * Updated private_constants.py and constants.py to be consistent with StandardFirmata 2.4.3 - - + + diff --git a/pymata_aio/private_constants.py b/pymata_aio/private_constants.py index bdf2b64..fb635c0 100644 --- a/pymata_aio/private_constants.py +++ b/pymata_aio/private_constants.py @@ -70,7 +70,7 @@ class PrivateConstants: SYSEX_REALTIME = 0x7F # MIDI Reserved for realtime messages # reserved for PyMata - PYMATA_VERSION = "2.25" + PYMATA_VERSION = "2.26" # each byte represents a digital port # and its value contains the current port settings diff --git a/pymata_aio/pymata_core.py b/pymata_aio/pymata_core.py index 4827831..d4364d1 100644 --- a/pymata_aio/pymata_core.py +++ b/pymata_aio/pymata_core.py @@ -44,7 +44,7 @@ class PymataCore: perform Arduino pin auto-detection. """ - def __init__(self, arduino_wait=2, sleep_tune=0.0001, log_output=False, + def __init__(self, arduino_wait=4, sleep_tune=0.0001, log_output=False, com_port=None, ip_address=None, ip_port=2000, ip_handshake='*HELLO*'): """ @@ -294,12 +294,16 @@ def start(self): self.the_task = self.loop.create_task(self._command_dispatcher()) # get arduino firmware version and print it - firmware_version = self.loop.run_until_complete(self.get_firmware_version()) - if self.log_output: - log_string = "\nArduino Firmware ID: " + firmware_version - logging.exception(log_string) - else: - print("\nArduino Firmware ID: " + firmware_version) + try: + firmware_version = self.loop.run_until_complete(self.get_firmware_version()) + if self.log_output: + log_string = "\nArduino Firmware ID: " + firmware_version + logging.exception(log_string) + else: + print("\nArduino Firmware ID: " + firmware_version) + except TypeError: + print('Do you have the correct Firmata sketch loaded?') + sys.exit(0) # try to get an analog pin map. if it comes back as none - shutdown report = self.loop.run_until_complete(self.get_analog_map()) @@ -776,7 +780,7 @@ async def get_firmware_version(self): while self.query_reply_data.get( PrivateConstants.REPORT_FIRMWARE) == '': elapsed_time = time.time() - if elapsed_time - current_time > 2: + if elapsed_time - current_time > 4: return None await asyncio.sleep(self.sleep_tune) return self.query_reply_data.get(PrivateConstants.REPORT_FIRMWARE) @@ -987,7 +991,7 @@ async def send_reset(self): try: await self._send_command([PrivateConstants.SYSTEM_RESET]) except RuntimeError: - exit(0) + sys.exit(0) async def servo_config(self, pin, min_pulse=544, max_pulse=2400): """ @@ -1685,7 +1689,7 @@ async def _report_firmware(self, sysex_data): name = sysex_data[3:-1] firmware_name_iterator = iter(name) - + # convert each element from two 7-bit bytes into characters, then add each # character to the version string for e in firmware_name_iterator: @@ -1834,7 +1838,7 @@ def _discover_port(self): locations.append('end') # for everyone else, here is a list of possible ports else: - locations = ['dev/ttyACM0', '/dev/ttyACM0', '/dev/ttyACM1', + locations = ['/dev/ttyACM0', '/dev/ttyACM1', '/dev/ttyACM2', '/dev/ttyACM3', '/dev/ttyACM4', '/dev/ttyACM5', '/dev/ttyUSB0', '/dev/ttyUSB1', '/dev/ttyUSB2', '/dev/ttyUSB3', '/dev/ttyUSB4', @@ -1866,7 +1870,7 @@ def _discover_port(self): print('Unable to find Serial Port, Please plug in ' 'cable or check cable connections.') detected = None - exit() + sys.exit() if self.log_output: log_string = 'Using COM Port: ' + detected logging.info(log_string) diff --git a/setup.py b/setup.py index 1dadb4f..ad93366 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='pymata-aio', - version='2.25', + version='2.26', packages=['pymata_aio'], install_requires=['pyserial', 'websockets'], url='https://github.com/MrYsLab/pymata-aio/wiki',