Skip to content

Commit 75e2042

Browse files
committed
more documentation; command line switch for debugging messages; improved response time when UART connected
1 parent 6312ac4 commit 75e2042

File tree

4 files changed

+66
-23
lines changed

4 files changed

+66
-23
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
# AutoSTAR_remote
2-
This is a GUI to remote control (using ASCOM) the Meade AutoSTAR #497 handheld.
2+
This is a GUI to remote control (using ASCOM or serial interface) the Meade AutoSTAR #497 handheld.
33

44
![screenshot](AutoSTAR_remote_V1.0.png)
55

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

8+
You can change the serial port parameters when connecting with UART. Default parameters for the MEADE AutoSTAR #497 are:
9+
- Speed: 9600 baud
10+
- 8 data bits
11+
- 1 stop bit
12+
- no parity
13+
- no flow control
14+
15+
When connecting with the serial port you have the option to set the time and date of the AutoSTAR to the computer clock. This feature is not fully tested. Especially the daylight saving may be wrong. Please check the AutoSTAR settings if you see strange errors when doing GOTO to an object.
16+
817
The compiled binary just needs to be unpacked. No installation and no Python is needed. ASCOM driver https://bitbucket.org/cjdskunkworks/meadeautostar497 must be installed and off course you need to connect your #497 AutoSTAR with your computer.
18+
19+
For running the Python source code you need the following packages:
20+
- PyQt5
21+
- pyserial
22+
- win32com when using ASCOM on Windows
23+
24+
The Python source code runs also on Raspberry Pi (Astroberry).

src/ASCOM.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88

99
class ASCOM:
1010

11-
def __init__(self):
11+
def __init__(self, showDebugMessages=False):
1212
self.Telescope = None
1313
self.Name = ""
14+
#
15+
self.showDebugMessages = showDebugMessages
16+
17+
def dbgMsg(self, msg):
18+
if self.showDebugMessages:
19+
print(f'DEBUG: {msg}')
1420

1521
def open(self):
1622
self.close()
@@ -48,10 +54,11 @@ def close(self):
4854

4955
def sendCommandBlind(self, cmd):
5056
if self.is_open():
57+
self.dbgMsg(f'sendCommandBlind: {cmd}')
5158
try:
5259
ret = self.Telescope.CommandBlind(cmd, False)
5360
except win32com.client.pywintypes.com_error as e:
54-
print(f'sendCommandBlind: {e}')
61+
print(f'ERROR in sendCommandBlind: {e}')
5562
return None
5663
else:
5764
return ret
@@ -88,6 +95,6 @@ def get_LCD(self):
8895
# send the LCD contents before the ASCOM driver trows a timeout exception.
8996
# Here we catch these timeout exceptions.
9097
print(f'ERROR in get_LCD: {e}')
91-
#print(f'sendCommandString response: {Response}')
98+
self.dbgMsg(f'get_LCD response: ED --> {Response}')
9299
return Response[1:].translate(self.CharacterTranslationTable)
93100
return None

src/AutoSTAR_remote.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
theme_selection = "Dark" # "Dark", "Light"
2323
LCD_polling_time = 1000 # milliseconds
24-
LCD_earlyUpdate_time = 200 # milliseconds
24+
LCD_earlyUpdate_time = 50 # milliseconds
2525

2626
"""
2727
By watching the RS232 communication of the AutoStart Suit telescope control I found the following commands:
@@ -58,6 +58,8 @@
5858
"""
5959

6060
"""
61+
How the ASCOM driver sets time and date:
62+
6163
21:06:26.686 UTCDate Set - 11.22.22 20:06:26
6264
21:06:26.686 SendString Transmitting #:GG#
6365
21:06:26.704 SendString Received -01
@@ -73,8 +75,9 @@ class MainWin(QtWidgets.QMainWindow):
7375
AutoSTAR_remote main window.
7476
"""
7577

