Skip to content

Commit bb3bd5d

Browse files
committed
improved error handling; faster LCD update after key press
catching now ASCOM time out errors when handbox needs too long for calculations
1 parent bb2d4f0 commit bb3bd5d

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

AutoSTAR_remote_V1.0.png

35.7 KB
Loading

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# AutoSTAR_remote
22
This is a GUI to remote control (using ASCOM) the Meade AutoSTAR #497 handheld.
33

4+
![screenshot](AutoSTAR_remote_V1.0.png)
5+
6+
Press [SHIFT] when clicking on "ENTER", "MODE" or "GO TO" to generate a long key press.
7+
48
It requires the ASCOM driver from https://bitbucket.org/cjdskunkworks/meadeautostar497
59

src/AutoSTAR_remote.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
import AutoSTAR_remote_ui
1111

12-
version = "V1.0"
12+
version = "V1.0.1"
1313

1414
theme_selection = "Dark" # "Dark", "Light"
1515
LCD_polling_time = 1000 # milliseconds
16+
LCD_earlyUpdate_time = 200 # milliseconds
1617

1718
"""
1819
By watching the RS232 communication of the AutoStart Suit telescope control I found the following commands:
@@ -135,7 +136,9 @@ def on_actionconnect_triggered(self):
135136
self.ui.actiondisconnect.setEnabled(True)
136137
self.ui.centralwidget.setEnabled(True)
137138
if self.ui.actionpoll.isChecked():
138-
self.PollingTimer.start()
139+
if not self.PollingTimer.isActive():
140+
self.PollingTimer.setInterval(LCD_earlyUpdate_time)
141+
self.PollingTimer.start()
139142
self.ui.actionupdate_now.setEnabled(True)
140143

141144
@QtCore.pyqtSlot()
@@ -158,7 +161,13 @@ def sendAction(self, param):
158161
def sendCommandBlind(self, cmd):
159162
if self.Telescope is not None:
160163
if self.Telescope.Connected:
161-
return self.Telescope.CommandBlind(cmd, False)
164+
try:
165+
ret = self.Telescope.CommandBlind(cmd, False)
166+
except win32com.client.pywintypes.com_error as e:
167+
print(f'sendCommandBlind: {e}')
168+
return None
169+
else:
170+
return ret
162171
return None
163172

164173
def buttonAction(self, cmd, long_cmd=None):
@@ -172,9 +181,12 @@ def buttonAction(self, cmd, long_cmd=None):
172181
self.sendCommandBlind(long_cmd)
173182
else:
174183
self.sendCommandBlind(cmd)
175-
self.updateLCD()
184+
# delayed LCD update
185+
self.PollingTimer.stop()
186+
self.PollingTimer.setInterval(LCD_earlyUpdate_time)
187+
self.PollingTimer.start()
176188

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

199211
def updateLCD(self):
200-
#LcdText = self.sendAction("readdisplay")
201-
LcdText = self.Telescope.CommandString("ED", False)
212+
try:
213+
LcdText = self.Telescope.CommandString("ED", False)
214+
except win32com.client.pywintypes.com_error as e:
215+
# Sometimes the handbox needs long time for calculations and does not
216+
# send the LCD contents bfore the ASCOM driver trows a timeout exception.
217+
# Here we catch these timeout exceptions.
218+
print(f'updateLCD: {e}')
219+
LcdText = None
202220
if LcdText is not None:
203221
LcdText = LcdText.translate(self.CharacterTranslationTable)
204222
Unknown = ord(LcdText[0])
@@ -209,7 +227,9 @@ def updateLCD(self):
209227
#print(", ".join([f'{ord(c):02X}' for c in LcdText]))
210228
#print(bytes(LcdText, 'utf-8'))
211229
if self.ui.actionpoll.isChecked():
212-
self.PollingTimer.start()
230+
if not self.PollingTimer.isActive():
231+
self.PollingTimer.setInterval(LCD_polling_time)
232+
self.PollingTimer.start()
213233

214234
@QtCore.pyqtSlot()
215235
def on_actionupdate_now_triggered(self):
@@ -219,7 +239,7 @@ def on_actionupdate_now_triggered(self):
219239
def on_actionpoll_toggled(self, isChecked):
220240
if isChecked:
221241
# start polling timer
222-
self.PollingTimer.start()
242+
self.updateLCD()
223243
else:
224244
# stop polling timer
225245
self.PollingTimer.stop()

0 commit comments

Comments
 (0)