From: Sangjung Woo Date: Wed, 26 Oct 2016 12:30:10 +0000 (+0900) Subject: client: Add CAN_OBJECT_WRITABLE macro X-Git-Tag: accepted/tizen/3.0/ivi/20161110.022231^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14c3c2fdac670c3429ae2a360ab49829a2d87556;p=profile%2Fivi%2Fautomotive-message-broker.git client: Add CAN_OBJECT_WRITABLE macro In order to send the can frame to specific AMB object, this patch adds CAN_OBJECT_WRITABLE macro. This macro automatically generates the send function related with designated object for developers' convenience Change-Id: I5e024a62da60569918ca268c5752421411da5eae Signed-off-by: Sangjung Woo --- diff --git a/lib/client/libamb-objects.h b/lib/client/libamb-objects.h index c69b733..a554669 100644 --- a/lib/client/libamb-objects.h +++ b/lib/client/libamb-objects.h @@ -151,6 +151,14 @@ CAN_OBJECT(FR_KeyEvent23, gboolean, NULL); CAN_OBJECT(FR_KeyEvent24, gboolean, NULL); +/** + * Writable AMB Object + */ +CAN_OBJECT_WRITABLE(CheckSeatHeaterL, guchar, NULL); +CAN_OBJECT_WRITABLE(CheckSeatHeaterR, guchar, NULL); +CAN_OBJECT_WRITABLE(CheckSeatCoolerL, guchar, NULL); +CAN_OBJECT_WRITABLE(CheckSeatCoolerR, guchar, NULL); + #ifdef __cplusplus } #endif diff --git a/lib/client/libamb-util.h b/lib/client/libamb-util.h index 65772b7..c987e88 100644 --- a/lib/client/libamb-util.h +++ b/lib/client/libamb-util.h @@ -41,6 +41,16 @@ extern "C" { #define g_variant_get_guint64 g_variant_get_uint64 #define g_variant_get_gdouble g_variant_get_double +#define g_variant_new_gboolean g_variant_new_boolean +#define g_variant_new_guchar g_variant_new_byte +#define g_variant_new_gint16 g_variant_new_int16 +#define g_variant_new_guint16 g_variant_new_uint16 +#define g_variant_new_gint32 g_variant_new_int32 +#define g_variant_new_guint32 g_variant_new_uint32 +#define g_variant_new_gint64 g_variant_new_int64 +#define g_variant_new_guint64 g_variant_new_uint64 +#define g_variant_new_gdouble g_variant_new_double + /** * Generate Custom CAN Object data structure and its related utility function. * @@ -49,7 +59,7 @@ extern "C" { * @param[in] Alias name that is used in AMB. If it is NULL, then this value * is ignored. * - * @see amb_release_data() + * @see amb_release_data() CAN_OBJECT_WRITABLE() */ #define CAN_OBJECT(obj_name, value_type, alias_name) \ struct obj_name ## Type { \ @@ -128,6 +138,33 @@ extern "C" { return 0; \ } +/** + * Generate utility function for writable CAN object + * + * @param[in] CAN Object name + * @param[in] data type for CAN object + * @param[in] Alias name that is used in AMB. If it is NULL, then this value + * is ignored. + * + * @see CAN_OBJECT() + */ +#define CAN_OBJECT_WRITABLE(obj_name, value_type, alias_name) \ + int amb_set_ ## obj_name ## _with_zone(value_type value, int zone) \ + { \ + GVariant *variant; \ + int ret; \ + variant = g_variant_new_ ## value_type(value); \ + ret = amb_set_property(#obj_name, \ + g_strcmp0(#alias_name, "NULL") ? #alias_name : "Value", \ + zone, variant);\ + if (ret < 0) { \ + fprintf(stderr, "Fail to amb_set_property: %d\n", ret); \ + return ret; \ + } \ + \ + return 0; \ + } + #ifdef __cplusplus } #endif diff --git a/lib/client/test/test.c b/lib/client/test/test.c index b175b23..7f44f97 100644 --- a/lib/client/test/test.c +++ b/lib/client/test/test.c @@ -404,10 +404,40 @@ static void test_VehicleOdometer_listen() g_main_loop_unref(loop); } +void test_CheckSeatHeaterL() +{ + struct CheckSeatHeaterLType *p; + int ret = amb_get_CheckSeatHeaterL_with_zone(&p, 0); + if (ret != 0) { + fprintf(stderr, "Fail to %s\n", __func__); + return ; + } + fprintf(stderr, "Zone: %d\n", p->Zone); + fprintf(stderr, "Value: %d\n", p->Value); + fprintf(stderr, "ValueSequence: %d\n", p->ValueSequence); + fprintf(stderr, "Time: %f\n", p->Time); + + amb_release_data(p); + return ; +} + +static void test_set_CheckSeatHeaterL(int value) +{ + int rc; + rc = amb_set_CheckSeatHeaterL_with_zone(value, 0); + if (rc < 0) { + fprintf(stderr, "Fail to amb_set_CheckSeatHeaterL_with_zone(): %d\n", rc); + return ; + } + test_CheckSeatHeaterL(); +} int main() { + test_set_CheckSeatHeaterL(1); + test_set_CheckSeatHeaterL(2); + test_VehicleOdometer_listen(); test_FR_KeyEvent01();