code:telescope_driver
Differences
This shows you the differences between two versions of the page.
Previous revisionLast revision | |||
— | code:telescope_driver [2010/01/17 02:41] – pkubanek | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Tasks in implementing driver ====== | ||
+ | To implement an RTS2 telescope driver, you need to create a child class inherited from [[rts2teld:: | ||
+ | |||
+ | If you are using a serial port to communicate with your telescope, you can consider using [[Rts2ConnSerial]] class to handle for you communication over serial port. For example how to use this class refer to [[http:// | ||
+ | |||
+ | This is a minimal example. Please refer to some real telescope driver for a more realistic example. | ||
+ | |||
+ | <code c++> | ||
+ | #include " | ||
+ | |||
+ | using namespace rts2teld; | ||
+ | |||
+ | class MyTelescope: | ||
+ | { | ||
+ | protected: | ||
+ | virtual int startMove (); | ||
+ | virtual int stopMove (); | ||
+ | virtual int startPark (); | ||
+ | virtual int stopPark (); | ||
+ | public: | ||
+ | MyTelescope (int argc, char ** argv); | ||
+ | }; | ||
+ | |||
+ | int Telescope:: | ||
+ | { | ||
+ | struct ln_equ_struct tar; | ||
+ | getTarget (&tar); | ||
+ | // do all what is needed to start move to tar.ra tar.dec | ||
+ | // ... | ||
+ | // return -1 in case of failure | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | int MyTelescope:: | ||
+ | { | ||
+ | return 0; // success | ||
+ | } | ||
+ | |||
+ | int MyTelescope:: | ||
+ | { | ||
+ | // do all what is needed to move telescope to park position | ||
+ | // return -1 in case of failure | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | int MyTelescope:: | ||
+ | { | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | MyTelescope:: | ||
+ | { | ||
+ | |||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== Main method ====== | ||
+ | |||
+ | After you implement your class, the main() method is trivial and effectively identical in all RTS2 devices (it basically allows you to pass in commandline arguments): | ||
+ | |||
+ | <code c++> | ||
+ | |||
+ | int main (int argc, char **argv) | ||
+ | { | ||
+ | MyTelescope device = MyTelescope (argc, argv); | ||
+ | return device.run (); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ====== Adding code to automake ====== | ||
+ | |||
+ | After you are done with coding, you should add it to Makefile.am, | ||
+ | |||
+ | In Makefile.am, | ||
+ | |||
+ | ====== Debuging a new code ====== | ||
+ | |||
+ | When you need to debug your code, you have two options: | ||
+ | |||
+ | - Attach with attach <pid> command to running code | ||
+ | - Start telescope daemon with -i option, so it will not detach from controlling terminal (set args -i in gdb) | ||
+ | |||
+ | If you don't do this, rts2-teld-mytel will start the new daemon process and then exit - and gdb is tracking the parent, not the spawned process. |
code/telescope_driver.txt · Last modified: 2010/01/17 00:00 (external edit)