summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2013-12-09 13:52:31 +0100
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2014-01-10 07:16:04 +0100
commitbff03e36c4ef0fe7f49403bbbcb49d48493293b7 (patch)
tree33685b60ed90d0830b9708af97394e2ecb0e3686
parent302499439d5cdfab0ed7a2bf850e644eb98874df (diff)
downloadDLT-daemon-bff03e36c4ef0fe7f49403bbbcb49d48493293b7.tar.gz
Added new control message timezone.
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
-rwxr-xr-xinclude/dlt/dlt_common.h11
-rwxr-xr-xinclude/dlt/dlt_protocol.h1
-rw-r--r--src/daemon/dlt-daemon.c23
-rwxr-xr-xsrc/daemon/dlt-daemon.h1
-rw-r--r--src/daemon/dlt.conf7
-rw-r--r--src/daemon/dlt_daemon_common.c60
-rw-r--r--src/daemon/dlt_daemon_common.h8
7 files changed, 107 insertions, 4 deletions
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index 0740c9e..22710c7 100755
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -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.
diff --git a/include/dlt/dlt_protocol.h b/include/dlt/dlt_protocol.h
index 7e941fe..09e4adc 100755
--- a/include/dlt/dlt_protocol.h
+++ b/include/dlt/dlt_protocol.h
@@ -189,6 +189,7 @@
#define DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW 0x14 /**< Service ID: Message buffer overflow */
#define DLT_SERVICE_ID_UNREGISTER_CONTEXT 0xf01 /**< Service ID: Message unregister context */
#define DLT_SERVICE_ID_CONNECTION_INFO 0xf02 /**< Service ID: Message connection info */
+#define DLT_SERVICE_ID_TIMEZONE 0xf03 /**< Service ID: Timezone */
#define DLT_SERVICE_ID_CALLSW_CINJECTION 0xFFF /**< Service ID: Message Injection (minimal ID) */
/*
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 00ac525..78d232f 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -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);
}
+
/**
\}
*/
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 46321a7..b7ffb55 100755
--- a/src/daemon/dlt-daemon.h
+++ b/src/daemon/dlt-daemon.h
@@ -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) */
int sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */
char pathToECUSoftwareVersion[256]; /**< (String: Filename) The file from which to read the ECU version from. */
+ int sendTimezone; /**< (Boolean) Send Timezone perdiodically */
} DltDaemonFlags;
/**
diff --git a/src/daemon/dlt.conf b/src/daemon/dlt.conf
index e09129a..a079d3e 100644
--- a/src/daemon/dlt.conf
+++ b/src/daemon/dlt.conf
@@ -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
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index bbd058d..df9ccbe 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -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;
+}
diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h
index 46b59dd..f0a6be4 100644
--- a/src/daemon/dlt_daemon_common.h
+++ b/src/daemon/dlt_daemon_common.h
@@ -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.
*/
int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, uint8_t state, char* comid, int verbose);
+/**
+ * Send control message connection info (add on to AUTOSAR standard)
+ * @param sock connection handle used for sending response
+ * @param daemon pointer to dlt daemon structure
+ * @param timezone timezone on target
+ * @param verbose if set to true verbose information is printed out.
+ */
+int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, int32_t timezone, uint8_t isdst, int verbose);
#ifdef __cplusplus
}