0

RS232 communications from node js

Is it possible to send/receive serial RS232 commands from node js?  Is there any documentation or sample code?

1 comment

  • 0
    Avatar
    acalleja

    Hi! 

    I did a test for this.. in the html file you can include this: 

    //IN BODY SECTION

    <input type="button" id="ButtonSerial" value="Send Serial" onclick="SendSerial()"/>
    <input type="text" name="TextSerial" id="TextSerial">

    ////IN SCRIPT SECTION

    //SERIAL RECEIVE
    var MiSerial = new BSSerialPort(1);
    MiSerial.SetBaudRate(9600);
    MiSerial.SetDataBits(8);
    MiSerial.SetStopBits(1);
    MiSerial.SetParity("none");
    //MiSerial.SetEcho(true);
    MiSerial.SetGenerateLineEvent(true);

    MiSerial.onserialline = function(e){
    //console.log('### onserialline: ' + e.sdata);
    document.getElementById("TextSerial").setAttribute("value", e.sdata);
    }

    //SERIAL SEND
    function SendSerial(){
    document.getElementById("TextSerial").setAttribute("value", "Serial Enviado");
    //MiSerial.SendByte(89);
    MiSerial.SendBytes('Hello World!\r');
    }

     

    Hope it helps..!

    Alvaro

Please sign in to leave a comment.