[Jderobot-admin] jderobot-r1117 - in trunk/src/stable/components/openniServer: . sv

rocapal en jderobot.org rocapal en jderobot.org
Jue Nov 28 17:25:42 CET 2013


Author: rocapal
Date: 2013-11-28 17:25:41 +0100 (Thu, 28 Nov 2013)
New Revision: 1117

Added:
   trunk/src/stable/components/openniServer/sv/
   trunk/src/stable/components/openniServer/sv/run
   trunk/src/stable/components/openniServer/sv/xtionUsbReset.sh
Modified:
   trunk/src/stable/components/openniServer/openniServer.cpp
Log:
#132 added usb reset of xtion, and supervise


Modified: trunk/src/stable/components/openniServer/openniServer.cpp
===================================================================
--- trunk/src/stable/components/openniServer/openniServer.cpp	2013-11-27 15:28:28 UTC (rev 1116)
+++ trunk/src/stable/components/openniServer/openniServer.cpp	2013-11-28 16:25:41 UTC (rev 1117)
@@ -55,6 +55,7 @@
 #define NUM_THREADS 5
 #define MAX_LENGHT 10000
 #define SAMPLE_READ_WAIT_TIMEOUT 2000
+#define RETRY_MAX_TIMES 10
 
 #define CHECK_RC(rc, what)                                      \
 if (rc != openni::STATUS_OK)                                         \
@@ -86,6 +87,7 @@
 pthread_t updateThread;
 int deviceMode; //videmode for device streamings
 
+int retry_times = 0;
 
 //block to wait the device initialization
 IceUtil::Mutex controlMutex;
@@ -118,6 +120,7 @@
 {
 
 	openni::Status rc = openni::STATUS_OK;
+
 	rc = openni::OpenNI::initialize();
 	if (rc != openni::STATUS_OK)
 	{
@@ -352,6 +355,12 @@
 			if (rc != openni::STATUS_OK)
 			{
 				std::cout<< "Wait failed! (timeout is " << SAMPLE_READ_WAIT_TIMEOUT <<  "ms) " << openni::OpenNI::getExtendedError() << std::endl;
+				retry_times++;
+				if (retry_times > RETRY_MAX_TIMES)
+				{
+					std::cout << "Retry Max Times exceeded!. Force Exit!!" << std::endl;
+					exit(-1);
+				}
 				continue;
 			}
 		}

Added: trunk/src/stable/components/openniServer/sv/run
===================================================================
--- trunk/src/stable/components/openniServer/sv/run	                        (rev 0)
+++ trunk/src/stable/components/openniServer/sv/run	2013-11-28 16:25:41 UTC (rev 1117)
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Enter your sudo pass for reset usb device automatically
+PASS_SUDO=
+
+mkdir -p ../log/
+echo "Restarting openniServer ... " `date` >> ../log/system.log
+
+killall -9 openniServer &> /dev/null
+cd ..
+./openniServer --Ice.Config=openniServer.cfg
+
+cd sv/
+echo ${PASS_SUDO} | sudo -S ./xtionUsbReset.sh
+
+sleep 5


Property changes on: trunk/src/stable/components/openniServer/sv/run
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/src/stable/components/openniServer/sv/xtionUsbReset.sh
===================================================================
--- trunk/src/stable/components/openniServer/sv/xtionUsbReset.sh	                        (rev 0)
+++ trunk/src/stable/components/openniServer/sv/xtionUsbReset.sh	2013-11-28 16:25:41 UTC (rev 1117)
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+#  Copyright (C) JDE DEVELOPERS
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see http://www.gnu.org/licenses/.
+#
+#  Authors : Roberto Calvo <rocapal at gmail dot com>
+
+idVendor="1d27"
+idProduct="0601"
+
+XTION_USB_DEVICE=""
+XTION_BUS=""
+
+function check_result {
+
+	if [ "$?" != "0" ]; then
+		echo "Error"
+		exit
+	else
+		echo "OK"
+	fi
+}
+
+
+IFS=$(echo -en "\n\b")
+for X in /sys/bus/usb/devices/*; do      
+
+	vendor=`cat "$X/idVendor" 2>/dev/null`
+	product=`cat "$X/idProduct" 2>/dev/null`
+
+	if [ "${vendor}" = "${idVendor}" ] && [ "${product}" = "${idProduct}" ]; then
+		XTION_USB_DEVICE=$X
+		break
+	fi
+done
+
+echo "Found Xtion in $XTION_USB_DEVICE"
+
+XTION_BUS=$(basename `echo $XTION_USB_DEVICE | cut -d"." -f-2`)
+echo "Found Xtion Bus in $XTION_BUS"
+
+echo -n "Unbind Xtion ... "
+echo $XTION_BUS | sudo tee /sys/bus/usb/drivers/usb/unbind &>/dev/null
+check_result
+
+sleep 1
+echo -n "Bind Xtion ... "
+echo $XTION_BUS | sudo tee /sys/bus/usb/drivers/usb/bind &>/dev/null
+check_result


Property changes on: trunk/src/stable/components/openniServer/sv/xtionUsbReset.sh
___________________________________________________________________
Added: svn:executable
   + *



More information about the Jderobot-admin mailing list