Author: vferey
Date: Thu Aug 5 16:09:00 2010
New Revision: 9027
URL: http://svn.slimdevices.com/jive?rev=9027&view=rev
Log:
Added a new package to mointor the hardware components at run time.
The current version only monitors the MSP430 on baby.
Added:
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/Makefile
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.c
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.sh
(with props)
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/monitor-hardware_1.0.bb
Added:
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/Makefile
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/Makefile?rev=9027&view=auto
==============================================================================
---
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/Makefile
(added)
+++
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/Makefile
Thu Aug 5 16:09:00 2010
@@ -1,0 +1,9 @@
+SOURCES := monitor_msp430.c
+
+all: monitor_msp430
+
+monitor_msp430: $(SOURCES)
+ $(CC) -Wall $(CFLAGS) -DUSE_HOSTCC $(SOURCES) -o monitor_msp430
+
+clean:
+ rm -f *.o monitor_msp430
Added:
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.c
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.c?rev=9027&view=auto
==============================================================================
---
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.c
(added)
+++
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.c
Thu Aug 5 16:09:00 2010
@@ -1,0 +1,107 @@
+/*
+ The purpose of this file is to monitor the MSP430 and to make sure
that the communication between iMX25 and the MSP430 is fine.
+ If the communication is not functional for a period of time then the
MSP430 is marked as failure and this process exits.
+ It is the responsibility of the watchdog to monitor this process to
make sure that it is running.
+ As soon as this process exits the watchdog knows that this process is
not running anymore and would make proper decision
+ ( which could be to reset the system ).
+*/
+
+
+/*
+ Include files.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+
+/*
+ Macros
+*/
+
+
+#define MSP430_FW_I2C_DEV "/sys/bus/i2c/drivers/msp430/1-0010/fw"
+#define MAX_CONSECUTIVE_FAIL_COUNT 30
+
+/*!
+ Monitors the MSP430 by reading its firmware revision. This causes i2c
issues to the MSP430 to read the information.
+ If the request fails for a specified number of times consecutively
then the MSP430 is considered failed.
+ This function returns only if it declraes the MSP430 as failed.
+*/
+
+void monitor_msp430 ( void )
+{
+ int fd;
+ char buf[10];
+ int ret;
+ int consecutive_fail_count;
+
+
+ consecutive_fail_count = 0;
+
+ while ( 1 )
+ {
+ sleep ( 1 );
+ fd = open ( MSP430_FW_I2C_DEV, O_RDONLY );
+ if ( fd < 0 )
+ {
+ fprintf ( stderr, "Failed to open the device %s, error
( %s )\n", MSP430_FW_I2C_DEV, strerror ( errno ));
+ ret = -1;
+ }
+ else
+ {
+ ret = read ( fd, buf, sizeof ( buf ));
+ if ( ret > 0 )
+ fprintf ( stdout, "The data read from the fw
is %d%d\n", buf[0], buf[1] );
+ else
+ fprintf ( stderr, "Failed to read from the
device %s, error ( %s )\n", MSP430_FW_I2C_DEV, strerror ( errno ));
+ close ( fd );
+ }
+
+ /*
+ Check if the request to communicate to MSP430 is
failed for any reason.
+ */
+
+ if ( ret < 0 )
+ {
+ /*
+ The communication to MSP430 is failed.
+ Increase the failed count and check if we
passed the threshold.
+ */
+
+ consecutive_fail_count++;
+
+ if ( consecutive_fail_count >
MAX_CONSECUTIVE_FAIL_COUNT )
+ {
+ fprintf ( stdout, "Too many consecutive
communication failure to MSP430. Consider it failed\n" );
+ break;
+ }
+ }
+ else
+ {
+ /*
+ The communication to MSP430 is working fine.
Clear out any history of failed communication counts.
+ */
+
+ consecutive_fail_count = 0;
+ }
+ }
+ return;
+}
+
+
+int main (int argc, char **argv)
+{
+ /*
+ Monitor the MSP430.
+ */
+
+ monitor_msp430 ();
+
+ return 0;
+}
Added:
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.sh
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.sh?rev=9027&view=auto
==============================================================================
---
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.sh
(added)
+++
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.sh
Thu Aug 5 16:09:00 2010
@@ -1,0 +1,37 @@
+#!/bin/sh
+
+case "$1" in
+ start)
+ if [ -s /var/run/monitor_msp430.pid ] && kill -0 $(cat
/var/run/monitor_msp430.pid)
+ then
+ echo "Monitor is already running"
+ exit 1
+ fi
+
+ echo "Monitoring MSP430"
+
+ (cd /usr/bin; /usr/bin/monitor_msp430) &
+ echo $! > /var/run/monitor_msp430.pid
+ ;;
+
+ stop)
+ echo "Stop monitoring the MSP430"
+
+ if [ -s /var/run/monitor_msp430.pid ]; then
+ /bin/kill $(cat /var/run/monitor_msp430.pid)
+
+ /bin/rm /var/run/monitor_msp430.pid
+ /bin/rm /var/run/monitor_msp430.wdog
+ fi
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit 0
Propchange:
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/files/monitor_msp430.sh
------------------------------------------------------------------------------
svn:executable = *
Added:
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/monitor-hardware_1.0.bb
URL:
http://svn.slimdevices.com/jive/7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/monitor-hardware_1.0.bb?rev=9027&view=auto
==============================================================================
---
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/monitor-hardware_1.0.bb
(added)
+++
7.6/trunk/squeezeos/poky/meta-squeezeos/packages/monitor-hardware/monitor-hardware_1.0.bb
Thu Aug 5 16:09:00 2010
@@ -1,0 +1,19 @@
+DESCRIPTION = "monitor hardware"
+SECTION = "base"
+LICENSE = "GPL"
+
+PR = "r1"
+
+SRC_URI=" \
+ file://Makefile \
+ file://monitor_msp430.c \
+ file://monitor_msp430.sh \
+ "
+
+S = ${WORKDIR}
+
+do_install() {
+ install -m 0755 -d ${D}${sbindir}
+ install -m 0755 ${WORKDIR}/monitor_msp430 ${D}${sbindir}/monitor_msp430
+ install -m 0755 ${WORKDIR}/monitor_msp430.sh
${D}${etcdir}/monitor_msp430.sh
+}
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins