Created
December 18, 2016 23:32
-
-
Save ErlendEllingsen/e1c0c1030c655390d2f6ae80078c8a2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require('exec'); | |
var colors = require('colors'); | |
function fixDevice() { | |
console.log(colors.red('Usb device error... Resetting...')); | |
exec('sudo /home/pi/work/usbreset /dev/bus/usb/001/005', function(err, out, code) { | |
console.log(colors.blue('Usb device error... Resetting...')); | |
setTimeout(updatepic, 3000); | |
}); | |
} | |
function updatepic() { | |
exec('fswebcam -D 1 --no-banner -r 640x480 /var/www/html/image.jpg', function(err, out, code) { | |
if (err != '') { | |
fixDevice(); | |
return; | |
} | |
//console.log('hi! ' + out.toString()); | |
console.log(colors.white('Pic -- OK')); | |
setTimeout(updatepic, 500); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment