Read the statement by Michael Teeuw here.
How to use the 'node_helper', 'serialport'
-
@nhpunch said in How to use the 'node_helper', 'serialport':
if(this._isPushed==false)
where is _isPushed defined or set?
i know it is in module_name.js, but node_helper cannot see it…
you should send that as the payload on button_pressed message
-
socketNotificationReceived: function (notification, payload) { if (notification === 'CONFIG') { const self = this; self.config = payload; } else if(notification ==='BUTTON_PRESSED') { this._isPushed = payload; var serialport = new Serialport('/dev/ttyACM0', { baudRate: 9600 });
Is that right? I’m really sorry for you.
-
@nhpunch yes if you send it that way
this.sendSocketNotification(“BUTTON_PUSHED”,this._isPushed)
-
false, true
works with two button in moduleIt seems that the value can not be sent to the node_helper
why?
buttonoff.addEventListener('click', ()=> { Log.log("button pushed 'on'") this._isPushed = false; console.log(this._isPushed); }); button.addEventListener('click', ()=> { Log.log("button pushed 'off' ") this._isPushed = true; console.log(this._isPushed); });
this is module
serialport.write(this._isPushed==true? '1' : '0');
this is node_helper
-
else if(notification ==='BUTTON_PRESSED') { this._isPushed = payload; console.log(payload);
‘false’ is displayed in the terminal window
._isPushed is passed to node_helper, but I think that the changed value is not sent when the button is pressed.
Please advise…:folded_hands_light_skin_tone: :folded_hands_light_skin_tone: :folded_hands_light_skin_tone:
If this is solved, it’s really a success.:flexed_biceps_light_skin_tone:
-
@nhpunch said in How to use the 'node_helper', 'serialport':
buttonoff.addEventListener('click', ()=> { Log.log("button pushed 'on'") this._isPushed = false; console.log(this._isPushed); this.sendSocketNotification(“BUTTON_PUSHED”,this._isPushed) }); button.addEventListener('click', ()=> { Log.log("button pushed 'off' ") this._isPushed = true; console.log(this._isPushed); this.sendSocketNotification(“BUTTON_PUSHED”,this._isPushed) });
-
._isPushed
was sentbut there was an error… im really sad
-
@nhpunch that is in the node_helper, serial library
looks like serialport.write(data: string|Buffer|Array,
i don’t know anything about serial port api… looks like promise based, so would need callbacks or .then()
-