mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
don't eat all the files.
This commit is contained in:
parent
a607951b7d
commit
cb6f17cde8
1 changed files with 19 additions and 11 deletions
|
|
@ -12,17 +12,25 @@ var baudrate = process.argv[3];
|
|||
var active = false;
|
||||
|
||||
function attemptLogging(fd, port, baudrate) {
|
||||
var serialPort = new SerialPort.SerialPort(port, {
|
||||
baudrate: baudrate
|
||||
});
|
||||
fs.write(fd, "\n------------------------------------------------------------\nOpening SerialPort: "+target+" at "+Date.now()+"\n------------------------------------------------------------\n");
|
||||
serialPort.on("data", function (data) {
|
||||
fs.write(fd, data.toString());
|
||||
});
|
||||
serialPort.on("close", function (data) {
|
||||
active = false;
|
||||
fs.write(fd, "\n------------------------------------------------------------\nClosing SerialPort: "+target+" at "+Date.now()+"\n------------------------------------------------------------\n");
|
||||
});
|
||||
if (!active) {
|
||||
fs.stat(port, function (err, stats) {
|
||||
if (!err) {
|
||||
active = true;
|
||||
|
||||
var serialPort = new SerialPort.SerialPort(port, {
|
||||
baudrate: baudrate
|
||||
});
|
||||
fs.write(fd, "\n------------------------------------------------------------\nOpening SerialPort: "+target+" at "+Date.now()+"\n------------------------------------------------------------\n");
|
||||
serialPort.on("data", function (data) {
|
||||
fs.write(fd, data.toString());
|
||||
});
|
||||
serialPort.on("close", function (data) {
|
||||
active = false;
|
||||
fs.write(fd, "\n------------------------------------------------------------\nClosing SerialPort: "+target+" at "+Date.now()+"\n------------------------------------------------------------\n");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!port) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue