[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [6377] Have an adequate button
From: |
Martin Mueller |
Subject: |
[paparazzi-commits] [6377] Have an adequate button |
Date: |
Sun, 07 Nov 2010 23:48:19 +0000 |
Revision: 6377
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=6377
Author: mmm
Date: 2010-11-07 23:48:18 +0000 (Sun, 07 Nov 2010)
Log Message:
-----------
Have an adequate button
Added Paths:
-----------
paparazzi3/trunk/sw/in_progress/button/
paparazzi3/trunk/sw/in_progress/button/Makefile
paparazzi3/trunk/sw/in_progress/button/panic.c
Added: paparazzi3/trunk/sw/in_progress/button/Makefile
===================================================================
--- paparazzi3/trunk/sw/in_progress/button/Makefile
(rev 0)
+++ paparazzi3/trunk/sw/in_progress/button/Makefile 2010-11-07 23:48:18 UTC
(rev 6377)
@@ -0,0 +1,113 @@
+#
+# $Id: Makefile 5874 2010-09-15 03:41:04Z aibara $
+# Copyright (C) 2004 Pascal Brisset, Antoine Drouin
+#
+# This file is part of paparazzi.
+#
+# paparazzi 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 2, or (at your option)
+# any later version.
+#
+# paparazzi 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 paparazzi; see the file COPYING. If not, write to
+# the Free Software Foundation, 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+# Quiet compilation
+Q=@
+
+OCAMLC = ocamlc
+OCAMLOPT = ocamlopt
+INCLUDES= -I +xml-light -I +lablgtk2 -I ../../lib/ocaml
+
+all: panic
+
+$^
+
+
+play play-nox plotter sd2log : ../../lib/ocaml/lib-pprz.cma
+plot : ../../lib/ocaml/lib-pprz.cmxa
+
+# Target for bytecode executable (if ocamlopt is not available)
+# plot : log_file.cmo gtk_export.cmo export.cmo plot.cmo
+# @echo OL $@
+# $(Q)$(OCAMLC) $(INCLUDES) -o $@ unix.cma str.cma xml-light.cma
glibivy-ocaml.cma lablgtk.cma lib-pprz.cma lablglade.cma gtkInit.cmo $^
+
+%.cmo: %.ml
+ @echo OC $<
+ $(Q)$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES) -c $<
+%.cmi: %.mli
+ @echo OCI $<
+ $(Q)$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES) -c $<
+%.cmx: %.ml
+ @echo OOC $<
+ $(Q)$(OCAMLOPT) $(OCAMLCFLAGS) $(INCLUDES) -c $<
+
+export.cmo : gtk_export.cmo
+export.cmx : gtk_export.cmx
+
+gtk_export.ml : export.glade
+ grep -v invisible_char $< > /tmp/$<
+ lablgladecc2 -root export -hide-default /tmp/$< | grep -B 1000000 "
end" > $@
+
+
+
+pt : ahrsview imuview ahrs2fg
+
+CC = gcc
+CFLAGS=-g -O2 -Wall `pkg-config gtk+-2.0 --cflags`
+LDFLAGS=`pkg-config gtk+-2.0 --libs` -s -lgtkdatabox `pcre-config --libs`
-lglibivy
+
+MORE_FLAGS = -I/usr/include/gtk-1.2 -I/usr/include/glib-1.2
-I/usr/lib/glib/include -rdynamic /usr/lib/libgtkgl.so -L/usr/lib
-L/usr/X11R6/lib /usr/lib/libgtk.so /usr/lib/libgdk.so /usr/lib/libgmodule.so
/usr/lib/libglib.so -ldl -lXi -lXext -lX11 -lm -lGLU -lGL -Wl,--rpath
-Wl,/usr/local/lib `pcre-config --libs` -lglibivy
+
+MORE_CFLAGS = -DHAVE_DLFCN_H=1 -DSTDC_HEADERS=1 -I. -I. -I.. -g -O2
-I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include
+
+clean:
+ rm -f *.opt *.out *~ core *.o *.bak .depend *.cm* panic
+
+#FGFS_PREFIX=/home/poine/local
+FGFS_PREFIX=/home/poine/flightgear
+#FGFS_PREFIX=/usr/local
+
+#FGFS_ROOT = /home/poine/local
+FGFS_ROOT = /home/poine/flightgear
+FGFS = $(FGFS_PREFIX)/bin/fgfs
+#FGFS = /usr/games/fgfs
+#FGFS_ENV = LD_LIBRARY_PATH=/usr/local/lib:$(FGFS_ROOT)/lib
+FGFS_ENV = LD_LIBRARY_PATH=$(FGFS_ROOT)/lib
+FGFS_COMMON_ARGS = --fg-root=$(FGFS_ROOT) --aircraft=A320 --timeofday=noon
+#FGFS_COMMON_ARGS = --aircraft=737-300 --timeofday=noon
+FGFS_IN_FDM_ARGS = $(FGFS_COMMON_ARGS) --fdm=null
--native-fdm=socket,in,30,,5501,udp
+FGFS_OUT_FDM_ARGS = $(FGFS_COMMON_ARGS) --native-fdm=socket,out,30,,5500,udp
+FGFS_IN_GUI_ARGS = $(FGFS_COMMON_ARGS) --fdm=null
--native-gui=socket,in,30,,5501,udp
+FGFS_OUT_GUI_ARGS = $(FGFS_COMMON_ARGS) --native-gui=socket,out,30,,5500,udp
+FGFS_IN_CTRLS_ARGS = $(FGFS_COMMON_ARGS) --native-ctrls=socket,in,30,,5501,udp
+FGFS_OUT_CTRLS_ARGS = $(FGFS_COMMON_ARGS)
--native-ctrls=socket,out,30,,5500,udp
+FGFS_OUT_MULTIPLAY_ARGS = $(FGFS_COMMON_ARGS)
--multiplay=out,10,127.0.0.1,5500 --callsign=F-POINE
+FGFS_IN_MULTIPLAY_ARGS = $(FGFS_COMMON_ARGS) --multiplay=in,10,127.0.0.1,5501
--callsign=F-POINE
+FGFS_RCAM_ARGS = $(FGFS_COMMON_ARGS) --fdm=null
--native-ctrls=socket,out,30,,5500,udp --native-fdm=socket,in,30,,5501,udp
+FGFS_GAME_ARGS = $(FGFS_COMMON_ARGS) --control=joystick
+
+FGFS_ARGS = $(FGFS_COMMON_ARGS) $(FGFS_IN_GUI_ARGS)
+#FGFS_GAME_ARGS)
+
+panic: panic.c
+ gcc -g -O2 -Wall `pkg-config glib-2.0 --cflags` -o $@ $^ `pkg-config
glib-2.0 --libs` `pcre-config --libs` -lglibivy -lhid
+
+#
+# Dependencies
+#
+
+.depend: Makefile
+ ocamldep -I ../../lib/ocaml *.ml* > .depend
+
+ifneq ($(MAKECMDGOALS),clean)
+-include .depend
+endif
Added: paparazzi3/trunk/sw/in_progress/button/panic.c
===================================================================
--- paparazzi3/trunk/sw/in_progress/button/panic.c
(rev 0)
+++ paparazzi3/trunk/sw/in_progress/button/panic.c 2010-11-07 23:48:18 UTC
(rev 6377)
@@ -0,0 +1,155 @@
+/*==============================================
+ PoC for USB Panic Button under unix
+ --------------------------------------------
+ by: Benjamin Kendinibilir
+ needs: libusb and libhid
+ compile: gcc usbpanicbutton.c -o upb -lhid
+ run: sudo ./upb (needs root)
+ ==============================================*/
+
+#include <hid.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+#include <glib.h>
+#include <sys/ioctl.h>
+#include <Ivy/ivy.h>
+#include <Ivy/ivyglibloop.h>
+
+#define VENDOR_ID 0x1130
+#define PRODUCT_ID 0x0202
+#define IFACE_NO 0
+#define PACKET_SIZE 8
+#define PATH1 0x00010000
+#define PATH2 0x00000000
+#define PATH_LEN 2
+
+#define TIMEOUT_PERIOD 20
+
+int loop = 1;
+hid_return ret;
+HIDInterface* hid;
+char packet[PACKET_SIZE];
+int const path_out[] = { PATH1, PATH2 };
+HIDInterfaceMatcher matcher = { VENDOR_ID, PRODUCT_ID, NULL, NULL, 0 };
+GMainLoop *ml;
+int ac_id, block_nr;
+
+void endloop(int signum) {
+ loop = 0;
+ g_main_loop_quit(ml);
+}
+
+int btn_init(void) {
+
+ #ifdef DEBUG
+ hid_set_debug(HID_DEBUG_ALL);
+ hid_set_debug_stream(stderr);
+ hid_set_usb_debug(0);
+ #endif
+
+ ret = hid_init();
+ if (ret != HID_RET_SUCCESS) {
+ fprintf(stderr, "hid_init failed with return code %d\n", ret);
+ return 1;
+ }
+
+ hid = hid_new_HIDInterface();
+ if (hid == 0) {
+ fprintf(stderr, "hid_new_HIDInterface() failed, out of
memory?\n");
+ return 1;
+ }
+
+ ret = hid_force_open(hid, IFACE_NO, &matcher, 3);
+ if (ret != HID_RET_SUCCESS) {
+ fprintf(stderr, "hid_force_open failed with return code %d\n",
ret);
+ return 1;
+ }
+
+ #ifdef DEBUG
+ ret = hid_write_identification(stdout, hid);
+ if (ret != HID_RET_SUCCESS) {
+ fprintf(stderr, "hid_write_identification failed with return
code %d\n", ret);
+ return 1;
+ }
+
+ ret = hid_dump_tree(stdout, hid);
+ if (ret != HID_RET_SUCCESS) {
+ fprintf(stderr, "hid_dump_tree failed with return code %d\n",
ret);
+ return 1;
+ }
+ #endif
+
+ signal(SIGINT, endloop);
+ signal(SIGHUP, endloop);
+ signal(SIGTERM, endloop);
+
+ printf("waiting for panic button action:\n");
+
+ return 0;
+}
+
+static gboolean btn_periodic(gpointer data __attribute__ ((unused))) {
+
+ ret = hid_get_input_report(hid, path_out, PATH_LEN, packet,
PACKET_SIZE);
+ if (ret != HID_RET_SUCCESS) {
+ fprintf(stderr, "hid_get_input_report failed with return code
%d\n", ret);
+ }
+
+ if(packet[0] == 0x1) {
+ IvySendMsg("dl JUMP_TO_BLOCK %d %d", ac_id, block_nr);
+ printf("\aplop\n");
+ fflush(stdout);
+ }
+
+ return loop;
+}
+
+int btn_close(void) {
+
+ printf("cleaning up... ");
+
+ ret = hid_close(hid);
+ if (ret != HID_RET_SUCCESS) {
+ fprintf(stderr, "hid_close failed with return code %d\n", ret);
+ return 1;
+ }
+
+ hid_delete_HIDInterface(&hid);
+
+ ret = hid_cleanup();
+ if (ret != HID_RET_SUCCESS) {
+ fprintf(stderr, "hid_cleanup failed with return code %d\n",
ret);
+ return 1;
+ }
+
+ printf("exit.\n");
+
+ return 0;
+}
+
+
+int main(int argc, char** argv) {
+
+ if (argc != 3) {
+ printf("usage: panic <ac_id> <block_nr>\n");
+ return 1;
+ }
+ ac_id = strtol(argv[1], NULL, 10);
+ block_nr = strtol(argv[2], NULL, 10);
+
+ ml = g_main_loop_new(NULL, FALSE);
+
+ IvyInit ("IvyCtrlButton", "IvyCtrlButton READY", NULL, NULL, NULL,
NULL);
+ IvyStart("127.255.255.255");
+
+ btn_init();
+
+ g_timeout_add(TIMEOUT_PERIOD, btn_periodic, NULL);
+ g_main_loop_run(ml);
+
+ btn_close();
+
+ return 0;
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [6377] Have an adequate button,
Martin Mueller <=