mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
Ticket: 104, reverting back.
This commit is contained in:
parent
b74a50d704
commit
ce51f4d093
1 changed files with 43 additions and 28 deletions
|
|
@ -198,36 +198,51 @@ function listUnix (callback) {
|
|||
}
|
||||
return console.log(err);
|
||||
}
|
||||
fs.readdir("/dev/serial/by-path", function(err_path, paths) {
|
||||
if (err_path) {
|
||||
if (err.errno === 34) return callback(null, []);
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
var dirName, items;
|
||||
//check if multiple devices of the same id are connected
|
||||
if (files.length !== paths.length) {
|
||||
dirName = "/dev/serial/by-path";
|
||||
items = paths;
|
||||
} else {
|
||||
dirName = "/dev/serial/by-id";
|
||||
items = files;
|
||||
}
|
||||
|
||||
async.map(items, function (file, callback) {
|
||||
var fileName = path.join(dirName, file);
|
||||
fs.readlink(fileName, function (err, link) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
link = path.resolve(dirName, link);
|
||||
callback(null, {
|
||||
comName: link,
|
||||
manufacturer: undefined,
|
||||
pnpId: file
|
||||
});
|
||||
var dirName = "/dev/serial/by-id";
|
||||
async.map(files, function (file, callback) {
|
||||
var fileName = path.join(dirName, file);
|
||||
fs.readlink(fileName, function (err, link) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
link = path.resolve(dirName, link);
|
||||
callback(null, {
|
||||
comName: link,
|
||||
manufacturer: undefined,
|
||||
pnpId: file
|
||||
});
|
||||
}, callback);
|
||||
// Suspect code per ticket: #104 removed for deeper inspection.
|
||||
// fs.readdir("/dev/serial/by-path", function(err_path, paths) {
|
||||
// if (err_path) {
|
||||
// if (err.errno === 34) return callback(null, []);
|
||||
// return console.log(err);
|
||||
// }
|
||||
|
||||
// var dirName, items;
|
||||
// //check if multiple devices of the same id are connected
|
||||
// if (files.length !== paths.length) {
|
||||
// dirName = "/dev/serial/by-path";
|
||||
// items = paths;
|
||||
// } else {
|
||||
// dirName = "/dev/serial/by-id";
|
||||
// items = files;
|
||||
// }
|
||||
|
||||
// async.map(items, function (file, callback) {
|
||||
// var fileName = path.join(dirName, file);
|
||||
// fs.readlink(fileName, function (err, link) {
|
||||
// if (err) {
|
||||
// return callback(err);
|
||||
// }
|
||||
// link = path.resolve(dirName, link);
|
||||
// callback(null, {
|
||||
// comName: link,
|
||||
// manufacturer: undefined,
|
||||
// pnpId: file
|
||||
// });
|
||||
// });
|
||||
// }, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue