[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [4772] more test programs
From: |
antoine drouin |
Subject: |
[paparazzi-commits] [4772] more test programs |
Date: |
Tue, 30 Mar 2010 17:50:00 +0000 |
Revision: 4772
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4772
Author: poine
Date: 2010-03-30 17:50:00 +0000 (Tue, 30 Mar 2010)
Log Message:
-----------
more test programs
Modified Paths:
--------------
paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h
paparazzi3/trunk/sw/airborne/fms/fms_spi_link.c
paparazzi3/trunk/sw/airborne/fms/fms_spi_link.h
paparazzi3/trunk/sw/airborne/fms/udp_transport.h
Added Paths:
-----------
paparazzi3/trunk/sw/airborne/fms/overo_test_link.c
paparazzi3/trunk/sw/airborne/fms/overo_test_telemetry.c
Modified: paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h
===================================================================
--- paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h 2010-03-30
17:48:40 UTC (rev 4771)
+++ paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h 2010-03-30
17:50:00 UTC (rev 4772)
@@ -4,9 +4,9 @@
#include <inttypes.h>
struct AutopilotMessageFoo {
- uint32_t foo;
- uint32_t bar;
- uint32_t blaa;
+ uint8_t foo;
+ uint8_t bar;
+ uint8_t blaa;
};
Modified: paparazzi3/trunk/sw/airborne/fms/fms_spi_link.c
===================================================================
--- paparazzi3/trunk/sw/airborne/fms/fms_spi_link.c 2010-03-30 17:48:40 UTC
(rev 4771)
+++ paparazzi3/trunk/sw/airborne/fms/fms_spi_link.c 2010-03-30 17:50:00 UTC
(rev 4772)
@@ -36,15 +36,14 @@
return 0;
}
-int spi_link_send(const void *buf_out, size_t count) {
+int spi_link_send(const void *buf_out, size_t count, void *buf_in) {
+
int ret;
- char buf_in[256]; /* FIXME, check size ? */
-
struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)buf_out,
- .rx_buf = (unsigned long)&buf_in,
- .len = sizeof(*buf_out),
+ .rx_buf = (unsigned long)buf_in,
+ .len = count,
.delay_usecs = spi_link.delay,
.speed_hz = spi_link.speed,
.bits_per_word = spi_link.bits,
@@ -52,4 +51,5 @@
ret = ioctl(spi_link.fd, SPI_IOC_MESSAGE(1), &tr);
return ret;
+
}
Modified: paparazzi3/trunk/sw/airborne/fms/fms_spi_link.h
===================================================================
--- paparazzi3/trunk/sw/airborne/fms/fms_spi_link.h 2010-03-30 17:48:40 UTC
(rev 4771)
+++ paparazzi3/trunk/sw/airborne/fms/fms_spi_link.h 2010-03-30 17:50:00 UTC
(rev 4772)
@@ -16,6 +16,6 @@
struct SpiLink spi_link;
extern int spi_link_init(void);
-extern int spi_link_send(const void *buf, size_t count);
+extern int spi_link_send(const void *buf_out, size_t count, void* buf_in);
#endif /* FMS_SPI_LINK_H */
Added: paparazzi3/trunk/sw/airborne/fms/overo_test_link.c
===================================================================
--- paparazzi3/trunk/sw/airborne/fms/overo_test_link.c
(rev 0)
+++ paparazzi3/trunk/sw/airborne/fms/overo_test_link.c 2010-03-30 17:50:00 UTC
(rev 4772)
@@ -0,0 +1,53 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2008-2009 Antoine Drouin <address@hidden>
+ *
+ * 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.
+ */
+
+#include <stdint.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#include "fms_spi_link.h"
+#include "fms_autopilot_msg.h"
+
+
+int main(int argc, char *argv[]) {
+
+ if (spi_link_init())
+ return -1;
+ uint32_t foo = 0;
+ while (1) {
+ struct AutopilotMessageFoo msg_out;
+ msg_out.foo = foo;
+ msg_out.bar = foo;
+ msg_out.blaa = foo;
+ struct AutopilotMessageFoo msg_in;
+ spi_link_send(&msg_out, sizeof(struct AutopilotMessageFoo), &msg_in);
+ printf("%d %d %d\n", msg_in.foo, msg_in.bar, msg_in.blaa);
+ // usleep(1953);
+ usleep(50000);
+ foo++;
+ }
+
+ return 0;
+}
Added: paparazzi3/trunk/sw/airborne/fms/overo_test_telemetry.c
===================================================================
--- paparazzi3/trunk/sw/airborne/fms/overo_test_telemetry.c
(rev 0)
+++ paparazzi3/trunk/sw/airborne/fms/overo_test_telemetry.c 2010-03-30
17:50:00 UTC (rev 4772)
@@ -0,0 +1,67 @@
+
+#include <inttypes.h>
+
+#include <stdio.h>
+
+#include <event.h>
+#include <evutil.h>
+
+#include "downlink.h"
+#include "udp_transport.h"
+#include "fms_network.h"
+
+#define GCS_HOST "10.31.4.7"
+#define GCS_PORT 4242
+#define DATALINK_PORT 4243
+
+#define TIMEOUT_DT_SEC 0
+//#define TIMEOUT_DT_USEC 500000
+#define TIMEOUT_DT_USEC 50000
+
+
+#define ADD_TIMEOUT() { \
+ struct timeval tv; \
+ evutil_timerclear(&tv); \
+ tv.tv_sec = TIMEOUT_DT_SEC; \
+ tv.tv_usec = TIMEOUT_DT_USEC; \
+ event_add(&timeout, &tv); \
+ }
+
+static void timeout_cb(int fd, short event, void *arg);
+
+static struct event timeout;
+static struct FmsNetwork* network;
+
+void timeout_cb(int fd, short event, void *arg) {
+
+ // printf("in timeout_cb\n");
+
+ DOWNLINK_SEND_ALIVE(DefaultChannel, 16, MD5SUM);
+
+ float foof = 3.14159265358979323846;
+ double food = 3.14159265358979323846;
+ DOWNLINK_SEND_TEST_FORMAT(DefaultChannel, &food, &foof);
+
+ UdpTransportPeriodic();
+
+ ADD_TIMEOUT();
+
+}
+
+
+int main(int argc, char** argv) {
+
+ network = network_new(GCS_HOST, GCS_PORT, DATALINK_PORT, FALSE);
+
+ /* Initalize the event library */
+ event_init();
+
+ /* Add a timeout event */
+ evtimer_set(&timeout, timeout_cb, &timeout);
+
+ ADD_TIMEOUT();
+
+ event_dispatch();
+
+ return 0;
+}
Modified: paparazzi3/trunk/sw/airborne/fms/udp_transport.h
===================================================================
--- paparazzi3/trunk/sw/airborne/fms/udp_transport.h 2010-03-30 17:48:40 UTC
(rev 4771)
+++ paparazzi3/trunk/sw/airborne/fms/udp_transport.h 2010-03-30 17:50:00 UTC
(rev 4772)
@@ -85,25 +85,31 @@
UdpTransportPutUint8(_x); \
}
-#define UdpTransportPut2ByteByAddr(_byte) { \
- UdpTransportPut1ByteByAddr(_byte); \
+#define UdpTransportPut2ByteByAddr(_byte) { \
+ UdpTransportPut1ByteByAddr(_byte); \
UdpTransportPut1ByteByAddr((const uint8_t*)_byte+1); \
}
-#define UdpTransportPut4ByteByAddr(_byte) { \
- UdpTransportPut2ByteByAddr(_byte); \
+#define UdpTransportPut4ByteByAddr(_byte) { \
+ UdpTransportPut2ByteByAddr(_byte); \
UdpTransportPut2ByteByAddr((const uint8_t*)_byte+2); \
}
+#define UdpTransportPut8ByteByAddr(_byte) { \
+ UdpTransportPut4ByteByAddr(_byte); \
+ UdpTransportPut4ByteByAddr((const uint8_t*)_byte+4); \
+ }
+
/* base types */
-#define UdpTransportPutInt8ByAddr(_x) UdpTransportPut1ByteByAddr(_x)
-#define UdpTransportPutUint8ByAddr(_x) UdpTransportPut1ByteByAddr((const
uint8_t*)_x)
-#define UdpTransportPutInt16ByAddr(_x) UdpTransportPut2ByteByAddr((const
uint8_t*)_x)
+#define UdpTransportPutInt8ByAddr(_x) UdpTransportPut1ByteByAddr(_x)
+#define UdpTransportPutUint8ByAddr(_x) UdpTransportPut1ByteByAddr((const
uint8_t*)_x)
+#define UdpTransportPutInt16ByAddr(_x) UdpTransportPut2ByteByAddr((const
uint8_t*)_x)
#define UdpTransportPutUint16ByAddr(_x) UdpTransportPut2ByteByAddr((const
uint8_t*)_x)
-#define UdpTransportPutInt32ByAddr(_x) UdpTransportPut4ByteByAddr((const
uint8_t*)_x)
+#define UdpTransportPutInt32ByAddr(_x) UdpTransportPut4ByteByAddr((const
uint8_t*)_x)
#define UdpTransportPutUint32ByAddr(_x) UdpTransportPut4ByteByAddr((const
uint8_t*)_x)
-#define UdpTransportPutFloatByAddr(_x) UdpTransportPut4ByteByAddr((const
uint8_t*)_x)
+#define UdpTransportPutFloatByAddr(_x) UdpTransportPut4ByteByAddr((const
uint8_t*)_x)
+#define UdpTransportPutDoubleByAddr(_x) UdpTransportPut8ByteByAddr((const
uint8_t*)_x)
#define UdpTransportPutArray(_put, _n, _x) { \
uint8_t _i; \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [4772] more test programs,
antoine drouin <=