summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Huerner <ingo.huerner@xse.de>2013-02-15 10:42:03 +0100
committerIngo Huerner <ingo.huerner@xse.de>2013-02-15 10:42:03 +0100
commit446589274e982a3d8da3d878743de83311ccb843 (patch)
treefefe3d16a077d75b6a80ae4bad85613c9d9f6afc
parent441e7ddbfb4cf6c31513905db1904ff4883d5b2e (diff)
downloadpersistence-client-library-446589274e982a3d8da3d878743de83311ccb843.tar.gz
Updated dbus message parameters; replaced pipe to dbus mainloop by eventfd
-rw-r--r--README6
-rw-r--r--include_protected/persistence_client_library_data_organization.h27
-rw-r--r--src/persistence_client_library_dbus_service.c23
-rw-r--r--src/persistence_client_library_dbus_service.h3
-rw-r--r--src/persistence_client_library_lc_interface.c13
-rw-r--r--src/persistence_client_library_lc_interface.h2
-rw-r--r--src/persistence_client_library_pas_interface.c24
-rw-r--r--src/persistence_client_library_pas_interface.h2
-rw-r--r--test/Makefile.am10
-rw-r--r--test/customLibConfigFile.cfg7
-rw-r--r--test/persistence_client_library_dbus_test.c9
11 files changed, 64 insertions, 62 deletions
diff --git a/README b/README
index 19a4b0d..e0bfa5d 100644
--- a/README
+++ b/README
@@ -8,6 +8,12 @@ Required packages
* autotools: install via Synaptic Package Manger or use apt-get
* GNU c compiler: install via Synaptic Package Manger or use apt-get
+Known issues:
+* Patch Itzam/C configure.ac file:
+ - replace in the Itzam/C configure.ac GENERIC_LIBRARY_NAME=libitzam with GENERIC_LIBRARY_NAME=itzam
+* copy itzam package confiuration file to /usr/local/lib/pkgconfig
+
+
How to compile
For the Persistence Client Library autotools will be used to generate makefiles.
To build the client library perform the following steps:
diff --git a/include_protected/persistence_client_library_data_organization.h b/include_protected/persistence_client_library_data_organization.h
index abd08e1..87680d3 100644
--- a/include_protected/persistence_client_library_data_organization.h
+++ b/include_protected/persistence_client_library_data_organization.h
@@ -42,24 +42,25 @@ enum _PersistenceConstantDef
FileClosed = 0,
FileOpen = 1,
- NsmShutdownNormal = 1, /// lifecycle shutdown normal
+ NsmShutdownNormal = 1, /// lifecycle shutdown normal
NsmErrorStatus_OK = 1,
NsmErrorStatus_Fail = -1,
- PrctKeySize = 64, /// persistence resource config table max key size
- PrctValueSize = 256, /// persistence resource config table max value size
- PrctDbTableSize = 1024, /// number of persistence resource config tables to store
+ PrctKeySize = 64, /// persistence resource config table max key size
+ PrctValueSize = 256, /// persistence resource config table max value size
+ PrctDbTableSize = 1024, /// number of persistence resource config tables to store
- DbKeySize = 64, /// database max key size
- DbValueSize = 16384, /// database max value size
- DbTableSize = 1024, /// database table size
+ DbKeySize = 64, /// database max key size
+ DbValueSize = 16384, /// database max value size
+ DbTableSize = 1024, /// database table size
- PasMsg_Block = 1, /// persistence administration service block access
- PasMsg_WriteBack = 2, /// persistence administration service write_back
- PasMsg_Unblock = 4, /// persistence administration service unblock access
- PasErrorStatus_RespPend = 50, /// persistence administration service msg return status
- PasErrorStatus_OK = 100, /// persistence administration service msg return status
- PasErrorStatus_FAIL = -1, /// persistence administration service msg return status
+ PasMsg_Block = 0x0001, /// persistence administration service block access
+ PasMsg_Unblock = 0x0002, /// persistence administration service unblock access
+ PasMsg_WriteBack = 0x0010, /// persistence administration service write_back
+
+ PasErrorStatus_RespPend = 0x0001, /// persistence administration service msg return status
+ PasErrorStatus_OK = 0x0002, /// persistence administration service msg return status
+ PasErrorStatus_FAIL = 0x8000, /// persistence administration service msg return status
CustLibMaxLen = 128, /// max length of the custom library name and path
DbKeyMaxLen = 128, /// max database key length
diff --git a/src/persistence_client_library_dbus_service.c b/src/persistence_client_library_dbus_service.c
index eec0412..dcf77eb 100644
--- a/src/persistence_client_library_dbus_service.c
+++ b/src/persistence_client_library_dbus_service.c
@@ -314,9 +314,9 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
{
dbus_connection_set_exit_on_disconnect (conn, FALSE);
printf("connected as '%s'\n", dbus_bus_get_unique_name(conn));
- if (0!=pipe(gPipefds))
+ if (-1 == (gEfds = eventfd(0, 0)))
{
- printf("pipe() failed w/ errno %d\n", errno);
+ printf("eventfd() failed w/ errno %d\n", errno);
}
else
{
@@ -325,7 +325,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
memset(&gPollInfo, 0 , sizeof(gPollInfo));
gPollInfo.nfds = 1;
- gPollInfo.fds[0].fd = gPipefds[0];
+ gPollInfo.fds[0].fd = gEfds;
gPollInfo.fds[0].events = POLLIN;
dbus_bus_add_match(conn, "type='signal',interface='org.genivi.persistence.admin',member='PersistenceModeChanged',path='/org/genivi/persistence/admin'", &err);
@@ -341,7 +341,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
}
else
{
- char buf[64];
+ uint16_t buf[64];
pthread_cond_signal(&gDbusInitializedCond);
pthread_mutex_unlock(&gDbusInitializedMtx);
@@ -366,7 +366,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
{
if (0!=gPollInfo.fds[i].revents)
{
- if (gPollInfo.fds[i].fd==gPipefds[0])
+ if (gPollInfo.fds[i].fd==gEfds)
{
if (0!=(gPollInfo.fds[i].revents & POLLIN))
{
@@ -374,17 +374,17 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
while ((-1==(ret=read(gPollInfo.fds[i].fd, buf, 64)))&&(EINTR==errno));
if (0>ret)
{
- printf("read() failed w/ errno %d\n", errno);
+ printf("read() failed w/ errno %d | %s\n", errno, strerror(errno));
}
- else if (sizeof(int)==ret)
+ else if (ret != -1)
{
switch (buf[0])
{
case CMD_PAS_BLOCK_AND_WRITE_BACK:
- process_block_and_write_data_back(buf[1]);
+ process_block_and_write_data_back((buf[2]), buf[1]);
break;
case CMD_LC_PREPARE_SHUTDOWN:
- process_prepare_shutdown(buf[1]);
+ process_prepare_shutdown((buf[2]), buf[1]);
break;
case CMD_QUIT:
bContinue = FALSE;
@@ -396,7 +396,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
}
else
{
- printf("read() returned %d (%s)\n", ret, buf);
+ printf("read() returned %d \n", ret);
}
}
}
@@ -434,8 +434,7 @@ int mainLoop(DBusObjectPathVTable vtable, DBusObjectPathVTable vtable2,
dbus_connection_unregister_object_path(conn, "/com/contiautomotive/NodeStateManager/LifecycleConsumer");
dbus_connection_unregister_object_path(conn, "/");
}
- close(gPipefds[1]);
- close(gPipefds[0]);
+ close(gEfds);
}
dbus_connection_unref(conn);
dbus_shutdown();
diff --git a/src/persistence_client_library_dbus_service.h b/src/persistence_client_library_dbus_service.h
index fa93622..328b25f 100644
--- a/src/persistence_client_library_dbus_service.h
+++ b/src/persistence_client_library_dbus_service.h
@@ -22,6 +22,7 @@
#include <dbus/dbus.h>
#include <poll.h>
#include <pthread.h>
+#include <sys/eventfd.h>
/// mutex to make sure main loop is running
extern pthread_mutex_t gDbusInitializedMtx;
@@ -39,7 +40,7 @@ typedef enum ECmd
/// pipe file descriptors
-int gPipefds[2];
+int gEfds;
/// returns the dbus connection
diff --git a/src/persistence_client_library_lc_interface.c b/src/persistence_client_library_lc_interface.c
index ae4c734..149b6e4 100644
--- a/src/persistence_client_library_lc_interface.c
+++ b/src/persistence_client_library_lc_interface.c
@@ -45,10 +45,11 @@ int check_lc_request(int request, int requestID)
{
case NsmShutdownNormal:
{
+ uint64_t cmd;
// add command and data to queue
- unsigned long cmd = ( (requestID << 8) | CMD_LC_PREPARE_SHUTDOWN);
+ cmd = ( ((uint64_t)requestID << 32) | ((uint64_t)request << 16) | CMD_LC_PREPARE_SHUTDOWN);
- if(sizeof(int)!=write(gPipefds[1], &cmd, sizeof(unsigned long)))
+ if(-1 == write(gEfds, &cmd, (sizeof(uint64_t))))
{
printf("write failed w/ errno %d\n", errno);
rval = NsmErrorStatus_Fail;
@@ -264,17 +265,15 @@ int unregister_lifecycle()
}
-int send_prepare_shutdown_complete(int requestId)
+int send_prepare_shutdown_complete(int requestId, int status)
{
- int status = 1; // TODO send correct status
-
return send_lifecycle_request("LifecycleRequestComplete", requestId, status);
}
-void process_prepare_shutdown(unsigned char requestId)
+void process_prepare_shutdown(unsigned char requestId, unsigned int status)
{
int i = 0;
//GvdbTable* resourceTable = NULL;
@@ -324,6 +323,6 @@ void process_prepare_shutdown(unsigned char requestId)
}
// notify lifecycle shutdown OK
- send_prepare_shutdown_complete((int)requestId);
+ send_prepare_shutdown_complete((int)requestId, (int)status);
}
diff --git a/src/persistence_client_library_lc_interface.h b/src/persistence_client_library_lc_interface.h
index bd612d1..64332f4 100644
--- a/src/persistence_client_library_lc_interface.h
+++ b/src/persistence_client_library_lc_interface.h
@@ -55,7 +55,7 @@ int unregister_lifecycle();
*
* @param requestId the requestID
*/
-void process_prepare_shutdown(unsigned char requestId);
+void process_prepare_shutdown(unsigned char requestId, unsigned int status);
diff --git a/src/persistence_client_library_pas_interface.c b/src/persistence_client_library_pas_interface.c
index 36f0dcc..89dab9a 100644
--- a/src/persistence_client_library_pas_interface.c
+++ b/src/persistence_client_library_pas_interface.c
@@ -56,23 +56,24 @@ int isAccessLocked(void)
int check_pas_request(unsigned int request, unsigned int requestID)
{
int rval = 0;
-
switch(request)
{
case (PasMsg_Block|PasMsg_WriteBack):
{
+ uint64_t cmd;
// add command and data to queue
- unsigned long cmd = ( (requestID << 8) | CMD_PAS_BLOCK_AND_WRITE_BACK);
+ cmd = ( ((uint64_t)requestID << 32) | ((uint64_t)request << 16) | CMD_PAS_BLOCK_AND_WRITE_BACK);
- if(sizeof(int)!=write(gPipefds[1], &cmd, sizeof(unsigned long)))
+ if(-1 == write(gEfds, &cmd, (sizeof(uint64_t))))
{
- printf("write failed w/ errno %d\n", errno);
+ printf("write failed w/ errno %d | %s\n", errno, strerror(errno));
rval = PasErrorStatus_FAIL;
}
else
{
rval = PasErrorStatus_RespPend;
}
+ printf("======> check_pas_request(requestID: %u | status: %u ) \n", (unsigned int)(cmd>>32&0xFF), (unsigned int)(cmd>>16&0xFF));
break;
}
case PasMsg_Unblock:
@@ -128,6 +129,7 @@ DBusHandlerResult msg_persAdminRequest(DBusConnection *connection, DBusMessage *
}
errorReturn = check_pas_request(request, requestID);
+
reply = dbus_message_new_method_return(message);
if (reply == 0)
@@ -321,7 +323,7 @@ int send_pas_register(const char* method, int notificationFlag)
int send_pas_request(const char* method, unsigned int requestID, int status)
{
- int rval = 0, errorCode = 0;
+ int rval = 0;
DBusError error;
dbus_error_init (&error);
@@ -332,11 +334,13 @@ int send_pas_request(const char* method, unsigned int requestID, int status)
"/org/genivi/persistence/admin", // path
"org.genivi.persistence.admin", // interface
method); // method
+
+ printf(" =======****> send_pas_request: requestID: %u | status: %u \n", requestID, status);
+
if(message != NULL)
{
dbus_message_append_args(message, DBUS_TYPE_UINT32, &requestID,
DBUS_TYPE_INT32, &status,
- DBUS_TYPE_INT32, &errorCode,
DBUS_TYPE_INVALID);
if(conn != NULL)
@@ -391,21 +395,21 @@ int unregister_pers_admin_service(void)
-int pers_admin_service_data_sync_complete(unsigned int requestID)
+int pers_admin_service_data_sync_complete(unsigned int requestID, unsigned int status)
{
- return send_pas_request("PersistenceAdminRequestCompleted", requestID, 1);
+ return send_pas_request("PersistenceAdminRequestCompleted", requestID, status);
}
-void process_block_and_write_data_back(unsigned int requestID)
+void process_block_and_write_data_back(unsigned int requestID, unsigned int status)
{
// lock persistence data access
pers_lock_access();
// sync data back to memory device
pers_data_sync();
// send complete notification
- pers_admin_service_data_sync_complete(requestID);
+ pers_admin_service_data_sync_complete(requestID, status);
}
diff --git a/src/persistence_client_library_pas_interface.h b/src/persistence_client_library_pas_interface.h
index e93c06e..5ee2ed9 100644
--- a/src/persistence_client_library_pas_interface.h
+++ b/src/persistence_client_library_pas_interface.h
@@ -60,7 +60,7 @@ int isAccessLocked(void);
/// block persistence access and write data back to device
-void process_block_and_write_data_back(unsigned int requestID);
+void process_block_and_write_data_back(unsigned int requestID, unsigned int status);
/**
diff --git a/test/Makefile.am b/test/Makefile.am
index 6d12435..8977079 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,12 +10,12 @@ endif
noinst_PROGRAMS = persistence_client_library_test persistence_client_library_dbus_test
-persistence_client_library_test_SOURCES = persistence_client_library_test.c
-persistence_client_library_test_LDADD = $(DEPS_LIBS) $(CHECK_LIBS) \
- $(top_srcdir)/src/libpersistence_client_library.la
-
persistence_client_library_dbus_test_SOURCES = persistence_client_library_dbus_test.c
persistence_client_library_dbus_test_LDADD = $(DEPS_LIBS) $(top_srcdir)/src/libpersistence_client_library.la
-
+
+persistence_client_library_test_SOURCES = persistence_client_library_test.c
+persistence_client_library_test_LDADD = $(DEPS_LIBS) $(CHECK_LIBS) \
+ $(top_srcdir)/src/libpersistence_client_library.la
+
TESTS=persistence_client_library_test
diff --git a/test/customLibConfigFile.cfg b/test/customLibConfigFile.cfg
index fffd4ee..e69de29 100644
--- a/test/customLibConfigFile.cfg
+++ b/test/customLibConfigFile.cfg
@@ -1,7 +0,0 @@
-secure /usr/local/lib/libsecureperscustom.so
-early /usr/local/lib/libearlyperscustom.so
-custom2 /usr/local/lib/libcustom2perscustom.so
-hwinfo /usr/local/lib/libhwinfoperscustom.so
-custom1 /usr/local/lib/libcustom1perscustom.so
-emergency /usr/local/lib/libemergencyperscustom.so
-custom3 /usr/local/lib/libcustom3perscustom.so \ No newline at end of file
diff --git a/test/persistence_client_library_dbus_test.c b/test/persistence_client_library_dbus_test.c
index caebd3e..fdad403 100644
--- a/test/persistence_client_library_dbus_test.c
+++ b/test/persistence_client_library_dbus_test.c
@@ -18,7 +18,7 @@
#include "../include/persistence_client_library_key.h"
#include "../include/persistence_client_library_file.h"
-
+#include "../include/persistence_client_library_error_def.h"
#include <stdio.h>
@@ -26,12 +26,11 @@
int main(int argc, char *argv[])
{
int ret = 0;
- char buffer[128];
-
+ unsigned char buffer[1024];
printf("Dbus interface test application\n");
- ret = pclKeyReadData(0, "/language/current_language", 3, 0, (unsigned char*)buffer, 128);
-
+ getchar();
+ ret = pclKeyReadData(0xFF, "pos/last_position", 0, 0, buffer, 1024);
getchar();