two serials at the same time

Posted on
  • Hi, all!
    I use two serials simultaneously.

    and 
    

    Serial3.on('data', function (data2) {... i cant write like Serial3.on('data2', function (data2) {...```
    last one doesn't work
    if both serials work, some wrong data I see in the serial buffer- doubled snippets...
    how do I do it right?

  • You should not write SerialN.on('data2'... ) beacause there is no such message. All serials can register a callback on the 'data' event. then the variable 'data' (which is a different thing from the name of the event) is local to the function, so no need to call it differently.

    So, what i mean is:

    Serial2.on('data', function(data) { console.log("Received " + data + "on serial2") });
    Serial3.on('data', function(data) { console.log("Received " + data + "on serial3") });
    

    should just work.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

two serials at the same time

Posted by Avatar for Andrey @Andrey

Actions