Skip to content

Commit

Permalink
auto restart after camera disconnect with new driver
Browse files Browse the repository at this point in the history
  • Loading branch information
elijahparker committed Jul 7, 2021
1 parent 3e74551 commit 795db9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions intervalometer/intervalometer-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ function parseData(data, client) {

function runCommand(type, args, callback, client) {
var cameraCallback = function(err, res) {
if(!intervalometer.status.running && !camera.ptp.lvOn && camera.ptp.model && camera.ptp.model.match(/nikon/i)) {
if(intervalometerStatus && !intervalometerStatus.running && !camera.ptp.lvOn && camera.ptp.model && camera.ptp.model.match(/nikon/i)) {
console.log("exiting pc mode...");
camera.ptp.set("controlmode", 0, function(){
callback && callback(err, res);
Expand Down Expand Up @@ -639,7 +639,7 @@ function runCommand(type, args, callback, client) {
motion.setPosition(args.driver, args.motor, args.position, callback);
break;
case 'motion.status':
if(intervalometer.status.running) {
if(intervalometerStatus && intervalometerStatus.running) {
sendEvent('motion.status', motion.status);
} else {
motion.refresh(callback);
Expand Down Expand Up @@ -823,24 +823,24 @@ camera.ptp.on('settings', function(data) {
sendEvent('camera.settings', camera.ptp.settings);
});
camera.ptp.on('connected', function(model) {
console.log("CORE: camera connected", model);
console.log("CORE: camera connected", model, "count", camera.ptp.count);
sendCameraUpdate();
if(camera.ptp.count == 1) intervalometer.resume();
if(camera.ptp.count == 1 && intervalometerStatus && intervalometerStatus.running) intervalometer.resume();
});
camera.ptp.new.on('connected', function(model) {
console.log("CORE: camera connected", model);
console.log("CORE: camera connected", model, "count", camera.ptp.new.cameras.length);
sendCameraUpdate();
if(camera.ptp.count > 0 && intervalometer.status && intervalometer.status.running) intervalometer.resume();
if(camera.ptp.new.cameras.length == 1 && intervalometerStatus && intervalometerStatus.running) intervalometer.resume();
});
camera.ptp.new.on('settings', function(settings) {
sendEvent('camera.settings', getNewSettings(camera.ptp.new.cameras[0].camera.exposure, camera.ptp.new.cameras[0].camera.status));
});
camera.ptp.on('exiting', function(model) {
console.log("CORE: camera disconnected");
console.log("CORE: camera disconnected. Count =", camera.ptp.count);
sendCameraUpdate();
});
camera.ptp.new.on('disconnect', function(model) {
console.log("CORE: camera disconnected");
console.log("CORE: camera disconnected. Count =", camera.ptp.new.cameras.length);
sendCameraUpdate();
});
camera.ptp.on('error', function(data) {
Expand Down
1 change: 1 addition & 0 deletions intervalometer/intervalometer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,7 @@ intervalometer.cancel = function(reason, callback) {
}

intervalometer.resume = function() {
if(!intervalometer.status.running) return;
logEvent("resuming time-lapse...")
camera.ptp.cancelCallbacks();
busyPhoto = false;
Expand Down

0 comments on commit 795db9c

Please sign in to comment.