Skip to content

Commit

Permalink
improved error handling; faster LCD update after key press
Browse files Browse the repository at this point in the history
catching now ASCOM time out errors when handbox needs too long for calculations
  • Loading branch information
scriptorron committed Jul 27, 2022
1 parent bb2d4f0 commit bb3bd5d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Binary file added AutoSTAR_remote_V1.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# AutoSTAR_remote
This is a GUI to remote control (using ASCOM) the Meade AutoSTAR #497 handheld.

![screenshot](AutoSTAR_remote_V1.0.png)

Press [SHIFT] when clicking on "ENTER", "MODE" or "GO TO" to generate a long key press.

It requires the ASCOM driver from https://bitbucket.org/cjdskunkworks/meadeautostar497

38 changes: 29 additions & 9 deletions src/AutoSTAR_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

import AutoSTAR_remote_ui

version = "V1.0"
version = "V1.0.1"

theme_selection = "Dark" # "Dark", "Light"
LCD_polling_time = 1000 # milliseconds
LCD_earlyUpdate_time = 200 # milliseconds

"""
By watching the RS232 communication of the AutoStart Suit telescope control I found the following commands:
Expand Down Expand Up @@ -135,7 +136,9 @@ def on_actionconnect_triggered(self):
self.ui.actiondisconnect.setEnabled(True)
self.ui.centralwidget.setEnabled(True)
if self.ui.actionpoll.isChecked():
self.PollingTimer.start()
if not self.PollingTimer.isActive():
self.PollingTimer.setInterval(LCD_earlyUpdate_time)
self.PollingTimer.start()
self.ui.actionupdate_now.setEnabled(True)

@QtCore.pyqtSlot()
Expand All @@ -158,7 +161,13 @@ def sendAction(self, param):
def sendCommandBlind(self, cmd):
if self.Telescope is not None:
if self.Telescope.Connected:
return self.Telescope.CommandBlind(cmd, False)
try:
ret = self.Telescope.CommandBlind(cmd, False)
except win32com.client.pywintypes.com_error as e:
print(f'sendCommandBlind: {e}')
return None
else:
return ret
return None

def buttonAction(self, cmd, long_cmd=None):
Expand All @@ -172,9 +181,12 @@ def buttonAction(self, cmd, long_cmd=None):
self.sendCommandBlind(long_cmd)
else:
self.sendCommandBlind(cmd)
self.updateLCD()
# delayed LCD update
self.PollingTimer.stop()
self.PollingTimer.setInterval(LCD_earlyUpdate_time)
self.PollingTimer.start()

# The :ED# command sends the LCD contents, coded withthe char table of the SED1233 LCD controller.
# The :ED# command sends the LCD contents, coded with the char table of the SED1233 LCD controller.
# For any reason the COM interface or the win32com transforms this into unicode. Unfortunately the
# special characters of the SED1233 controller get mapped to the wrong unicode. Here we fix this
# with a translation table:
Expand All @@ -197,8 +209,14 @@ def buttonAction(self, cmd, long_cmd=None):
}

def updateLCD(self):
#LcdText = self.sendAction("readdisplay")
LcdText = self.Telescope.CommandString("ED", False)
try:
LcdText = self.Telescope.CommandString("ED", False)
except win32com.client.pywintypes.com_error as e:
# Sometimes the handbox needs long time for calculations and does not
# send the LCD contents bfore the ASCOM driver trows a timeout exception.
# Here we catch these timeout exceptions.
print(f'updateLCD: {e}')
LcdText = None
if LcdText is not None:
LcdText = LcdText.translate(self.CharacterTranslationTable)
Unknown = ord(LcdText[0])
Expand All @@ -209,7 +227,9 @@ def updateLCD(self):
#print(", ".join([f'{ord(c):02X}' for c in LcdText]))
#print(bytes(LcdText, 'utf-8'))
if self.ui.actionpoll.isChecked():
self.PollingTimer.start()
if not self.PollingTimer.isActive():
self.PollingTimer.setInterval(LCD_polling_time)
self.PollingTimer.start()

@QtCore.pyqtSlot()
def on_actionupdate_now_triggered(self):
Expand All @@ -219,7 +239,7 @@ def on_actionupdate_now_triggered(self):
def on_actionpoll_toggled(self, isChecked):
if isChecked:
# start polling timer
self.PollingTimer.start()
self.updateLCD()
else:
# stop polling timer
self.PollingTimer.stop()
Expand Down

0 comments on commit bb3bd5d

Please sign in to comment.