Skip to content

Commit

Permalink
1. workaround to avoid uv__finish_close fatal error
Browse files Browse the repository at this point in the history
2. set `power` and `ground` to null in driver.json
  • Loading branch information
jerry-weng committed Aug 17, 2016
1 parent daeff36 commit 86e3de6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ picture.on('end', function () {
// ...
});
```
## FAQ
If your get error message `Cannot find USB camera`, please confirm your camera has been pluged, and power down the ruff board and then power on it agagin.

## API References

Expand Down
4 changes: 3 additions & 1 deletion driver.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"models": [
"uvc-01"
]
],
"power": null,
"ground": null
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"homepage": "https://github.com/ruff-drivers/ruff-v1-usb-camera",
"keywords": [
"ruff",
"driver"
"driver",
"USB camera",
"UVC"
],
"main": "src/index.js",
"device-typings": "typings/device.d.ts",
Expand Down
14 changes: 8 additions & 6 deletions src/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ Camera.prototype._grabInit = function (callback) {
});
}
], function (error) {
if (error) {
callback && callback(error);
return;
}
that._readPoll = new Poll(that._fifoFd);
callback && callback(error);
callback && callback();
});
};

Expand All @@ -132,6 +136,8 @@ Camera.prototype._grab = function (option, picture, callback) {
var length = fs.readSync(that._fifoFd, buffer, 0, CHUNK_SIZE, -1);
if (length === 0) {
that._readPoll.stop();
that._readPoll.close();
fs.closeSync(that._fifoFd);
picture.emit('end');
that._readCleanup(callback);
return;
Expand All @@ -150,11 +156,7 @@ Camera.prototype._grabCleanup = function (callback) {

Camera.prototype._readCleanup = function (callback) {
this._readFinish = true;
async.series([
this._readPoll.close.bind(this._readPoll),
fs.close.bind(fs, this._fifoFd),
this._cleanup.bind(this, callback)
]);
this._cleanup(callback);
};

Camera.prototype._cleanup = function (callback) {
Expand Down

0 comments on commit 86e3de6

Please sign in to comment.