Added new control message timezone.
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Mon, 9 Dec 2013 12:52:31 +0000 (13:52 +0100)
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Fri, 10 Jan 2014 06:16:04 +0000 (07:16 +0100)
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
include/dlt/dlt_common.h
include/dlt/dlt_protocol.h
src/daemon/dlt-daemon.c
src/daemon/dlt-daemon.h
src/daemon/dlt.conf
src/daemon/dlt_daemon_common.c
src/daemon/dlt_daemon_common.h

index 0740c9e..22710c7 100755 (executable)
@@ -520,6 +520,17 @@ typedef struct
 } PACKED DltServiceConnectionInfo;
 
 /**
+ * The structure of the DLT Service Timezone
+ */
+typedef struct
+{
+    uint32_t service_id;            /**< service ID */
+    uint8_t status;                 /**< reponse status */
+    int32_t timezone;               /**< Timezone in seconds */
+    uint8_t isdst;                  /**< Is daylight saving time */
+} PACKED DltServiceTimezone;
+
+/**
  * Structure to store filter parameters.
  * ID are maximal four characters. Unused values are filled with zeros.
  * If every value as filter is valid, the id should be empty by having only zero values.
index 7e941fe..09e4adc 100755 (executable)
 #define DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW         0x14 /**< Service ID: Message buffer overflow */\r
 #define DLT_SERVICE_ID_UNREGISTER_CONTEXT             0xf01 /**< Service ID: Message unregister context */\r
 #define DLT_SERVICE_ID_CONNECTION_INFO                0xf02 /**< Service ID: Message connection info */\r
+#define DLT_SERVICE_ID_TIMEZONE                                                  0xf03 /**< Service ID: Timezone */\r
 #define DLT_SERVICE_ID_CALLSW_CINJECTION              0xFFF /**< Service ID: Message Injection (minimal ID) */\r
 \r
 /*\r
index 00ac525..78d232f 100644 (file)
@@ -209,6 +209,7 @@ int option_file_parser(DltDaemonLocal *daemon_local)
        daemon_local->timeoutOnSend = 4;
        daemon_local->flags.sendECUSoftwareVersion = 0;
        memset(daemon_local->flags.pathToECUSoftwareVersion, 0, sizeof(daemon_local->flags.pathToECUSoftwareVersion));
+       daemon_local->flags.sendTimezone = 0;
 
        /* open configuration file */
        if(daemon_local->flags.cvalue[0])
@@ -365,7 +366,11 @@ int option_file_parser(DltDaemonLocal *daemon_local)
                                                         strncpy(daemon_local->flags.pathToECUSoftwareVersion,value,sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1);
                                                        //printf("Option: %s=%s\n",token,value);
                                                }
-
+                                               else if(strcmp(token,"SendTimezone")==0)
+                                               {
+                                                       daemon_local->flags.sendTimezone = atoi(value);
+                                                       //printf("Option: %s=%s\n",token,value);
+                                               }
                                                else
                                                {
                                                        fprintf(stderr, "Unknown option: %s=%s\n",token,value);
@@ -471,7 +476,7 @@ int main(int argc, char* argv[])
     create_timer_fd(&daemon_local, 1, 1, &daemon_local.timer_timingpacket, "Timing packet");
 
     // create fd for timer ecu version
-    if(daemon_local.flags.sendECUSoftwareVersion > 0)
+    if(daemon_local.flags.sendECUSoftwareVersion > 0 || daemon_local.flags.sendTimezone > 0)
     {
         //dlt_daemon_init_ecuversion(&daemon_local);
         create_timer_fd(&daemon_local, 60, 60, &daemon_local.timer_ecuversion, "ECU version");
@@ -2751,6 +2756,7 @@ void dlt_daemon_send_timingpacket(DltDaemon *daemon, DltDaemonLocal *daemon_loca
                 {
                     dlt_log(LOG_DEBUG, "timingpacket\n");
                     dlt_daemon_control_message_time(j, daemon, daemon_local->flags.vflag);
+
                 }
             }
         }
@@ -2774,7 +2780,17 @@ void dlt_daemon_send_ecuversion(DltDaemon *daemon, DltDaemonLocal *daemon_local)
                        && (j!=daemon_local->timer_timingpacket) && (j!=daemon_local->timer_ecuversion))
             {
                 dlt_log(LOG_DEBUG, "ecu_version\n");
-                               dlt_daemon_control_get_software_version(j, daemon, daemon_local->flags.vflag);
+                if(daemon_local->flags.sendECUSoftwareVersion > 0)
+                       dlt_daemon_control_get_software_version(j, daemon, daemon_local->flags.vflag);
+
+                if(daemon_local->flags.sendTimezone > 0)
+                {
+                                       // send timezone information
+                                       time_t t = time(NULL);
+                                       struct tm lt = {0};
+                                       localtime_r(&t, &lt);
+                                       dlt_daemon_control_message_timezone(j,daemon,(int32_t) lt.tm_gmtoff,(uint8_t) lt.tm_isdst,daemon_local->flags.vflag);
+                }
             }
         }
     }
