Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Telescope Control

Feedback
Anonymous
2013-10-18
2013-10-21

  • Anonymous
    2013-10-18

    Hello,

    I'd like to connect a program that I am developing to control a telescope to Stellarium.
    I read the informations about the Telescope Control Plug-in and it seems a very simple protocol to implement.
    So I started to create a super simple server that should listen an incoming message from Stellarium and send it back to Stellarium. My initial goal was to see if the name of the telescope appears on the sky.

    But while I am perfect able to read everything, I cannot send anything to Stellarium, so, after one week trying you are my last option.

    Could someone tell me what is wrong with this code (except the fact that I am not trapping any error)?
    If I remove the "send" line I can read a packet of 20 bytes every time I press control-1 on Stellarium, as expected (I tried also to decode the message and the coordinates are correct).
    But if I send back the packet to Stellarium the connection is closed and the program stops.
    Any help is more than welcome.
    Thanks
    Enrico

    include <unistd.h>

    include <sys socket.h="">

    include <netinet in.h="">

    include <sys types.h="">

    include <sys ipc.h="">

    include <sys shm.h="">

    include <stdlib.h>

    include <string.h>

    include <stdio.h>

    int main()
    {
    int connfd;
    int listenfd;
    struct sockaddr_in cliaddr, servaddr;
    socklen_t clilen;
    char buffer[24];
    int i;

    listenfd=socket(AF_INET,SOCK_STREAM,0);

    bzero(&servaddr,sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
    servaddr.sin_port=htons(10001);
    bind(listenfd,(struct sockaddr *)&servaddr,sizeof(servaddr));
    listen(listenfd,1);

    clilen=sizeof(cliaddr);
    connfd = accept(listenfd,(struct sockaddr *)&cliaddr,&clilen);

    for (i=0;i<24;i++)
    buffer[i]=0;

    for (;;)
    {
    printf("Received: %d\n",recv(connfd,buffer,20,0));
    sleep(1);
    printf("Sent: %d\n",send(connfd,buffer,24,0));
    sleep(1);
    }

    return 0;
    }

     
  • barrykgerdes
    barrykgerdes
    2013-10-18

    The simplest way to get stellarium to talk to the telescope is to use either Celestron or Meade protocol in your controller. See the manuals on these devices already available on the internet.

    Stellarium already has this control built into it.

    Barry

     

  • Anonymous
    2013-10-18

    Barry,

    I am confused now. I thought that the only way to talk with Stellarium was through the Stellarium Telescope Plug-in. So what does it mean that it has the control built into it?
    I can see those telescope models in the options of the Telescope Control but that protocols are for telescope connected to the computer through USB or serial.
    My device is remote and I'd like to connect to Stellarium through a tcp connection.
    I think that the only option is to use the "External software or a remote computer" that start up an Internet client. Is there any other possibility?
    Thank you for your answer.
    Enrico

     

  • Anonymous
    2013-10-20

    I solved it: the first two bytes were wrong because the size of the sent packet is 24, so I had to set buffer[0]=0x18 (24 in hex).
    E.

     


Anonymous


Cancel   Add attachments