• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Send / Receive ASCII string through serial port?

    User help
    4
    9
    8.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mrk22
      last edited by

      Is there anyway in Mango to send an ASCII string to a serial device and capture the response? I'm trying to connect to a RS-485 thermostat. A sample request for the set temperature of the thermostat would be:

      "SN1 SH=?" and the reply would be "SN1 SH=68"

      Thanks!

      1 Reply Last reply Reply Quote 0
      • M
        mlohbihler
        last edited by

        No, not currently. The number of possibilities that people might need from something like this are too vast to build a general data source. You would be much better off building a module in M2M2 specifically for your equipment.

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • O
          oja
          last edited by

          Hi,

          I tried workaround for this. I create simple JAR with openPort, closePort and sendData method with RxTx library.

          This JAR I sent to jre/lib/ext folder with RxTx library.

          Last step was create Meta data source point with some field with Cron timing.
          In Javascript (Rhino) I wrote import of my JAR and called my methods.

          Now I am busy, but I want to create simple example and zip with my serial communicator classes.

          It works.

          Oja

          1 Reply Last reply Reply Quote 0
          • O
            oja
            last edited by

            Java script code for ASCII serial

            importPackage(com.alarex.serialcommunicator);
            
            var serial = new SerialCommunicator();
            
            var command = 'ati\r\n';
            
            x = serial.openPort("/dev/ttyS0", 115200, 8, 1, SerialCommunicator.PARITY_NONE, SerialCommunicator.FLOWCONTROL_NONE);
            
            //sendDataAsString(String, timeout for response, timeout for last byte from response - detect packet end)
            vysledek = serial.sendDataAsString(command,1000,100);
            
            
            serial.closePort();
            
            return vysledek;
            

            You can call sendDataAsString multiple and return part1+","+part2+"," part3
            and split in other fields in datasource.

            1 Reply Last reply Reply Quote 0
            • O
              oja
              last edited by

              Copy SerialCommunicator.jar to ...jre/lib/ext . RxTx library have to be installed.

              After copy you have to restart apache-tomcat.

              I attached datapoint settings picture

              Attachment: download link

              1 Reply Last reply Reply Quote 0
              • M
                mrk22
                last edited by

                OJA,

                Thank you for the reply and example. I'll give it a try!

                1 Reply Last reply Reply Quote 0
                • M
                  mkhadem
                  last edited by

                  Oja,

                  The link to your files are removed or can not be found. Please let me know how I can get your code.

                  Thanks
                  Mo

                  1 Reply Last reply Reply Quote 0
                  • O
                    oja
                    last edited by

                    Ok, I am attaching it as one ZIP.

                    Attachment: download link

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post