[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [5145] Change downlink_transport/ messages2 interfac
From: |
Allen Ibara |
Subject: |
[paparazzi-commits] [5145] Change downlink_transport/ messages2 interface to pass data-type to the transport, in case it wants to know |
Date: |
Fri, 23 Jul 2010 17:38:10 +0000 |
Revision: 5145
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5145
Author: aibara
Date: 2010-07-23 17:38:09 +0000 (Fri, 23 Jul 2010)
Log Message:
-----------
Change downlink_transport/messages2 interface to pass data-type to the
transport, in case it wants to know
Modified Paths:
--------------
paparazzi3/trunk/sw/airborne/downlink_transport.h
paparazzi3/trunk/sw/tools/gen_messages2.ml
Modified: paparazzi3/trunk/sw/airborne/downlink_transport.h
===================================================================
--- paparazzi3/trunk/sw/airborne/downlink_transport.h 2010-07-23 17:12:36 UTC
(rev 5144)
+++ paparazzi3/trunk/sw/airborne/downlink_transport.h 2010-07-23 17:38:09 UTC
(rev 5145)
@@ -32,12 +32,26 @@
#include <inttypes.h>
+enum DownlinkDataType {
+ DL_TYPE_ARRAY_LENGTH = 1,
+ DL_TYPE_UINT8,
+ DL_TYPE_INT8,
+ DL_TYPE_UINT16,
+ DL_TYPE_INT16,
+ DL_TYPE_UINT32,
+ DL_TYPE_INT32,
+ DL_TYPE_UINT64,
+ DL_TYPE_INT64,
+ DL_TYPE_FLOAT,
+ DL_TYPE_DOUBLE,
+};
+
struct DownlinkTransport
{
uint8_t (*SizeOf)(void *impl, uint8_t size);
int (*CheckFreeSpace)(void *impl, uint8_t size);
- void (*PutBytes)(void *impl, uint8_t len, const uint8_t *bytes);
+ void (*PutBytes)(void *impl, enum DownlinkDataType data_type, uint8_t
len, const uint8_t *bytes);
void (*StartMessage)(void *impl, char *name, uint8_t msg_id, uint8_t
payload_len);
void (*EndMessage)(void *impl);
Modified: paparazzi3/trunk/sw/tools/gen_messages2.ml
===================================================================
--- paparazzi3/trunk/sw/tools/gen_messages2.ml 2010-07-23 17:12:36 UTC (rev
5144)
+++ paparazzi3/trunk/sw/tools/gen_messages2.ml 2010-07-23 17:38:09 UTC (rev
5145)
@@ -43,6 +43,18 @@
| "Uint16" -> "uint16_t"
| "Uint8" -> "uint8_t"
| _ -> failwith (sprintf "gen_messages.c_type: unknown format '%s'" format)
+
+let dl_type = fun format ->
+ match format with
+ "Float" -> "DL_TYPE_FLOAT"
+ | "Double" -> "DL_TYPE_DOUBLE"
+ | "Int32" -> "DL_TYPE_INT32"
+ | "Int16" -> "DL_TYPE_INT16"
+ | "Int8" -> "DL_TYPE_INT8"
+ | "Uint32" -> "DL_TYPE_UINT32"
+ | "Uint16" -> "DL_TYPE_UINT16"
+ | "Uint8" -> "DL_TYPE_UINT8"
+ | _ -> failwith (sprintf "gen_messages.c_type: unknown format '%s'" format)
type field = _type * string * format option
@@ -127,11 +139,11 @@
let print_field = fun h (t, name, (_f: format option)) ->
match t with
Basic _ ->
- fprintf h "\t tp->PutBytes(tp->impl, %s, (uint8_t *) _%s); \n"
(Syntax.sizeof t) name
+ fprintf h "\t tp->PutBytes(tp->impl, %s, %s, (uint8_t *) _%s); \n"
(dl_type (Syntax.nameof t)) (Syntax.sizeof t) name
| Array (t, varname) ->
let _s = Syntax.sizeof (Basic t) in
- fprintf h "\t tp->PutBytes(tp->impl, 1, (uint8_t *) &%s); \n"
(Syntax.length_name varname);
- fprintf h "\t tp->PutBytes(tp->impl, %s * %s, (uint8_t *) _%s); \n"
(Syntax.sizeof (Basic t)) (Syntax.length_name varname) name
+ fprintf h "\t tp->PutBytes(tp->impl, DL_TYPE_ARRAY_LENGTH, 1, (uint8_t
*) &%s); \n" (Syntax.length_name varname);
+ fprintf h "\t tp->PutBytes(tp->impl, %s, %s * %s, (uint8_t *) _%s);
\n" (dl_type (Syntax.nameof (Basic t))) (Syntax.sizeof (Basic t))
(Syntax.length_name varname) name
let print_parameter h = function
(Array (t, varname), s, _) -> fprintf h "uint8_t %s, %s *_%s"
(Syntax.length_name s) (c_type (Syntax.nameof (Basic t))) s
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [5145] Change downlink_transport/ messages2 interface to pass data-type to the transport, in case it wants to know,
Allen Ibara <=