1 | The code here demonstrates the use of INDI, an Instrument-Neutral Device |
---|
2 | Interface protocol. See http://www.clearskyinstitute.com/INDI/INDI.pdf. |
---|
3 | |
---|
4 | Architecture: |
---|
5 | |
---|
6 | Typical INDI Client / Server / Driver / Device connectivity: |
---|
7 | |
---|
8 | |
---|
9 | INDI Client 1 ----| |---- INDI Driver A ---- Dev X |
---|
10 | | | |
---|
11 | INDI Client 2 ----| |---- INDI Driver B ---- Dev Y |
---|
12 | | | | |
---|
13 | ... |--- indiserver ---| |-- Dev Z |
---|
14 | | | |
---|
15 | | | |
---|
16 | INDI Client n ----| |---- INDI Driver C ---- Dev T |
---|
17 | |
---|
18 | |
---|
19 | Client INET Server UNIX Driver Hardware |
---|
20 | processes sockets process pipes processes devices |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | Indiserver is the public network access point where one or more INDI Clients |
---|
25 | may contact one or more INDI Drivers. Indiserver launches each driver |
---|
26 | process and arranges for it to receive the INDI protocol from Clients on |
---|
27 | its stdin and expects to find commands destined for Clients on the |
---|
28 | driver's stdout. Anything arriving from a driver process' stderr is copied |
---|
29 | to indiserver's stderr. |
---|
30 | |
---|
31 | Indiserver only provides convenient port, fork and data steering services. |
---|
32 | If desired, a Client may run and connect to INDI Drivers directly. |
---|
33 | |
---|
34 | Construction: |
---|
35 | |
---|
36 | An INDI driver typically consists of one .c file, eg, mydriver.c, which |
---|
37 | #includes indiapi.h to access the reference API declarations. It is |
---|
38 | compiled then linked with indidrivermain.o, eventloop.o and liblilxml.a to |
---|
39 | form an INDI process. These supporting files contain the implementation of |
---|
40 | the INDI Driver API and need not be changed in any way. Note that |
---|
41 | evenloop.[ch] provide a nice callback facility independent of INDI which |
---|
42 | may be used in other projects if desired. |
---|
43 | |
---|
44 | The driver implementation, again in our example mydriver.c, does not |
---|
45 | contain a main() but is expected to operate as an event-driver program. |
---|
46 | The driver must implement each ISxxx() function but never call them. The |
---|
47 | IS() functions are called by the reference implementation main() as messages |
---|
48 | arrive from Clients. Within each IS function the driver performs the |
---|
49 | desired tasks then may report back to the Client by calling the IDxxx() |
---|
50 | functions. |
---|
51 | |
---|
52 | The reference API provides IE() functions to allow the driver to add its |
---|
53 | own callback functions if desired. The driver can arrange for functions to |
---|
54 | be called when reading a file descriptor will not block; when a time |
---|
55 | interval has expired; or when there is no other client traffic in progress. |
---|
56 | |
---|
57 | The sample indiserver is a stand alone process that may be used to run one |
---|
58 | or more INDI-compliant drivers. It takes the names of each driver process |
---|
59 | to run in its command line args. |
---|
60 | |
---|
61 | To build indiserver type 'make indiserver'; |
---|
62 | to build all the sample drivers type 'make drivers'; |
---|
63 | to run the sample server with all drivers type 'make run'. |
---|
64 | Killing indiserver will also kill all the drivers it started. |
---|
65 | |
---|
66 | Secure remote operation: |
---|
67 | |
---|
68 | Suppose we want to run indiserver and its clients on a remote machine, r, |
---|
69 | and connect them to our favorite INDI client, XEphem, running on the |
---|
70 | local machine. |
---|
71 | |
---|
72 | From the local machine log onto the remote machine, r, by typing: |
---|
73 | |
---|
74 | ssh2 -L 7624:s:7624 r |
---|
75 | |
---|
76 | after logging in, run indiserver on the remote machine: |
---|
77 | |
---|
78 | make run |
---|
79 | |
---|
80 | Back on the local machine, start XEphem, then open Views -> Sky View -> |
---|
81 | Telescope -> INDI panel. XEphem will connect to the remote INDI server |
---|
82 | securely and automatically begin running. Sweet. |
---|
83 | |
---|
84 | Testing: |
---|
85 | |
---|
86 | A low-level way to test the socket, forking and data steering abilities of |
---|
87 | indiserver is to use the 'hose' command from the netpipes collection |
---|
88 | (http://web.purplefrog.com/~thoth/netpipes/netpipes.html): |
---|
89 | |
---|
90 | 1. start indiserver using UNIX' cat program as the only INDI "device": |
---|
91 | |
---|
92 | % indiserver cat & |
---|
93 | |
---|
94 | 2. use hose to connect to the "cat" device driver which just copies back: |
---|
95 | |
---|
96 | % hose localhost 7624 --slave |
---|
97 | hello world |
---|
98 | hello world |
---|
99 | more stuff |
---|
100 | more stuff |
---|
101 | |
---|
102 | ! For RCS Only -- Do Not Edit |
---|
103 | ! @(#) $RCSfile$ $Date: 2004-02-03 09:34:32 +0300 (Tue, 03 Feb 2004) $ $Revision: 284704 $ $Name: $ |
---|