76-
def __init__(self):
78+
def __init__(self, showDebugMessages=False):
7779
super(MainWin, self).__init__()
80+
self.showDebugMessages = showDebugMessages
7881
self.ui = AutoSTAR_remote_ui.Ui_MainWindow()
7982
self.ui.setupUi(self)
8083
self.setWindowTitle(f'AutoSTAR_remote {version}')
@@ -87,7 +90,7 @@ def __init__(self):
8790
self.Interface = None
8891
# persistent settings
8992
self.Settings = QtCore.QSettings()
90-
print(f'QSettings file: {self.Settings.fileName()}')
93+
self.dbgMsg(f'QSettings file: {self.Settings.fileName()}')
9194
# LCD polling timer
9295
self.PollingTimer = QtCore.QTimer()
9396
self.PollingTimer.setSingleShot(True)
@@ -127,6 +130,10 @@ def __init__(self):
127130
self.ui.pushButton_FocOut.pressed.connect(lambda: self.sendCommandBlind("F+"))
128131
self.ui.pushButton_FocOut.released.connect(lambda: self.sendCommandBlind("FQ"))
129132

133+
def dbgMsg(self, msg):
134+
if self.showDebugMessages:
135+
print(f'DEBUG: {msg}')
136+
130137
@QtCore.pyqtSlot()
131138
def closeEvent(self, event):
132139
self.PollingTimer.stop()
@@ -151,7 +158,7 @@ def update_GuiOpenInterface(self):
151158

152159
@QtCore.pyqtSlot()
153160
def on_actionconnect_ASCOM_triggered(self):
154-
self.Interface = ASCOM.ASCOM()
161+
self.Interface = ASCOM.ASCOM(showDebugMessages=self.showDebugMessages)
155162
self.Interface.open()
156163
if self.Interface.is_open():
157164
self.update_GuiOpenInterface()
@@ -162,10 +169,9 @@ def on_actionconnect_ASCOM_triggered(self):
162169
@QtCore.pyqtSlot()
163170
def on_actionconnect_UART_triggered(self):
164171
Parameter = {k: self.Settings.value(k) for k in self.Settings.allKeys()}
165-
self.Interface = UART.UART(Parameter=Parameter)
172+
self.Interface = UART.UART(Parameter=Parameter, showDebugMessages=self.showDebugMessages)
166173
self.Interface.open()
167174
if self.Interface.is_open():
168-
print("DBG: UART is open")
169175
Parameter = self.Interface.get_Parameter()
170176
for k, v in Parameter.items():
171177
self.Settings.setValue(k, v)
@@ -221,11 +227,10 @@ def updateLCD(self):
221227
Line1 = LcdText[0:16]
222228
Line2 = LcdText[16:]
223229
self.ui.plainTextEdit_LCD.setPlainText(f'{Line1}\n{Line2}')
224-
# print(f'{Unknown}: >{Line1}< >{Line2}<')
225230
# print(", ".join([f'{ord(c):02X}' for c in LcdText]))
226231
# print(bytes(LcdText, 'utf-8'))
227232
else:
228-
print('DBG: no response from get_LCD.')
233+
self.dbgMsg('No response from get_LCD.')
229234
if self.ui.actionpoll.isChecked():
230235
if not self.PollingTimer.isActive():
231236
self.PollingTimer.setInterval(LCD_polling_time)
@@ -247,6 +252,11 @@ def on_actionpoll_toggled(self, isChecked):
247252

248253
# Start Qt event loop unless running in interactive mode.
249254
def main():
255+
import argparse
256+
parser = argparse.ArgumentParser(description="remote control for MEADE AutoSTAR #497")
257+
parser.add_argument("-d", "--debug", action="store_true",
258+
help="enable debug messages")
259+
args = parser.parse_args()
250260
# build application
251261
App = QtWidgets.QApplication(sys.argv)
252262
App.setOrganizationName("GeierSoft")
@@ -284,7 +294,7 @@ def main():
284294
else:
285295
pass
286296
#
287-
MainWindow = MainWin()
297+
MainWindow = MainWin(showDebugMessages=args.debug)
288298
# MainWindow.resize(1400, 900)
289299
MainWindow.show()
290300
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):

