diff --git a/appA15HeartBeatHost.c b/appA15HeartBeatHost.c
index f2e65094215ab909e539789a75f2c091506e5e0e..e0d898548fa313b70d45644c939d20aaa741ebcf 100644 (file)
--- a/appA15HeartBeatHost.c
+++ b/appA15HeartBeatHost.c
/* open the remote message queue */
sprintf(msgqName, App_SlaveMsgQueName, MultiProc_getName(remoteProcId));
-
+ ALOGE("App_create: msgqName %s", msgqName);
do {
status = MessageQ_open(msgqName, &Module.slaveQue);
sleep(1);
MessageCount++;
// Get current time of day
gettimeofday(&tv, NULL);
- ALOGE("%ld us: App_exec: sending #%d message %d \n", (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount, msg->cmd);
+ ALOGE("%ld us: App_exec: sending #%d message %d \n",
+ (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount, msg->cmd);
#endif
while (running) {
/* send START 1st message */
MessageQ_put(Module.slaveQue, (MessageQ_Msg)msg);
- // Sleep for Microseconds - 500ms
- usleep(Microseconds);
+ /* Wait for server message within 500ms */
+ status = MessageQ_get(Module.hostQue, (MessageQ_Msg *)&msg,
+ Microseconds);
+ /* Check the message from server that indicates GPIO reverse gear
+ * detected or non-reverse gear detected.
+ * If timeout, then reset the 500ms sleep and resend the A15 heartbeat
+ * to server.
+ * If reverse gear is detected, then set the A15 watchdog/panic
+ * timeout to 0 sec (no recovery/reboot should take place).
+ * If non-reverse is detected, then set the A15 watchdog/panic
+ * timout to 5 sec.
+ */
+ if ((status < 0) && (status != MessageQ_E_TIMEOUT)) {
+ ALOGE("--> App_exec: MessageQ_get FAILED");
+ status = -1;
+ goto leave;
+ }
+
+ if (status == MessageQ_S_SUCCESS) {
+ /* Received a message from server
+ * Extract message payload: check reverse or non-reverse indication
+ */
+ if (msg->cmd == App_CMD_RVC_UP) {
+ ALOGE("--> App_exec: Message received App_CMD_RVC_UP");
+ system("echo 0 > /proc/sys/kernel/panic");
+ }
+ else if (msg->cmd == App_CMD_RVC_DOWN) {
+ ALOGE("--> App_exec: Message received App_CMD_RVC_DOWN");
+ system("echo 5 > /proc/sys/kernel/panic");
+ }
+
+ /* Free the message from M4 -
+ * msg to indicate rvc reverse gear detected or not
+ */
+ MessageQ_free((MessageQ_Msg)msg);
+ }
+
+ if (status == MessageQ_E_TIMEOUT) {
+ /* Receive a TIMEOUT. No message from M4, continue heartbeat
+ */
+ //ALOGE("App_exec: message TIMEOUT, continue heartbeat \n");
+ }
- /* allocate message */
+ /* Allocate message
+ */
msg = (App_Msg *)MessageQ_alloc(Module.heapId, Module.msgSize);
if (msg == NULL) {
goto leave;
}
- /* fill in message payload */
+ /* Fill in message payload */
msg->cmd = App_CMD_ALIVE;
#ifdef DEBUG
MessageCount++;
gettimeofday(&tv, NULL);
- ALOGE("%ld us: App_exec: sending #%d App_CMD_ALIVE \n", (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount);
+ ALOGE("%ld us: App_exec: sending #%d App_CMD_ALIVE \n",
+ (tv.tv_sec * 1000000) + tv.tv_usec, MessageCount);
#endif
}
ALOGE("--> main:");
- /* configure the transport factory */
+ /* Configure the transport factory */
Ipc_transportConfig(&TransportRpmsg_Factory);
- /* parse command line */
+ /* Parse command line */
status = Main_parseArgs(argc, argv);
if (status < 0) {
status = Ipc_start();
if (status >= 0) {
- /* application create, exec, delete */
+ /* Application create, exec, delete */
status = Main_main();
/* Ipc finalization */