Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Commit

Permalink
Version 2.16 Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterYsLab@gmail.com committed Aug 24, 2016
1 parent 988af2e commit 1487c16
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
9 changes: 9 additions & 0 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## Release 2.16

24 Auguts 2016

* This is a minor bug fix release

* Added a 2 second timeout for retrieiving Firmata Firmware Verison
* If the request times out, the application will exit since there is no connectivity to the Arduino.

## Release 2.15

31 July 2016
Expand Down
2 changes: 1 addition & 1 deletion pymata_aio/private_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PrivateConstants:
SYSEX_REALTIME = 0x7F # MIDI Reserved for realtime messages

# reserved for PyMata
PYMATA_VERSION = "2.15"
PYMATA_VERSION = "2.16"

# each byte represents a digital port
# and its value contains the current port settings
Expand Down
33 changes: 33 additions & 0 deletions pymata_aio/pymata_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,35 @@ async def start_aio(self):

# get arduino firmware version and print it
firmware_version = await self.get_firmware_version()
if not firmware_version:
if self.log_output:
log_string = '*** Firmware Version retrieval timed out. ***'

logging.exception(log_string)
log_string = '\nDo you have Arduino connectivity and do you ' \
'have a Firmata sketch uploaded to the board?'
logging.exception(log_string)

else:
print('*** Firmware Version retrieval timed out. ***')
print('\nDo you have Arduino connectivity and do you have a '
'Firmata sketch uploaded to the board?')
try:
loop = self.loop
for t in asyncio.Task.all_tasks(loop):
t.cancel()
loop.run_until_complete(asyncio.sleep(.1))
loop.stop()
loop.close()
sys.exit(0)
except RuntimeError:
self.the_task.cancel()
time.sleep(1)
# this suppresses the Event Loop Is Running message,
# which may be a bug in python 3.4.3
sys.exit(0)
except TypeError:
sys.exit(0)
if self.log_output:
log_string = "\nArduino Firmware ID: " + firmware_version
logging.exception(log_string)
Expand Down Expand Up @@ -720,10 +749,14 @@ async def get_firmware_version(self):
:returns: Firmata firmware version
"""
current_time = time.time()
if self.query_reply_data.get(PrivateConstants.REPORT_FIRMWARE) == '':
await self._send_sysex(PrivateConstants.REPORT_FIRMWARE, None)
while self.query_reply_data.get(
PrivateConstants.REPORT_FIRMWARE) == '':
elapsed_time = time.time()
if elapsed_time - current_time > 2:
return None
await asyncio.sleep(self.sleep_tune)
reply = ''
for x in self.query_reply_data.get(PrivateConstants.REPORT_FIRMWARE):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pymata-aio',
version='2.15',
version='2.16',
packages=['pymata_aio'],
install_requires=['pyserial==2.7', 'websockets'],
url='https://github.com/MrYsLab/pymata-aio/wiki',
Expand Down

0 comments on commit 1487c16

Please sign in to comment.