From c158c856f3ed5f9bd292206614b35437862dfffe Mon Sep 17 00:00:00 2001 From: Gautier Hattenberger Date: Wed, 5 Jun 2024 18:10:51 +0200 Subject: [PATCH] [ocaml] use glib from gtk3 if gtk2 is not found (#3290) Gtk3 doesn't support all features of gtk2 (or have a different interface), so if only gtk3 is found, GUI tools are not compiled, only CLI tools based only on glib. If no gtk found, tools based on glib/gtk are not compiled. Remove two old tools not used and not supported by gtk3. --- sw/Makefile.ocaml | 19 +- sw/ground_segment/cockpit/Makefile | 13 +- sw/ground_segment/cockpit/lib/Makefile | 4 +- sw/ground_segment/joystick/Makefile | 8 +- sw/ground_segment/misc/Makefile | 13 +- sw/ground_segment/tmtc/Makefile | 28 +- .../tmtc/c_ivy_client_example_3.c | 38 - sw/ground_segment/tmtc/ivy_serial_bridge.c | 833 ------------------ sw/lib/ocaml/META.pprz | 2 +- sw/lib/ocaml/Makefile | 8 +- sw/logalizer/Makefile | 12 +- sw/simulator/Makefile | 8 +- sw/supervision/Makefile | 15 +- 13 files changed, 87 insertions(+), 914 deletions(-) delete mode 100644 sw/ground_segment/tmtc/c_ivy_client_example_3.c delete mode 100644 sw/ground_segment/tmtc/ivy_serial_bridge.c diff --git a/sw/Makefile.ocaml b/sw/Makefile.ocaml index 8a5f2ce45e..0e7eeb8c80 100644 --- a/sw/Makefile.ocaml +++ b/sw/Makefile.ocaml @@ -30,8 +30,8 @@ endif endif OCAML = ocaml -OCAMLC = ocamlfind ocamlc -safe-string -g -OCAMLOPT = ocamlfind ocamlopt -safe-string -g +OCAMLC = ocamlfind ocamlc -safe-string -g -thread +OCAMLOPT = ocamlfind ocamlopt -safe-string -g -thread OCAMLDEP = ocamlfind ocamldep OCAMLMKLIB = ocamlmklib OCAMLLEX=ocamllex @@ -50,3 +50,18 @@ OCAMLXDLL = -dllpath $(LIBPPRZDIR),$(LIBPPRZLINKDIR) OCAMLPATH:=$(shell echo $(LIBPPRZLINKDIR):$(LIBPPRZDIR):$(OCAMLPATH)) export OCAMLPATH + +# Test lablgtk version, use V2 if available, V3 otherwise +# disable ocaml/gtk tools if none ? +LABLGTK2_VER = $(shell ocamlfind query -p-format lablgtk2 2>/dev/null) +LABLGTK3_VER = $(shell ocamlfind query -p-format lablgtk3 2>/dev/null) +ifneq ($(LABLGTK2_VER),) +USE_LABELGTK = $(LABLGTK2_VER) +else +ifneq ($(LABLGTK3_VER),) +USE_LABELGTK = $(LABLGTK3_VER) +else +USE_LABELGTK= +endif +endif + diff --git a/sw/ground_segment/cockpit/Makefile b/sw/ground_segment/cockpit/Makefile index 5bca3e0353..9230fbbb93 100644 --- a/sw/ground_segment/cockpit/Makefile +++ b/sw/ground_segment/cockpit/Makefile @@ -29,9 +29,17 @@ include ../../Makefile.ocaml OCAMLPATH:=$(shell echo $(PAPARAZZI_SRC)/sw/ground_segment/cockpit/lib:$(OCAMLPATH)) export OCAMLPATH +ifneq ($(USE_LABELGTK),lablgtk2) +all : + @echo Skipping legacy GCS build \(missing lablgtk2\) + +opt : + @echo Skipping legacy GCS.opt build \(missing lablgtk2\) + +else INCLUDES= -PKG = -package pprzlink,gcslib -LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprzlink,gcslib,pprz +PKG = -package lablgtk2,pprzlink,gcslib +LINKPKG = $(PKG) -linkpkg -dllpath-pkg lablgtk2,pprzlink,gcslib,pprz LABLGTK2INIT = $(shell ocamlfind query -p-format lablgtk2.init 2>/dev/null) ifeq ($(LABLGTK2INIT),) @@ -68,6 +76,7 @@ all : $(MAIN) opt : $(MAIN).opt +endif endif endif diff --git a/sw/ground_segment/cockpit/lib/Makefile b/sw/ground_segment/cockpit/lib/Makefile index bcad5441ba..a785b06777 100644 --- a/sw/ground_segment/cockpit/lib/Makefile +++ b/sw/ground_segment/cockpit/lib/Makefile @@ -47,8 +47,8 @@ PKGCOMMON=pprzlink XINCLUDES= XPKGCOMMON=pprzlink,xml-light,glibivy,$(LABLGTK2GNOMECANVAS),lablgtk2.glade -PKG = -package pprzlink,pprz.xlib -LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz.xlib,pprzlink +PKG = -package lablgtk2,pprzlink,pprz.xlib +LINKPKG = $(PKG) -linkpkg -dllpath-pkg lablgtk2,pprz.xlib,pprzlink XSRC = contrastLabel.ml acIcon.ml wind_sock.ml gtk_papget_editor.ml gtk_papget_text_editor.ml gtk_papget_gauge_editor.ml gtk_papget_led_editor.ml papget_common.ml papget_renderer.ml papget.ml mapCanvas.ml mapWaypoints.ml mapTrack.ml mapGoogle.ml mapIGN.ml ml_gtk_drag.o xmlEdit.ml mapFP.ml XCMO = $(XSRC:.ml=.cmo) diff --git a/sw/ground_segment/joystick/Makefile b/sw/ground_segment/joystick/Makefile index ce72dc2f9e..19de36dcb1 100644 --- a/sw/ground_segment/joystick/Makefile +++ b/sw/ground_segment/joystick/Makefile @@ -32,8 +32,8 @@ CAML_LD_LIBRARY_PATH := /usr/lib/$(shell uname -m)-linux-gnu/:$(CAML_LD_LIBRARY_ export CAML_LD_LIBRARY_PATH -PKG = -package pprz,glibivy -LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink +PKG = -package pprz,glibivy,$(USE_LABELGTK) +LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink,$(USE_LABELGTK) GLIB_CFLAGS = -Wall -fPIC $(shell pkg-config glib-2.0 --cflags) GLIB_LDFLAGS = $(shell pkg-config glib-2.0 --libs) @@ -71,7 +71,11 @@ else endif endif +ifneq ($(USE_LABELGTK),) all: test_stick input2ivy +else +all: test_stick +endif test_stick: test_sdl_stick.o @echo BUILD $@ diff --git a/sw/ground_segment/misc/Makefile b/sw/ground_segment/misc/Makefile index 5a4179d724..8125bcf3f8 100644 --- a/sw/ground_segment/misc/Makefile +++ b/sw/ground_segment/misc/Makefile @@ -35,9 +35,14 @@ else LIBRARYS = endif +GTK2_INC = $(shell pkg-config gtk+-2.0 --cflags 2> /dev/null) +GTK2_LDFLAGS = $(shell pkg-config gtk+-2.0 --libs 2> /dev/null) + +ifneq ($(GTK2_INC),) CFLAGS += -Wall -fPIC -g -GTK_CFLAGS = $(shell pkg-config gtk+-2.0 --cflags) -DGTK_DISABLE_DEPRECATED -GTK_LDFLAGS = $(shell pkg-config gtk+-2.0 --libs) $(shell pkg-config --libs ivy-glib) $(shell pcre-config --libs) -fPIC +GTK_CFLAGS = $(GTK2_INC) -DGTK_DISABLE_DEPRECATED +GTK_LDFLAGS = $(GTK2_LDFLAGS) $(shell pkg-config --libs ivy-glib) $(shell pcre-config --libs) -fPIC +endif GLIBIVY_CFLAGS = $(shell pkg-config --cflags ivy-glib) GLIBIVY_LDFLAGS = $(shell pkg-config --libs ivy-glib) $(shell pcre-config --libs) @@ -57,7 +62,11 @@ GLIB_LDFLAGS = $(shell pkg-config glib-2.0 --libs) -lglibivy -lm $(shell pcre-co INCLUDES += $(shell pkg-config glib-2.0 --cflags) -I$(PAPARAZZI_SRC)/sw/airborne/ -I$(PAPARAZZI_SRC)/sw/include/ $(IVY_INC) INCLUDES += -I$(PAPARAZZI_SRC)/sw/ext/libsbp/c/include/ -I$(PAPARAZZI_SRC)/sw/airborne/modules/gps/librtcm3/ -I$(PAPARAZZI_SRC)/sw/airborne/arch/linux/ +ifeq ($(GTK2_INC),) +all: davis2ivy kestrel2ivy sbp2ivy rtcm2ivy ublox2ivy +else all: davis2ivy kestrel2ivy sbp2ivy video_synchronizer sbs2ivy rtcm2ivy ublox2ivy +endif clean: $(Q)rm -f *.o davis2ivy kestrel2ivy sbp2ivy video_synchronizer sbs2ivy rtcm2ivy ublox2ivy diff --git a/sw/ground_segment/tmtc/Makefile b/sw/ground_segment/tmtc/Makefile index cb7a3262e3..93ba3a312e 100644 --- a/sw/ground_segment/tmtc/Makefile +++ b/sw/ground_segment/tmtc/Makefile @@ -29,21 +29,24 @@ CONF = ../../../conf VAR = ../../../var INCLUDES= -PKG = -package glibivy,pprz -LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink -XPKG = -package pprz.xlib -XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg pprz.xlib,pprzlink +PKG = -package glibivy,pprz,$(USE_LABELGTK) +LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink,$(USE_LABELGTK) +XPKG = -package pprz.xlib,$(USE_LABELGTK) +XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg pprz.xlib,pprzlink,$(USE_LABELGTK) SERVERCMO = server_globals.cmo aircraft_server.cmo wind.cmo airprox.cmo kml.cmo parse_messages_v1.ml intruder.cmo server.cmo SERVERCMX = $(SERVERCMO:.cmo=.cmx) +all: link server ivy_tcp_aircraft ivy_tcp_controller broadcaster ivy2udp ivy2serial app_server ivy2nmea gpsd2ivy gtk_tools -all: link server messages ivy_tcp_aircraft ivy_tcp_controller broadcaster ivy2udp ivy2serial ivy_serial_bridge app_server ivy2nmea gpsd2ivy +ifeq ($(USE_LABELGTK),lablgtk2) +gtk_tools: messages +endif opt: server.opt clean: - $(Q)rm -f link server messages *.bak *~ core *.o .depend *.opt *.out *.cm* ivy_tcp_aircraft ivy_tcp_controller broadcaster ivy2udp ivy2serial ivy_serial_bridge app_server gpsd2ivy c_ivy_client_example_1 c_ivy_client_example_2 c_ivy_client_example_3 ivy2nmea + $(Q)rm -f link server messages *.bak *~ core *.o .depend *.opt *.out *.cm* ivy_tcp_aircraft ivy_tcp_controller broadcaster ivy2udp ivy2serial ivy_serial_bridge app_server gpsd2ivy c_ivy_client_example_1 c_ivy_client_example_2 ivy2nmea messages : messages.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) @echo OL $@ @@ -105,9 +108,6 @@ ivy2serial : ivy2serial.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) CC = gcc -GTK_CFLAGS = $(shell pkg-config gtk+-2.0 --cflags) -DGTK_DISABLE_DEPRECATED -GTK_LDFLAGS = $(shell pkg-config gtk+-2.0 --libs) $(shell pcre-config --libs) - GLIBIVY_CFLAGS = -Wall -fPIC $(shell pkg-config --cflags ivy-glib) GLIBIVY_LDFLAGS = $(shell pkg-config --libs ivy-glib) $(shell pcre-config --libs) @@ -143,15 +143,7 @@ c_ivy_client_example_1: c_ivy_client_example_1.c Makefile c_ivy_client_example_2: c_ivy_client_example_2.c Makefile $(CC) $(GLIBIVY_CFLAGS) -o $@ $< $(GLIBIVY_LDFLAGS) -c_ivy_client_example_3: c_ivy_client_example_3.c Makefile - $(CC) $(GLIBIVY_CFLAGS) $(GTK_CFLAGS) -o $@ $< $(GLIBIVY_LDFLAGS) $(GTK_LDFLAGS) - -ivy_serial_bridge: ivy_serial_bridge.c Makefile - @echo OL $@ - $(Q)$(CC) $(GLIBIVY_CFLAGS) $(GTK_CFLAGS) -o $@ $< $(GLIBIVY_LDFLAGS) $(GTK_LDFLAGS) - - -.PHONY: all opt clean +.PHONY: all opt clean gtk_tools # # Dependencies diff --git a/sw/ground_segment/tmtc/c_ivy_client_example_3.c b/sw/ground_segment/tmtc/c_ivy_client_example_3.c deleted file mode 100644 index da51674ae6..0000000000 --- a/sw/ground_segment/tmtc/c_ivy_client_example_3.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include -#include - -#include -#include - - -static void on_button_clicked (GtkWidget *widget, gpointer data) { - g_message("hello world"); - int foo = 42; - IvySendMsg("ME HELLO_WORLD 1234 5678 %d", foo); -} - - -int main ( int argc, char** argv) { - - gtk_init(&argc, &argv); - - IvyInit ("Example1", "Example1 READY", NULL, NULL, NULL, NULL); - IvyStart("127.255.255.255"); - - - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "HelloWorld"); - - GtkWidget* button = gtk_toggle_button_new_with_label( "ClickMe" ); - gtk_container_add (GTK_CONTAINER (window), button); - g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_button_clicked), NULL); - - gtk_widget_show_all(window); - - gtk_main(); - return 0; - -} - diff --git a/sw/ground_segment/tmtc/ivy_serial_bridge.c b/sw/ground_segment/tmtc/ivy_serial_bridge.c deleted file mode 100644 index a4b379bc8d..0000000000 --- a/sw/ground_segment/tmtc/ivy_serial_bridge.c +++ /dev/null @@ -1,833 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -//#include - - -#define Dprintf(X, ... ) -//#define Dprintf printf - -////////////////////////////////////////////////////////////////////////////////// -// SETTINGS -////////////////////////////////////////////////////////////////////////////////// - -// Serial Repeat Rate -long delay = 1000; - - -GtkWidget *status_ivy; -GtkWidget *status_serial; -GtkWidget *status; - -char status_str[256]; -char status_ivy_str[256]; -char status_serial_str[256]; -char *port = ""; - -long int count_ivy = 0; -long int count_serial = 0; - -long int rx_bytes = 0; -long int tx_bytes = 0; -long int rx_error = 0; - -char modem_id[32] = ""; -int power_level = 4; - -////////////////////////////////////////////////////////////////////////////////// -// local_uav DATA -////////////////////////////////////////////////////////////////////////////////// - - -struct _uav_type_ -{ - // Header - unsigned char header; - - // Data - unsigned char ac_id; - short int phi, theta, psi, speed; - int utm_east,utm_north,utm_z; - unsigned char utm_zone; - unsigned char pprz_mode; - float desired_alt; - float climb; - unsigned char block; - - // Footer - unsigned char footer; -} -__attribute__((packed)) - -local_uav, remote_uav; - -volatile unsigned char new_ivy_data = 0; -volatile unsigned char new_serial_data = 0; - -////////////////////////////////////////////////////////////////////////////////// -// IVY Reader -////////////////////////////////////////////////////////////////////////////////// - - -static void on_Attitude(IvyClientPtr app, void *user_data, int argc, char *argv[]) -{ -/* - - - - - -*/ - - local_uav.phi = (short int) (atof(argv[0]) * 1000.0); - local_uav.psi = (short int) (atof(argv[1]) * 1000.0); - local_uav.theta = (short int) (atof(argv[2]) * 1000.0); - - //Dprintf("ATTITUDE ac=%d phi=%d theta=%d psi=%d ",local_uav.ac_id, local_uav.phi, local_uav.theta, local_uav.psi); -} - -static void on_Estimator(IvyClientPtr app, void *user_data, int argc, char *argv[]) -{ -/* - - - - -*/ - - local_uav.utm_z = (( atof(argv[0]) ) * 1000.0f); - local_uav.climb = atof(argv[1]); -} - -static void on_Navigation(IvyClientPtr app, void *user_data, int argc, char *argv[]) -{ -/* - - - - - - - - - - -*/ - - local_uav.block = atoi(argv[0]); -} - -static void on_Desired(IvyClientPtr app, void *user_data, int argc, char *argv[]) -{ -/* - - - - - - - - - -*/ - - local_uav.desired_alt = atof(argv[5]); -} - -static void on_Gps(IvyClientPtr app, void *user_data, int argc, char *argv[]) -{ -/* - - - - - - - - - - - - - -*/ - - local_uav.utm_east = atoi(argv[1]); - local_uav.utm_north = atoi(argv[2]); - local_uav.utm_zone = atoi(argv[9]); - local_uav.speed = atoi(argv[5]); - - //Dprintf("ATTITUDE ac=%d phi=%d theta=%d psi=%d ",local_uav.ac_id, local_uav.phi, local_uav.theta, local_uav.psi); - //Dprintf("GPS ac=%d %d %d %d %d\n",local_uav.ac_id, local_uav.utm_east, local_uav.utm_north, local_uav.utm_z, local_uav.utm_zone); - - new_ivy_data = 1; -} - -////////////////////////////////////////////////////////////////////////////////// -// IVY Writer -////////////////////////////////////////////////////////////////////////////////// - -void send_ivy(void) -{ - float phi,theta,psi,z,zdot; - - if (new_serial_data == 0) - return; - - new_serial_data = 0; - - phi = ((float) remote_uav.phi) / 1000.0f; - theta = ((float) remote_uav.theta) / 1000.0f; - psi = ((float) remote_uav.psi) / 1000.0f; - - IvySendMsg("%d ALIVE 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n", remote_uav.ac_id); - - IvySendMsg("%d ATTITUDE %f %f %f\n", remote_uav.ac_id, phi, psi, theta); - -/* - remote_uav.utm_east = local_uav.utm_east; - remote_uav.utm_north = local_uav.utm_north + 5000; - remote_uav.utm_z = local_uav.utm_z + 1000; - remote_uav.utm_zone = local_uav.utm_zone; - remote_uav.speed = local_uav.speed * 4; - remote_uav.psi += 30.; -*/ - -/* - - - - - - - - - - - - - -*/ - - IvySendMsg("%d GPS 3 %d %d 0 %d %d 0 0 0 %d 0\n", remote_uav.ac_id, remote_uav.utm_east, remote_uav.utm_north, remote_uav.utm_z, remote_uav.speed, remote_uav.utm_zone); - -/* - - - - - - - -*/ - - IvySendMsg("%d FBW_STATUS 2 0 1 81 0 \n", remote_uav.ac_id); - - z = ((float)remote_uav.utm_z) / 1000.0f; - zdot = remote_uav.climb; - IvySendMsg("%d ESTIMATOR %f %f \n", remote_uav.ac_id, z, zdot); - -/* - - - - - - - - - -*/ - IvySendMsg("%d DESIRED 0 0 0 0 0 %f 0 \n", remote_uav.ac_id, remote_uav.desired_alt); - -/* - - - - - - - - - - -*/ - -// IvySendMsg("%d NAVIGATION %d 0 0 0 0 0 0 0 \n", remote_uav.ac_id, remote_uav.block); - -/* - - - - - - - - -*/ - - // IvySendMsg("%d PPRZ_MODE 0 0 0 0 0 0\n", remote_uav.ac_id); - -/* // Needed to show any NAV info like current block number - - - - - -*/ - - static int delayer = 10; - delayer++; - if (delayer > 5) - { -// IvySendMsg("%d NAVIGATION_REF %d %d %d\n", remote_uav.ac_id, remote_uav.utm_east, remote_uav.utm_north, remote_uav.utm_zone); - delayer = 0; - } - - count_serial++; - - sprintf(status_serial_str, "Read %d from '%s': forwarding to IVY [%ld] {Rx=%ld} {Err=%ld}", remote_uav.ac_id, port, count_serial, rx_bytes, rx_error); - gtk_label_set_text( GTK_LABEL(status_serial), status_serial_str ); -} - -////////////////////////////////////////////////////////////////////////////////// -// SERIAL PORT -////////////////////////////////////////////////////////////////////////////////// - -// pointer -int fd = 0; - -/// Open -void open_port(const char* device) { - fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); - if (fd == -1) { - fprintf(stderr, "open_port: unable to open device %s - ", device); - perror(NULL); - exit(EXIT_FAILURE); - } - // setup connection options - struct termios options; - - // get the current options - tcgetattr(fd, &options); - - // set local mode, enable receiver, set comm. options: - // 8 data bits, 1 stop bit, no parity, 9600 Baud - options.c_cflag = CLOCAL | CREAD | CS8 | B9600; - - // write options back to port - tcsetattr(fd, TCSANOW, &options); -} - -unsigned char* buf_tx = (unsigned char*) &local_uav; -unsigned char* buf_rx = (unsigned char*) &remote_uav; - -void send_port(void) -{ - int bytes; - int i = 0; - - if (new_ivy_data == 0) - return; - - new_ivy_data = 0; - - - local_uav.header = '@'; - local_uav.footer = 0; - // Checksum - for (i=0;i<(sizeof(local_uav)-1);i++) - { - local_uav.footer += buf_tx[i]; - Dprintf("%x ", buf_tx[i]); - } - bytes = write(fd, &local_uav, sizeof(local_uav)); - - tx_bytes += bytes; - - Dprintf("SENT: %d (%d bytes)\n",local_uav.ac_id, bytes); - - count_ivy++; - - sprintf(status_ivy_str, "Received %d from IVY: forwarding to '%s' [%ld] {Tx=%ld}", local_uav.ac_id, port, count_ivy, tx_bytes); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); -} - -int set_power_level = -1; -int get_power_level = -1; - -int handle_api(void) -{ - static int step = 0; - int bytes; - int i=0; - char buff[48]; - - // ATPL4 = power level 4 - // ATMT0 = zero retry on broadcast - // ATRR = mac retry on NACK - - // ATDH = 0x00000000 - // ATDL = 0x0000FFFF - - // read only: - // Serial High - // Serial Low - - // ATDC = duty cycle status (percent 0 - 100) - // ATDB = Signal Strength - - - // ATWR = write to flash - // ATCN = exit command mode - - - step++; - - if (step > 35) - { - step = 35; - return 1; - } - - switch(step) - { - case 1: - sprintf(buff,"+++"); - bytes = write(fd, buff, strlen(buff)); - printf("+++ (bytes=%d %d)\n",bytes, fd); - - buff[strlen(buff)] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - - break; - case 8: - sprintf(buff,"ATPL\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATPL\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 10: - sprintf(buff,"ATPL%d\r", power_level); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATPL%d\n",power_level); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 12: - sprintf(buff,"ATPL\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATPL\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 14: - sprintf(buff,"ATDH\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATDH\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 16: - sprintf(buff,"ATDL\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATDL\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 18: - sprintf(buff,"ATSH\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATSH\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 20: - sprintf(buff,"ATSL\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATSL\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 22: - sprintf(buff,"ATMT0\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATMT0\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 24: - sprintf(buff,"ATRR0\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATRR0\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 26: - sprintf(buff,"ATDH00000000\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATDH00000000\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 28: - sprintf(buff,"ATDL0000FFFF\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATDL0000FFFF\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 30: - sprintf(buff,"ATWR\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATWR\n"); - - buff[strlen(buff) - 1] = 0; - strcpy(status_ivy_str,buff); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - break; - case 32: - sprintf(buff,"ATCN\r"); - write(fd, (unsigned char*) buff, strlen(buff)); - printf("ATCN\n"); - printf("Quit API\n"); - modem_id[16]=0; - sprintf(buff, ", XB_ADDR='%s', ", modem_id); - strcat(status_str,buff); - sprintf(buff, "ATPL=%d", power_level); - strcat(status_str,buff); - gtk_label_set_text( GTK_LABEL(status), status_str ); - break; - case 34: - sprintf(status_ivy_str, "---"); - gtk_label_set_text( GTK_LABEL(status_ivy), status_ivy_str ); - sprintf(status_serial_str, "---"); - gtk_label_set_text( GTK_LABEL(status_serial), status_serial_str ); - - break; - case 7: - case 9: - case 11: - case 13: - case 15: - case 17: - case 19: - case 21: - case 23: - case 25: - case 27: - case 29: - case 31: - case 33: - bytes = read(fd, (unsigned char*) buff, 32); - printf("Bytes %d %d\n",bytes, fd); - if ((bytes > 1) && (bytes < 10)) - { - buff[bytes-1] = 0; - strcpy(status_serial_str, buff); - gtk_label_set_text( GTK_LABEL(status_serial), status_serial_str ); - } - for (i=0;i= sizeof(remote_uav)) - { - if (buf_rx[0] != '@') - { - int head = 0; - for (head=0; head= 0) && (handle_api() == 0)) - return TRUE; - - // Every Time - read_port(); - - // One out of 4 - if (dispatch > 2) - { - send_port(); - dispatch = 0; - } - else - { - dispatch ++; - } - return TRUE; -} - -////////////////////////////////////////////////////////////////////////////////// -// MAIN -////////////////////////////////////////////////////////////////////////////////// - -gint delete_event( GtkWidget *widget, - GdkEvent *event, - gpointer data ) -{ - g_print ("CLEAN STOP\n"); - - close_port(); - IvyStop(); - - exit(0); - - return(FALSE); // false = delete window, FALSE = keep active -} - - -int main ( int argc, char** argv) -{ - int s = sizeof(local_uav); - - gtk_init(&argc, &argv); - - if (argc < 3) - { - printf("Use: ivy2serial ac_id serial_device\n"); - printf("or\n"); - printf("Use: ivy2serial ac_id serial_device xbee_power_level [0-4] to configure the xbee as broadcast, no retries\n"); - return -1; - } - - if (argc == 4) - { - printf("Programming XBee Modem\n"); - power_level = (int) (argv[3][0]) - (int) '0'; - if (power_level < 0) - power_level = 0; - else if (power_level > 4) - power_level = 4; - printf("Set Power Level To: '%d'\n", power_level); - } - else - { - power_level = -1; - } - - local_uav.ac_id = atoi(argv[1]); - - sprintf(status_str, "Listening to AC=%d, Serial Data Size = %d",local_uav.ac_id, s); - sprintf(status_ivy_str, "---"); - sprintf(status_serial_str, "---"); - printf("%s\n",status_str); - - // Open Serial or Die - port = argv[2]; - open_port(port); - - // Init UAV - remote_uav.ac_id = 6; - - remote_uav.phi = 1000; - remote_uav.theta = 200; - remote_uav.psi = -3140; - - // Start IVY - IvyInit ("IVY <-> Serial", "IVY <-> Serial READY", NULL, NULL, NULL, NULL); - IvyBindMsg(on_Desired, NULL, "^%d DESIRED (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); - IvyBindMsg(on_Estimator, NULL, "^%d ESTIMATOR (\\S*) (\\S*)",local_uav.ac_id); - IvyBindMsg(on_Navigation, NULL, "^%d NAVIGATION (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); - IvyBindMsg(on_Attitude, NULL, "^%d ATTITUDE (\\S*) (\\S*) (\\S*)", local_uav.ac_id); - IvyBindMsg(on_Gps, NULL, "^%d GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); - IvyStart("127.255.255.255"); - - // Add Timer - g_timeout_add(delay / 4, timeout_callback, NULL); - - // GTK Window - GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "IVY_Serial_Bridge"); - - g_signal_connect (GTK_OBJECT (window), "delete_event", - G_CALLBACK (delete_event), NULL); - - GtkWidget *box = gtk_vbox_new(TRUE, 1); - gtk_container_add (GTK_CONTAINER (window), box); - - GtkWidget *hbox = gtk_hbox_new(FALSE, 1); - gtk_container_add (GTK_CONTAINER (box), hbox); - status = gtk_label_new( "Status:" ); - gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1); - gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT ); - status = gtk_label_new( status_str ); - gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1); - gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT ); - - hbox = gtk_hbox_new(FALSE, 1); - gtk_container_add (GTK_CONTAINER (box), hbox); - status_ivy = gtk_label_new( "IVY->SERIAL:" ); - gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1); - gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT ); - status_ivy = gtk_label_new( status_ivy_str ); - gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1); - gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT ); - - hbox = gtk_hbox_new(FALSE, 1); - gtk_container_add (GTK_CONTAINER (box), hbox); - status_serial = gtk_label_new( "SERIAL->IVY:" ); - gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1); - gtk_label_set_justify( (GtkLabel*) status_serial, GTK_JUSTIFY_LEFT ); - status_serial = gtk_label_new( status_serial_str ); - gtk_label_set_justify( GTK_LABEL(status_serial), GTK_JUSTIFY_LEFT ); - gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1); - - - gtk_widget_show_all(window); - - gtk_main(); - - // Clean up - fprintf(stderr,"Stopping\n"); - - - return 0; -} - diff --git a/sw/lib/ocaml/META.pprz b/sw/lib/ocaml/META.pprz index b6425281cd..b9e963a9b0 100644 --- a/sw/lib/ocaml/META.pprz +++ b/sw/lib/ocaml/META.pprz @@ -1,5 +1,5 @@ description = "Paparazzi UAS package" -requires = "unix,str,pprzlink,xml-light,lablgtk2,glibivy,netclient,nettls-gnutls" +requires = "unix,str,pprzlink,xml-light,glibivy,netclient,nettls-gnutls" version = "1.0" directory = "" diff --git a/sw/lib/ocaml/Makefile b/sw/lib/ocaml/Makefile index 5461089a12..acca418c66 100644 --- a/sw/lib/ocaml/Makefile +++ b/sw/lib/ocaml/Makefile @@ -30,16 +30,20 @@ include ../../Makefile.ocaml VERBOSITY = INCLUDES= -PKGCOMMON=pprzlink,xml-light,netclient,nettls-gnutls,glibivy,lablgtk2 +PKGCOMMON=pprzlink,xml-light,netclient,nettls-gnutls,glibivy XINCLUDES= -XPKGCOMMON=pprzlink,xml-light,glibivy,lablgtk2 +XPKGCOMMON=pprzlink,xml-light,glibivy,$(USE_LABELGTK) SRC = fig.ml debug.ml base64.ml serial.ml ocaml_tools.ml expr_syntax.ml expr_parser.ml expr_lexer.ml extXml.ml env.ml xml2h.ml latlong.ml egm96.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o ubx.ml xmlCom.ml os_calls.ml editAirframe.ml defivybus.ml fp_proc.ml quaternion.ml SRC += gen_common.ml radio.ml settings.ml module.ml flight_plan.ml autopilot.ml airframe.ml telemetry.ml aircraft.ml CMO = $(SRC:.ml=.cmo) CMX = $(SRC:.ml=.cmx) +ifeq ($(USE_LABELGTK),lablgtk2) XSRC = gtk_tools.ml +else +XSRC = +endif XCMO = $(XSRC:.ml=.cmo) XCMX = $(XSRC:.ml=.cmx) diff --git a/sw/logalizer/Makefile b/sw/logalizer/Makefile index 9a27fba3b9..64de125135 100644 --- a/sw/logalizer/Makefile +++ b/sw/logalizer/Makefile @@ -25,21 +25,25 @@ Q=@ include ../Makefile.ocaml INCLUDES= -PKG = -package glibivy,pprz -LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink +PKG = -package glibivy,pprz,$(USE_LABELGTK) +LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink,$(USE_LABELGTK) LABLGTK2GLADE = $(shell ocamlfind query -p-format lablgtk2.glade 2>/dev/null) +ifeq ($(USE_LABELGTK),lablgtk2) # only compile it lablgtk2.glade is installed ifeq ($(LABLGTK2GLADE),) -XPKG = -package pprz.xlib +XPKG = -package pprz.xlib,lablgtk2 XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg pprz.xlib,pprzlink all : play plotter sd2log plotprofile openlog2tlm sdlogger_download else -XPKG = -package pprz.xlib,lablgtk2.glade +XPKG = -package lablgtk2,pprz.xlib,lablgtk2.glade XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg pprz.xlib,pprzlink all : play plotter logplotter sd2log plotprofile openlog2tlm sdlogger_download endif +else # no gtk2 +all: sd2log plotprofile openlog2tlm sdlogger_download +endif play : log_file.cmo play_core.cmo play.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) diff --git a/sw/simulator/Makefile b/sw/simulator/Makefile index 7669193452..d484a5f58d 100644 --- a/sw/simulator/Makefile +++ b/sw/simulator/Makefile @@ -28,8 +28,8 @@ include ../Makefile.ocaml OCAMLC += -g INCLUDES = -PKG = -package glibivy,pprz -LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink +PKG = -package glibivy,pprz,$(USE_LABELGTK) +LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink,$(USE_LABELGTK) AIRBORNE = ../airborne VARINCLUDE=$(PAPARAZZI_HOME)/var/include @@ -37,7 +37,11 @@ ACINCLUDE = $(PAPARAZZI_HOME)/var/$(AIRCRAFT) CAML_CFLAGS = -I $(shell $(OCAMLC) -where) +ifeq ($(USE_LABELGTK),lablgtk2) all : gaia +else +all : +endif gaia : gaia.cmo $(LIBPPRZCMA) $(LIBPPRZLINKCMA) @echo OL $@ diff --git a/sw/supervision/Makefile b/sw/supervision/Makefile index f6439a4ee7..59b56cdad6 100644 --- a/sw/supervision/Makefile +++ b/sw/supervision/Makefile @@ -32,6 +32,7 @@ else MKTEMP = mktemp endif +ifeq ($(USE_LABELGTK),lablgtk2) LABLGTK2GNOMEUI = $(shell ocamlfind query -p-format lablgtk2-gnome.gnomeui 2>/dev/null) ifeq ($(LABLGTK2GNOMEUI),) LABLGTK2GNOMEUI = $(shell ocamlfind query -p-format lablgtk2.gnomeui 2>/dev/null) @@ -40,18 +41,20 @@ endif LABLGTK2GLADE = $(shell ocamlfind query -p-format lablgtk2.glade 2>/dev/null) INCLUDES = -XPKG = -package pprz.xlib,lablgtk2.glade,$(LABLGTK2GNOMEUI) -XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg pprz.xlib,pprzlink +XPKG = -package lablgtk2,pprz.xlib,lablgtk2.glade,$(LABLGTK2GNOMEUI) +XLINKPKG = $(XPKG) -linkpkg -dllpath-pkg lablgtk2,pprz.xlib,pprzlink PAPARAZZICENTERCMO = gtk_pc.cmo gtk_process.cmo pc_common.cmo pc_control_panel.cmo pc_aircraft.cmo paparazzicenter.cmo - # only compile it lablgtk2.glade is installed -ifeq ($(LABLGTK2GLADE),) +ifneq ($(LABLGTK2GLADE),) +all: paparazzicenter + +endif + +else # no gtk2 all : @echo Skipping legacy Paparazzi Center build -else -all: paparazzicenter endif paparazzicenter : $(PAPARAZZICENTERCMO) $(LIBPPRZCMA) $(LIBPPRZLINKCMA) $(XLIBPPRZCMA)