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:
parent
d950ceceea
commit
e95d4a9010
@ -125,7 +125,7 @@
|
|||||||
<script type="text/x-red" data-template-name="arduino-board">
|
<script type="text/x-red" data-template-name="arduino-board">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-device"><i class="fa fa-random"></i> Port</label>
|
<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>
|
<a id="node-config-lookup-serial" class="btn"><i id="node-config-lookup-serial-icon" class="fa fa-search"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-tips"><b>Tip:</b> Use search to try to auto-detect serial port.</div>
|
<div class="form-tips"><b>Tip:</b> Use search to try to auto-detect serial port.</div>
|
||||||
|
@ -28,20 +28,23 @@ module.exports = function(RED) {
|
|||||||
this.repeat = n.repeat||25;
|
this.repeat = n.repeat||25;
|
||||||
//node.log("opening connection "+this.device);
|
//node.log("opening connection "+this.device);
|
||||||
var node = this;
|
var node = this;
|
||||||
var pre = "\\\\.\\";
|
|
||||||
if (!plat.match(/^win/)) { pre = ""; }
|
|
||||||
|
|
||||||
node.board = new ArduinoFirmata();
|
node.board = new ArduinoFirmata();
|
||||||
if (!fs.existsSync(pre+node.device)) {
|
if (!plat.match(/^win/)) { // not Windows
|
||||||
node.warn("Device "+node.device+" not found");
|
if (!fs.existsSync(node.device)) {
|
||||||
|
node.warn("Device "+node.device+" not found");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
node.board.connect(node.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else { // Windows - try to connect anyway... this can be bad...
|
||||||
node.board.connect(node.device);
|
node.board.connect(node.device);
|
||||||
node.board.on('connect', function(){
|
|
||||||
node.log("version "+node.board.boardVersion);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node.board.on('boardReady', function(){
|
||||||
|
node.log("version "+node.board.boardVersion);
|
||||||
|
});
|
||||||
|
|
||||||
node.on('close', function() {
|
node.on('close', function() {
|
||||||
if (node.board) {
|
if (node.board) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user