From 6c70b98aecc7fcaab4988b210aa4ea8ad96bbe25 Mon Sep 17 00:00:00 2001 From: Antoine Drouin Date: Mon, 23 Mar 2009 19:07:36 +0000 Subject: [PATCH] *** empty log message *** --- conf/autopilot/booz2_test_progs.makefile | 18 +++++++++++++----- sw/airborne/fms/Makefile | 2 +- sw/airborne/fms/fms_ap_link.c | 4 ++-- sw/airborne/fms/fms_main.c | 22 +++++++++++++++++----- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/conf/autopilot/booz2_test_progs.makefile b/conf/autopilot/booz2_test_progs.makefile index fa9a844437..218c032cba 100644 --- a/conf/autopilot/booz2_test_progs.makefile +++ b/conf/autopilot/booz2_test_progs.makefile @@ -140,17 +140,25 @@ test_usb.ARCH = arm7tdmi test_usb.TARGET = test_usb test_usb.TARGETDIR = test_usb -test_usb.CFLAGS += -DCONFIG=$(BOARD_CFG) $(BOOZ_CFLAGS) +test_usb.CFLAGS += -DCONFIG=\"booz2_board_usb.h\" $(BOOZ_CFLAGS) test_usb.srcs += $(SRC_BOOZ_TEST)/booz2_test_usb.c test_usb.CFLAGS += -DPERIODIC_TASK_PERIOD='SYS_TICS_OF_SEC((1./512.))' -DTIME_LED=1 test_usb.CFLAGS += -DLED test_usb.srcs += sys_time.c $(SRC_ARCH)/sys_time_hw.c $(SRC_ARCH)/armVIC.c -test_usb.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 -test_usb.srcs += $(SRC_ARCH)/uart_hw.c +#test_usb.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B57600 +#test_usb.srcs += $(SRC_ARCH)/uart_hw.c +#test_usb.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1 +#test_usb.srcs += downlink.c pprz_transport.c + +test_usb.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DUSE_USB_SERIAL +test_usb.CFLAGS += -DDOWNLINK_DEVICE=UsbS -DPPRZ_UART=UsbS -DDATALINK=PPRZ +test_usb.srcs += downlink.c $(SRC_ARCH)/uart_hw.c $(SRC_ARCH)/usb_ser_hw.c pprz_transport.c +# datalink.c +test_usb.srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c +test_usb.srcs += $(SRC_ARCH)/lpcusb/usbstdreq.c $(SRC_ARCH)/lpcusb/usbinit.c + -test_usb.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DDOWNLINK_DEVICE=Uart1 -test_usb.srcs += downlink.c pprz_transport.c diff --git a/sw/airborne/fms/Makefile b/sw/airborne/fms/Makefile index 3aa2f7c521..d7fa4be1a0 100644 --- a/sw/airborne/fms/Makefile +++ b/sw/airborne/fms/Makefile @@ -1,5 +1,5 @@ -CFLAGS = -Wall `pkg-config --cflags glib-2.0` +CFLAGS = -Wall `pkg-config --cflags glib-2.0` -g LDFLAGS = `pkg-config --libs glib-2.0` fms: fms_main.c fms_ap_link.c fms_serial_port.c fms_gs_link.c fms_network.c diff --git a/sw/airborne/fms/fms_ap_link.c b/sw/airborne/fms/fms_ap_link.c index 16a3e218a0..f32e01b27a 100644 --- a/sw/airborne/fms/fms_ap_link.c +++ b/sw/airborne/fms/fms_ap_link.c @@ -11,7 +11,7 @@ struct FmsApLink* ap_link_new(const char* device) { struct FmsApLink* me = malloc(sizeof(struct FmsApLink)); me->sp = serial_port_new(); - if (!serial_port_open(me->sp, device, configure_term)) { + if (serial_port_open(me->sp, device, configure_term)) { ap_link_free(me); return NULL; } @@ -33,7 +33,7 @@ void ap_link_free(struct FmsApLink* me) { void ap_link_parse(struct FmsApLink* me, int nb_bytes) { - + printf("got %d bytes\n", nb_bytes); } diff --git a/sw/airborne/fms/fms_main.c b/sw/airborne/fms/fms_main.c index fc2f7227c6..4eef40a93d 100644 --- a/sw/airborne/fms/fms_main.c +++ b/sw/airborne/fms/fms_main.c @@ -1,7 +1,9 @@ #include -#define AP_DEVICE "/dev/ttyUSB0" +#include + +#define AP_DEVICE "/dev/ttyACM0" #define GS_IP "192.168.1.8" #define GS_PORT 2442 @@ -25,6 +27,12 @@ static gboolean on_ap_link_data_received(GIOChannel *source, gsize bytes_read; GError* _err = NULL; GIOStatus st = g_io_channel_read_chars(source, ap_link->buf, AP_LINK_BUF_SIZE, &bytes_read, &_err); + printf("in on_ap_link_data_received %d %d\n", st, _err); + if (_err != NULL) { + fprintf (stderr, "error reading serial: %s\n", _err->message); + g_error_free (_err); + + } if (st == G_IO_STATUS_NORMAL) { ap_link_parse(ap_link, bytes_read); } @@ -42,14 +50,18 @@ int main(int argc, char** argv) { struct FmsApLink* ap_link; struct FmsGsLink* gs_link; - ap_link = ap_link_new(AP_DEVICE); + if (!ap_link) { + printf("error opening serial port %s\n", AP_DEVICE); + return -1; + } GIOChannel* ioc1 = g_io_channel_unix_new(ap_link->sp->fd); + g_io_channel_set_encoding(ioc1, NULL, NULL); g_io_add_watch (ioc1, G_IO_IN, on_ap_link_data_received, ap_link); - gs_link = gs_link_new(GS_IP, GS_PORT); - GIOChannel* ioc2 = g_io_channel_unix_new(gs_link->network->fd); - g_io_add_watch (ioc2, G_IO_IN, on_gs_link_data_received, ap_link); + // gs_link = gs_link_new(GS_IP, GS_PORT); + // GIOChannel* ioc2 = g_io_channel_unix_new(gs_link->network->fd); + // g_io_add_watch (ioc2, G_IO_IN, on_gs_link_data_received, ap_link); GMainLoop* ml = g_main_loop_new(NULL, FALSE); g_main_loop_run(ml);