@@ -2806,6 +2822,7 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_
 
        dlt_daemon_control_message_connection_info(DLT_DAEMON_STORE_TO_BUFFER,daemon,DLT_CONNECTION_STATUS_DISCONNECTED,"",verbose);
 }
+
 /**
   \}
 */
index 46321a7..b7ffb55 100755 (executable)
@@ -105,6 +105,7 @@ typedef struct
     char loggingFilename[256]; /**< (String: Filename) The logging filename if internal logging mode is log to file (Default: /tmp/log) */\r
     int  sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */\r
     char pathToECUSoftwareVersion[256]; /**< (String: Filename) The file from which to read the ECU version from. */\r
+    int  sendTimezone; /**< (Boolean) Send Timezone perdiodically */\r
 } DltDaemonFlags;\r
 \r
 /**\r
index e09129a..a079d3e 100644 (file)
@@ -101,3 +101,10 @@ TimeOutOnSend = 4
 
 # Absolute path to file storing version info - otherwise DLT version is used
 # PathToECUSoftwareVersion = <absolute-path-to-file>
+
+########################################################################
+# Timezone info                                                        #
+########################################################################
+
+# Send periodic timezone info (Default: 0)
+# SendTimezone = 0
\ No newline at end of file
index bbd058d..df9ccbe 100644 (file)
@@ -2631,7 +2631,7 @@ int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, c
     resp->service_id = DLT_SERVICE_ID_UNREGISTER_CONTEXT;
     resp->status = DLT_SERVICE_RESPONSE_OK;
        dlt_set_id(resp->apid, apid);
-       dlt_set_id(resp->apid, ctid);
+       dlt_set_id(resp->ctid, ctid);
        dlt_set_id(resp->comid, comid);
 
     /* send message */
@@ -2704,3 +2704,61 @@ int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, uint
 
     return 0;
 }
+
+int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, int32_t timezone, uint8_t isdst, int verbose)
+{
+    DltMessage msg;
+    DltServiceTimezone *resp;
+
+    PRINT_FUNCTION_VERBOSE(verbose);
+
+    if (daemon==0)
+    {
+        return -1;
+    }
+
+    /* initialise new message */
+    if (dlt_message_init(&msg,0)==-1)
+    {
+       dlt_daemon_control_service_response(sock, daemon, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR,  verbose);
+       return -1;
+    }
+
+    /* prepare payload of data */
+    msg.datasize = sizeof(DltServiceTimezone);
+    if (msg.databuffer && (msg.databuffersize < msg.datasize))
+    {
+        free(msg.databuffer);
+        msg.databuffer=0;
+    }
+    if (msg.databuffer == 0){
+       msg.databuffer = (uint8_t *) malloc(msg.datasize);
+       msg.databuffersize = msg.datasize;
+    }
+    if (msg.databuffer==0)
+    {
+        if (sock!=DLT_DAEMON_STORE_TO_BUFFER)
+        {
+            dlt_daemon_control_service_response(sock, daemon, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR,  verbose);
+        }
+        return -1;
+    }
+
+    resp = (DltServiceTimezone*) msg.databuffer;
+    resp->service_id = DLT_SERVICE_ID_TIMEZONE;
+    resp->status = DLT_SERVICE_RESPONSE_OK;
+    resp->timezone = timezone;
+    resp->isdst = isdst;
+
+    /* send message */
+    if(dlt_daemon_control_send_control_message(sock,daemon,&msg,"","",  verbose))
+    {
+        dlt_message_free(&msg,0);
+       return -1;
+    }
+
+    /* free message */
+    dlt_message_free(&msg,0);
+
+    return 0;
+}
index 46b59dd..f0a6be4 100644 (file)
@@ -477,6 +477,14 @@ int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, c
  * @param verbose if set to true verbose information is printed out.\r
  */\r
 int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, uint8_t state, char* comid, int verbose);\r
+/**\r
+ * Send control message connection info (add on to AUTOSAR standard)\r
+ * @param sock connection handle used for sending response\r
+ * @param daemon pointer to dlt daemon structure\r
+ * @param timezone timezone on target\r
+ * @param verbose if set to true verbose information is printed out.\r
+ */\r
+int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, int32_t timezone, uint8_t isdst, int verbose);\r
 \r
 #ifdef __cplusplus\r
 }\r