src/UART.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class UART(QtWidgets.QDialog):
1616

17-
def __init__(self, Parameter={}):
17+
def __init__(self, Parameter={}, showDebugMessages=False):
1818
super().__init__()
1919
self.ui = UART_ui.Ui_Dialog()
2020
self.ui.setupUi(self)
@@ -37,6 +37,12 @@ def __init__(self, Parameter={}):
3737
# no port opened
3838
self.PortHandle = None
3939
self.Name = ""
40+
#
41+
self.showDebugMessages = showDebugMessages
42+
43+
def dbgMsg(self, msg):
44+
if self.showDebugMessages:
45+
print(f'DEBUG: {msg}')
4046

4147
def get_Parameter(self):
4248
Parameter = {
@@ -117,20 +123,22 @@ def initializeCommunication(self):
117123
# Attempting manual bypass of prompts
118124
for i in range(10):
119125
self.sendCommandBlind("EK9")
120-
self.sendCommandString("ED")
126+
self.get_LCD()
121127
# set date and time
122128
if self.ui.checkBox_SetTimeDate.isChecked():
123129
# TODO: make this aware of the daylight saving setting of the controller!
124130
now = datetime.datetime.now()
125131
time = now.strftime("%H:%M:%S")
126-
self.PortHandle.write(f'#:SL{time}#'.encode("ascii"))
132+
cmd = f'#:SL{time}#'.encode("ascii")
133+
self.PortHandle.write(cmd)
127134
Response = self.PortHandle.read(size=1)
128-
print(f'DBG: #:SL{time}# --> {Response}')
135+
self.dbgMsg(f'{cmd} --> {Response}')
129136
# MM/DD/YY
130-
date = now.strftime("%m/%d/%y")
131-
self.PortHandle.write(f'#:SC{date}#'.encode("ascii"))
132-
Response = self.PortHandle.read(size=1)
133-
print(f'DBG: #:SC{date}# --> {Response}')
137+
date = now.strftime("%m.%d.%y")
138+
cmd = f'#:SC{date}#'.encode("ascii")
139+
self.PortHandle.write(cmd)
140+
Response = self.PortHandle.read(size=66)
141+
self.dbgMsg(f'{cmd} --> {Response}')
134142

135143
def is_open(self):
136144
if self.PortHandle is not None:
@@ -148,6 +156,8 @@ def sendCommandBlind(self, cmd):
148156
if self.is_open():
149157
MeadeCmd = f'#:{cmd}#'.encode("ascii")
150158
self.PortHandle.write(MeadeCmd)
159+
self.PortHandle.flush()
160+
self.dbgMsg(f'sendCommandBlind: {MeadeCmd}')
151161

152162
# The :ED# command sends the LCD contents, coded with the char table of the SED1233 LCD controller.
153163
# For any reason the COM interface or the win32com transforms this into unicode. Unfortunately the
@@ -174,10 +184,10 @@ def sendCommandBlind(self, cmd):
174184
def get_LCD(self):
175185
if self.is_open():
176186
MeadeCmd = b'#:ED#'
177-
#print(f'sendCommandString command: {MeadeCmd}')
178187
self.PortHandle.write(MeadeCmd)
188+
self.PortHandle.flush()
179189
Response = self.PortHandle.read_until(b"#")
180-
print(f'DBG: get_LCD response: {Response}')
190+
self.dbgMsg(f'get_LCD response: {MeadeCmd} --> {Response}')
181191
Response = Response[1:].rstrip(b"#")
182192
Response = Response.decode("latin-1")
183193
return Response.translate(self.CharacterTranslationTable)

0 commit comments

Comments
 (0)