communication_langage_protocol.rst.txt
4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
*********************************************
Communication protocols for astromecca mounts
*********************************************
This section describes how to use a client software to communicate with
a running astromecca server.
Available protocol transports are:
* Serial RS232.
* Ethernet TCP.
Available protocol langages are:
* LX200. The classical Meade LX200 syntax.
* ASCOM. ASCOM driver for Astromecca mounts
* MCS. Json based messages to allow any operation with the mount.
The default configuration of the MCS script is to run using ASCOM protocol
via serial port RS232 (driver astromecca, 115200 bauds).
It is possible to mix any protocol transport with any protocol langage.
However, do not forget that LX200 langage protocol is usually used
with a RS232 serial transport at 9600 bauds.
1. Serial port and LX200 protocol
*********************************
The client must connect a serial wire between its computer and the astromecca computer.
For example, you can use an ASCOM or INDI client to communicate with the astromecca server.
You have configure ASCOM or INDI to the protocol langage LX200 and the serial transport protocol as 9600 bauds.
If you want to write a Python code to create client, you can use the class MountremoteClient
which wraps the serial protocol. When the MountremoteClient is instanciated the method
putread_chan send the command and receive the response.
The following example gets the declination of the mount via the LX200 command :GD:
::
from mountremote import MountremoteClient
remote_client = MountremoteClient("SERIAL", port="COM1", protocol="LX200", baud=9600)
command = ':GD#'
result = remote_client.putread_chan(command)
print("Command = {}\nResult = {}".format(command,result))
del(remote_client)
The implemented LX200 commands described in https://www.meade.com/support/LX200CommandSet.pdf are:
:CM, :Gc, :GC, :GD, :Gg, :GL, :Gm, :GR, :Gt, :H, :Me, :Mn, :Ms, :Mw, :MS, :P,
:Qe, :Qn, :Qs, :Qw, :Q, :RC, :RG, :RM, :RS, :Sr, :Sd, :Sg, :Sts, :U.
2. Ethernet TCP port and MCS protocol
********************************************
The client must connect an Ethernet wire or establish a wifi connection between its computer and the astromecca computer.
Configure the TCP transport protocol to send messages on the port 1111.
The following example gets the right ascension, the declination and the peer side of the mount via the astromecca command get radec.
::
from mountremote import MountremoteClient
remote_client = MountremoteClient("TCP", port=1111, protocol="MCS")
command = "{'req': {'get': 'radec'}}"
result = remote_client.putread_chan(command)
print("Command = {}\nResult = {}".format(command,result))
del(remote_client)
The most useful command is 'exec' which allow to execute
any python command of the mount thread. By this way it is possible
to drive the mount with only this command. The following example show
how to call directly the method which returns the radec coordinates:
::
from mountremote import MountremoteClient
remote_client = MountremoteClient("TCP", port=1111, protocol="MCS")
command = "{'req': {'do': {'exec' , 'self.radec_coord()'}}}"
result = remote_client.putread_chan(command)
print("Command = {}\nResult = {}".format(command,result))
del(remote_client)
You can execute a GOTO action:
::
from mountremote import MountremoteClient
remote_client = MountremoteClient("TCP", port=1111, protocol="MCS")
command = "{'req': {'do': {'exec' , 'self.radec_goto("4h45m,"+05d18m")'}}}"
result = remote_client.putread_chan(command)
print("Command = {}\nResult = {}".format(command,result))
del(remote_client)
3. The MCS langage protocol
********************************************
The messages are Json formated. Basically the hierarchy is defined as:
::
command = "{typemsg: {action: {cmd: val}}}"
The following combinations can be used:
+------------+------------+-----------+------------------+
| typemsg | action | cmd | val |
+============+============+===========+==================+
| req | do | exec | *Python command* |
+------------+------------+-----------+------------------+
| req | get | radec | |
+------------+------------+-----------+------------------+
| req | get | hadec | |
+------------+------------+-----------+------------------+
The reponse is also a Json structure for which the keys reflect
those of the request (but 'req' is replaced by 'res'):
::
Command = {'req': {'get': 'radec'}}
Result = {'res': {'get': {'radec': [{'ra': 93.77897552123532, 'dec': 0.007976942637754572, 'side': 1}]}}}
Note the val is a list or any other kind of type in case of (req,de,exec).