1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Update Ardunio node slightly in line with latest Windows Serialport patches.

(But there is still a possibly bad underlying problem 
- error not being caught -  in the upstream npm - reported.)
This commit is contained in:
Dave C-J 2014-10-04 22:26:02 +01:00
parent d950ceceea
commit e95d4a9010
2 changed files with 13 additions and 10 deletions

View File

@ -125,7 +125,7 @@
<script type="text/x-red" data-template-name="arduino-board">
<div class="form-row">
<label for="node-config-input-device"><i class="fa fa-random"></i> Port</label>
<input type="text" id="node-config-input-device" style="width:60%;" placeholder="/dev/ttyUSB0"/>
<input type="text" id="node-config-input-device" style="width:60%;" placeholder="e.g. /dev/ttyUSB0 COM1"/>
<a id="node-config-lookup-serial" class="btn"><i id="node-config-lookup-serial-icon" class="fa fa-search"></i></a>
</div>
<div class="form-tips"><b>Tip:</b> Use search to try to auto-detect serial port.</div>

View File

@ -28,19 +28,22 @@ module.exports = function(RED) {
this.repeat = n.repeat||25;
//node.log("opening connection "+this.device);
var node = this;
var pre = "\\\\.\\";
if (!plat.match(/^win/)) { pre = ""; }
node.board = new ArduinoFirmata();
if (!fs.existsSync(pre+node.device)) {
if (!plat.match(/^win/)) { // not Windows
if (!fs.existsSync(node.device)) {
node.warn("Device "+node.device+" not found");
}
else {
node.board.connect(node.device);
node.board.on('connect', function(){
}
}
else { // Windows - try to connect anyway... this can be bad...
node.board.connect(node.device);
}
node.board.on('boardReady', function(){
node.log("version "+node.board.boardVersion);
});
}
node.on('close', function() {
if (node.board) {