Skip to content

Instantly share code, notes, and snippets.

@ErlendEllingsen
Created December 18, 2016 23:32
Show Gist options
  • Save ErlendEllingsen/e1c0c1030c655390d2f6ae80078c8a2c to your computer and use it in GitHub Desktop.
Save ErlendEllingsen/e1c0c1030c655390d2f6ae80078c8a2c to your computer and use it in GitHub Desktop.
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