Skip to content

Commit b716271

Browse files
authored
Merge pull request #2 from scriptorron/support_direct_RS232_connection
Support direct rs232 connection
2 parents 2e91a25 + 75e2042 commit b716271

File tree

9 files changed

+743
-112
lines changed

9 files changed

+743
-112
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).

make_UI.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
call pyuic5 -x src\AutoSTAR_remote_ui.ui -o src\AutoSTAR_remote_ui.py
2+
call pyuic5 -x src\UART_ui.ui -o src\UART_ui.py

src/ASCOM.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
"""
2+
ASCOM interface for AutoSTAR_remote
3+
"""
4+
5+
from PyQt5 import QtWidgets
6+
import win32com.client
7+
8+
9+
class ASCOM:
10+
11+
def __init__(self, showDebugMessages=False):
12+
self.Telescope = None
13+
self.Name = ""
14+
#
15+
self.showDebugMessages = showDebugMessages
16+
17+
def dbgMsg(self, msg):
18+
if self.showDebugMessages:
19+
print(f'DEBUG: {msg}')
20+
21+
def open(self):
22+
self.close()
23+
try:
24+
Chooser = win32com.client.Dispatch("ASCOM.Utilities.Chooser")
25+
except win32com.client.pywintypes.com_error:
26+
QtWidgets.QMessageBox.critical(None, "Can not call ASCOM!",
27+
f"Is ASCOM installed?")
28+
else:
29+
Chooser.DeviceType = 'Telescope'
30+
self.Name = Chooser.Choose(None)
31+
if self.Name != "":
32+
self.Telescope = win32com.client.Dispatch(self.Name)
33+
self.Telescope.Connected = True
34+
if not self.Telescope.Connected:
35+
QtWidgets.QMessageBox.critical(None, "Can not connect to telescope!",
36+
f"Please check connection to\n{self.Name}.\nMaybe it is already in use.")
37+
self.Telescope = None
38+
39+
def get_Parameter(self):
40+
# has no parameter
41+
return dict()
42+
43+
def is_open(self):
44+
if self.Telescope is not None:
45+
if self.Telescope.Connected:
46+
return True
47+
return False
48+
49+
def close(self):
50+
if self.is_open():
51+
self.Telescope.Connected = False
52+
self.Telescope = None
53+
self.Name = ""
54+
55+
def sendCommandBlind(self, cmd):
56+
if self.is_open():
57+
self.dbgMsg(f'sendCommandBlind: {cmd}')
58+
try:
59+
ret = self.Telescope.CommandBlind(cmd, False)
60+
except win32com.client.pywintypes.com_error as e:
61+
print(f'ERROR in sendCommandBlind: {e}')
62+
return None
63+
else:
64+
return ret
65+
return None
66+
67+
# The :ED# command sends the LCD contents, coded with the char table of the SED1233 LCD controller.
68+
# For any reason the COM interface or the win32com transforms this into unicode. Unfortunately the
69+
# special characters of the SED1233 controller get mapped to the wrong unicode. Here we fix this
70+
# with a translation table:
71+
CharacterTranslationTable = {
72+
0x0d: ord('\n'),
73+
# 0x2020: ord(' '),
74+
0xDF: ord('°'),
75+
0x7E: 0x2192, # ord('>'),
76+
0x7F: 0x2190, # ord('<'),
77+
0x18: 0x2191, # ord('^'),
78+
0x19: 0x2193, # ord('v'),
79+
# bar graph symbols
80+
0x5F: 0x2582,
81+
0x81: 0x2583,
82+
0x201A: 0x2584, # raw: 0x82
83+
0x0192: 0x2585, # raw: 0x83
84+
0x201E: 0x2586, # raw: 0x84
85+
0x2026: 0x2587, # raw: 0x85
86+
0x2020: 0x2588, # raw: 0x86
87+
}
88+
89+
def get_LCD(self):
90+
if self.is_open():
91+
try:
92+
Response = self.Telescope.CommandString("ED", False)
93+
except win32com.client.pywintypes.com_error as e:
94+
# Sometimes the handbox needs long time for calculations and does not
95+
# send the LCD contents before the ASCOM driver trows a timeout exception.
96+
# Here we catch these timeout exceptions.
97+
print(f'ERROR in get_LCD: {e}')
98+
self.dbgMsg(f'get_LCD response: ED --> {Response}')
99+
return Response[1:].translate(self.CharacterTranslationTable)
100+
return None

0 commit comments

Comments
 (0)