Commit 4e13f778 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

make console runable

parent e4491c73
...@@ -132,6 +132,7 @@ clean: ...@@ -132,6 +132,7 @@ clean:
log_proxy \ log_proxy \
spg_auth \ spg_auth \
spg_log_parser \ spg_log_parser \
shell.cgi \
await_controller \ await_controller \
command.cgi \ command.cgi \
status.cgi status.cgi
...@@ -139,3 +140,6 @@ clean: ...@@ -139,3 +140,6 @@ clean:
$(MAKE) -C doc clean $(MAKE) -C doc clean
$(MAKE) -C predictlib clean $(MAKE) -C predictlib clean
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "tcp_connect.h" #include "tcp_connect.h"
#include "dt_port_numbers.h" #include "dt_port_numbers.h"
#include "dt_host.h"
#define MAX_RETRIES 30 #define MAX_RETRIES 30
#define SLEEP_INTERVAL 10 #define SLEEP_INTERVAL 10
...@@ -37,14 +38,14 @@ int fd; ...@@ -37,14 +38,14 @@ int fd;
int retries = 0; int retries = 0;
if (argc != 2) { if (argc != 1) {
printf("Usage: %s [host]\n", argv[0]); printf("Usage: %s\n", argv[0]);
printf("\n"); printf("\n");
printf("e.g. %s foo\n", argv[0]); printf("e.g. %s\n", argv[0]);
return 1; return 1;
} }
tr_host = argv[1]; tr_host = dt_host_controller();
tr_port = CTRL_TRACE_PORT; tr_port = CTRL_TRACE_PORT;
fd = tcp_connect(tr_host, tr_port); fd = tcp_connect(tr_host, tr_port);
......
/*
HTTP frontend for J2000.0 positions
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2009
Copyright Stichting C.A. Muller Radioastronomiestation, 2009
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "tcp_connect.h"
int main(int argc, char **argv)
{
int fd;
alarm(10);
if (argc != 3) {
printf("Content-type: text/plain\n");
printf("Cache-Control: no-cache\n");
printf("Pragma: no-cache\n");
printf("\n");
sleep(1);
printf("Not enough arguments\n");
printf("%s <host> <port>\n", argv[0]);
printf("port: e.g. 11030\n");
return 1;
}
fd = tcp_connect(argv[1], atoi(argv[2]));
if (fd >= 0) {
char linebuf[1000];
int r;
ioctl(fd, FIONBIO, &(int){ 0 });
r = read(fd, linebuf, 999);
if (r > 0) {
linebuf[r] = 0;
printf("Content-type: text/plain\n");
printf("Content-Length: %d\n", r);
printf("Cache-Control: no-cache\n");
printf("Pragma: no-cache\n");
printf("\n");
printf("%s", linebuf);
}
} else {
printf("Content-type: text/plain\n");
printf("Content-Length: 7\n");
printf("Cache-Control: no-cache\n");
printf("Pragma: no-cache\n");
printf("\n");
sleep(1);
printf("failed\n");
}
return 0;
}
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "tcp_connect.h" #include "tcp_connect.h"
#include "dt_port_numbers.h" #include "dt_port_numbers.h"
#include "dt_host.h"
char *logfile = "controller.log"; char *logfile = "controller.log";
...@@ -44,15 +45,15 @@ int main (int argc, char **argv) ...@@ -44,15 +45,15 @@ int main (int argc, char **argv)
int nr_clients = 0; int nr_clients = 0;
int fd_logfile = -1; int fd_logfile = -1;
if (argc != 3 && argc != 4) { if (argc != 1 && argc != 2) {
printf("Usage: %s [host] [port] <logfile>\n", argv[0]); printf("Usage: %s <logfile>\n", argv[0]);
printf("\n"); printf("\n");
printf("e.g.: %s foo 11200\n", argv[0]); printf("e.g.: %s\n", argv[0]);
printf("or: %s foo 11200 /var/log/controller.log\n", argv[0]); printf("or: %s /var/log/controller.log\n", argv[0]);
return 1; return 1;
} }
if (argc == 4) { if (argc == 2) {
logfile = argv[3]; logfile = argv[1];
} }
fd_listen = tcp_listen(CONSOLE_LOG_PORT, 0, 100); fd_listen = tcp_listen(CONSOLE_LOG_PORT, 0, 100);
...@@ -65,7 +66,7 @@ int main (int argc, char **argv) ...@@ -65,7 +66,7 @@ int main (int argc, char **argv)
ioctl(fd_listen, FIONBIO, &(int){ 1 }); ioctl(fd_listen, FIONBIO, &(int){ 1 });
fd_log = tcp_connect(argv[1], atoi(argv[2])); fd_log = tcp_connect(dt_host_controller(), CTRL_LOG_PORT);
f_log = fdopen(fd_log, "r"); f_log = fdopen(fd_log, "r");
while (1) { while (1) {
...@@ -77,7 +78,7 @@ int main (int argc, char **argv) ...@@ -77,7 +78,7 @@ int main (int argc, char **argv)
while (fd_log < 0) { while (fd_log < 0) {
sleep(1); sleep(1);
printf("Trying to connect to server.\n"); printf("Trying to connect to server.\n");
fd_log = tcp_connect(argv[1], atoi(argv[2])); fd_log = tcp_connect(dt_host_controller(), CTRL_LOG_PORT);
} }
rb = sprintf(buffer, rb = sprintf(buffer,
"Established connection to controller\n"); "Established connection to controller\n");
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "block_setpoint_generator.h" #include "block_setpoint_generator.h"
#include "dt_port_numbers.h" #include "dt_port_numbers.h"
#include "dt_host.h"
struct console_client { struct console_client {
struct console_client *next; struct console_client *next;
...@@ -404,7 +405,7 @@ void handle_client(struct spg_client *client, struct spg_client **clientp) ...@@ -404,7 +405,7 @@ void handle_client(struct spg_client *client, struct spg_client **clientp)
} }
if (client->cmdlen >= 12) { if (client->cmdlen >= 12) {
printf("cmdlen %d is to long\n", client->cmdlen); printf("cmdlen %zd is to long\n", client->cmdlen);
close(client->fd); close(client->fd);
client->fd = -1; client->fd = -1;
return; return;
...@@ -595,10 +596,9 @@ int main (int argc, char **argv) ...@@ -595,10 +596,9 @@ int main (int argc, char **argv)
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
command_host = dt_host_controller();
if (argc > 1) { if (argc > 1) {
command_host = argv[1];
}
if (argc > 2) {
logfile = argv[2]; logfile = argv[2];
} }
......
#!/bin/sh #!/bin/sh
CTRL=127.0.0.1
#await_controller $CTRL #await_controller
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
echo "Start-up niet mogelijk; controller-PC is niet goed opgestart\n" echo "Start-up niet mogelijk; controller-PC is niet goed opgestart\n"
...@@ -10,9 +9,9 @@ then ...@@ -10,9 +9,9 @@ then
fi fi
screen -dmS trace_proxy trace_proxy $CTRL 20000 screen -dmS trace_proxy trace_proxy
screen -dmS spg_auth spg_auth $CTRL screen -dmS spg_auth spg_auth
screen -dmS log_proxy log_proxy $CTRL 21200 screen -dmS log_proxy log_proxy
sleep 1 sleep 1
screen -dmS console_idle console_idle screen -dmS console_idle console_idle
screen -dmS console_j2000tracker console_j2000tracker screen -dmS console_j2000tracker console_j2000tracker
......
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2008, 2009
Copyright Stichting C.A. Muller Radioastronomiestation, 2008, 2009
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <time.h>
#include "tcp_connect.h"
char *host = "localhost";
int port = 10001;
int main (int argc, char **argv)
{
int i;
int fd;
int r;
char buf[10];
char linebuf[1000];
int linepos = 0;
char *query;
fd = tcp_connect(host, port);
query=getenv("QUERY_STRING");
for (i = 0; i < strlen(query); i++)
if (query[i] == '&')
break;
i++;
for (; i < strlen(query)+1; i++)
if (query[i] == '&')
write(fd, &(char){ 0 }, 1);
else
write(fd, &query[i], 1);
write(fd, &(char){ 0 }, 1);
ioctl(fd, FIONBIO, &(int){ 0 });
while ((r = read(fd, buf, 1) > 0)) {
linebuf[linepos] = buf[0];
linepos++;
}
linebuf[linepos] = 0;
printf("Content-type: text/plain\n");
printf("Content-Length: %d\n", linepos);
printf("Cache-Control: no-cache\n");
printf("Pragma: no-cache\n");
printf("\n");
printf("%s", linebuf);
return 0;
}
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "tcp_connect.h" #include "tcp_connect.h"
#include "dt_port_numbers.h" #include "dt_port_numbers.h"
#include "dt_host.h"
#define INBUF_MAX 100 #define INBUF_MAX 100
...@@ -464,12 +465,6 @@ int main(int argc, char **argv) ...@@ -464,12 +465,6 @@ int main(int argc, char **argv)
list[1] = 0; list[1] = 0;
listlen = 2; listlen = 2;
if (argc != 3) {
printf("Usage: %s [host] [port]\n", argv[0]);
printf("\n");
printf("e.g. %s foo 10000\n", argv[0]);
return 1;
}
fd_listen = tcp_listen(CONSOLE_TRACE_PORT, 0, 100); fd_listen = tcp_listen(CONSOLE_TRACE_PORT, 0, 100);
if (fd_listen < 0) { if (fd_listen < 0) {
...@@ -486,8 +481,8 @@ int main(int argc, char **argv) ...@@ -486,8 +481,8 @@ int main(int argc, char **argv)
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
/* determine socket on dt_ctrl */ /* determine socket on dt_ctrl */
tr_host = argv[1]; tr_host = dt_host_controller();
tr_port = atoi(argv[2]); tr_port = CTRL_TRACE_PORT;
nonex = trace_open("Non-existing-trace"); nonex = trace_open("Non-existing-trace");
if (nonex) if (nonex)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment