-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from scriptorron/support_direct_RS232_connection
Support direct rs232 connection
- Loading branch information
Showing
9 changed files
with
743 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
# AutoSTAR_remote | ||
This is a GUI to remote control (using ASCOM) the Meade AutoSTAR #497 handheld. | ||
This is a GUI to remote control (using ASCOM or serial interface) the Meade AutoSTAR #497 handheld. | ||
|
||
 | ||
|
||
Press [SHIFT] when clicking on "ENTER", "MODE" or "GO TO" to generate a long key press. | ||
|
||
You can change the serial port parameters when connecting with UART. Default parameters for the MEADE AutoSTAR #497 are: | ||
- Speed: 9600 baud | ||
- 8 data bits | ||
- 1 stop bit | ||
- no parity | ||
- no flow control | ||
|
||
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. | ||
|
||
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. | ||
|
||
For running the Python source code you need the following packages: | ||
- PyQt5 | ||
- pyserial | ||
- win32com when using ASCOM on Windows | ||
|
||
The Python source code runs also on Raspberry Pi (Astroberry). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
call pyuic5 -x src\AutoSTAR_remote_ui.ui -o src\AutoSTAR_remote_ui.py | ||
call pyuic5 -x src\UART_ui.ui -o src\UART_ui.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
""" | ||
ASCOM interface for AutoSTAR_remote | ||
""" | ||
|
||
from PyQt5 import QtWidgets | ||
import win32com.client | ||
|
||
|
||
class ASCOM: | ||
|
||
def __init__(self, showDebugMessages=False): | ||
self.Telescope = None | ||
self.Name = "" | ||
# | ||
self.showDebugMessages = showDebugMessages | ||
|
||
def dbgMsg(self, msg): | ||
if self.showDebugMessages: | ||
print(f'DEBUG: {msg}') | ||
|
||
def open(self): | ||
self.close() | ||
try: | ||
Chooser = win32com.client.Dispatch("ASCOM.Utilities.Chooser") | ||
except win32com.client.pywintypes.com_error: | ||
QtWidgets.QMessageBox.critical(None, "Can not call ASCOM!", | ||
f"Is ASCOM installed?") | ||
else: | ||
Chooser.DeviceType = 'Telescope' | ||
self.Name = Chooser.Choose(None) | ||
if self.Name != "": | ||
self.Telescope = win32com.client.Dispatch(self.Name) | ||
self.Telescope.Connected = True | ||
if not self.Telescope.Connected: | ||
QtWidgets.QMessageBox.critical(None, "Can not connect to telescope!", | ||
f"Please check connection to\n{self.Name}.\nMaybe it is already in use.") | ||
self.Telescope = None | ||
|
||
def get_Parameter(self): | ||
# has no parameter | ||
return dict() | ||
|
||
def is_open(self): | ||
if self.Telescope is not None: | ||
if self.Telescope.Connected: | ||
return True | ||
return False | ||
|
||
def close(self): | ||
if self.is_open(): | ||
self.Telescope.Connected = False | ||
self.Telescope = None | ||
self.Name = "" | ||
|
||
def sendCommandBlind(self, cmd): | ||
if self.is_open(): | ||
self.dbgMsg(f'sendCommandBlind: {cmd}') | ||
try: | ||
ret = self.Telescope.CommandBlind(cmd, False) | ||
except win32com.client.pywintypes.com_error as e: | ||
print(f'ERROR in sendCommandBlind: {e}') | ||
return None | ||
else: | ||
return ret | ||
return None | ||
|
||
# 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: | ||
CharacterTranslationTable = { | ||
0x0d: ord('\n'), | ||
# 0x2020: ord(' '), | ||
0xDF: ord('°'), | ||
0x7E: 0x2192, # ord('>'), | ||
0x7F: 0x2190, # ord('<'), | ||
0x18: 0x2191, # ord('^'), | ||
0x19: 0x2193, # ord('v'), | ||
# bar graph symbols | ||
0x5F: 0x2582, | ||
0x81: 0x2583, | ||
0x201A: 0x2584, # raw: 0x82 | ||
0x0192: 0x2585, # raw: 0x83 | ||
0x201E: 0x2586, # raw: 0x84 | ||
0x2026: 0x2587, # raw: 0x85 | ||
0x2020: 0x2588, # raw: 0x86 | ||
} | ||
|
||
def get_LCD(self): | ||
if self.is_open(): | ||
try: | ||
Response = 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 before the ASCOM driver trows a timeout exception. | ||
# Here we catch these timeout exceptions. | ||
print(f'ERROR in get_LCD: {e}') | ||
self.dbgMsg(f'get_LCD response: ED --> {Response}') | ||
return Response[1:].translate(self.CharacterTranslationTable) | ||
return None |
Oops, something went wrong.