• 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

    Chinese brand PSU_monitoring rs485 and Mango

    How-To
    3
    63
    57.7k
    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.
    • H
      hengst
      last edited by

      Yes , data is incoming.

      0_1477932713242_upload-9ffbf133-70e8-4e32-b554-235cb0fa7be4

      now whats next ?

      1 Reply Last reply Reply Quote 0
      • H
        hengst
        last edited by hengst

        i know i have to get the values out of the returned Hex, with some ( java? ) code
        ( in the script like in the second post probably ).

        how does such code typical looks like.

        get states of modules :

        returned code :
        7e30323030303134323030303032373432353641334437424543434343434430303030303030303345393939393941303030303030303034314338303030303431433830303030303134314338303030303030303030303031 3030303145350d

        following manuals :

        7e3032303030313432303030303237 ( length of data )
        3432353641334437 Bus voltage-float: D7A35642=53.66
        4245434343434344 Battery 1 voltage
        3030303030303030 Battery 2 voltage
        3345393939393941 Load current
        3030303030303030 Total module current
        3431433830303030 Battery temperature-float: 0000c841=25
        3431 Number of modules:
        4338303030303031 Environment humidity
        3431 System alarms
        4338303030303030 Batteries and environmental alarms
        3030 Reservation
        3031 State of charge: 1 float charging
        30 30 Relay alarm high byte
        30 31 Relay alarm low byte
        45 35 0D

        1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by phildunlap

          You could get the hex for any of these by doing something like...

          var busVoltage = /[0-9A-Fa-f]{46}([0-9A-Fa-f]{8}).*/.exec(messsage);
          var extractedValue = busVoltage[1];
          

          Using the position in the message to know where to extract them (so, after 46 characters, capture the next 8 is what that regular expression suggests). I'm not sure what the float encoding is (how does D7A35642=53.66?), so I can't really offer too much help there. Some people are talking about a hex to float function here: http://stackoverflow.com/questions/5055723/converting-hexadecimal-to-float-in-javascript

          It looks like you're working with the ASCII encoded values again, so while you're playing with the script check out the output of

          function toASCII(message) {
            var result = "";
            while(message.length > 1) { //parse two characters at a time
               var charCode = message.substr(0, 2);
               result += String.fromCharCode( "0x" + charCode );
               message = message.substr(2); 
            }
            return result;
          }
          print( toASCII(message) );
          

          In case that's useful.

          1 Reply Last reply Reply Quote 0
          • H
            hengst
            last edited by

            yes, that float things is special, i figured out is has something do do with "reversed"

            http://www.scadacore.com/field-applications/programming-calculators/online-hex-converter/

            0_1477943857945_upload-c4d36cfd-0296-4615-a6f7-003b8e3aeca9

            1 Reply Last reply Reply Quote 0
            • H
              hengst
              last edited by

              pffff, drives me crazy. putting pieces of code in the script only complains about no variable set and stuff and i don t know in what order and place to put the code.
              so,
              now i started again from scratch. but same settings do not get any data anymore.
              ( i see it coming in tcpdump )

              only in terminal i see :

              0_1477950904238_upload-a6654fa3-ebf8-4b5f-bc3d-4eccf1b5b37b

              removing everything. start from beginning. same result. this happened me twice now.

              rebooting..

              1 Reply Last reply Reply Quote 0
              • phildunlapP
                phildunlap
                last edited by

                Perhaps the device holds open the connection and your timeout is set to 0? I would give it a try with a 1000ms timeout or so.

                1 Reply Last reply Reply Quote 0
                • H
                  hengst
                  last edited by

                  Nope, reboot did not help, rebooting device and connections did not help.

                  settings :

                  0_1477951949659_upload-8a4e25f9-e204-4559-9642-7b9b6c0784e3

                  0_1477952027989_upload-9a895995-1c71-4f83-831c-8f67c82813f5

                  1 Reply Last reply Reply Quote 0
                  • phildunlapP
                    phildunlap
                    last edited by

                    Your value index is wrong. It should be 0. and your value regex can just be .*

                    1 Reply Last reply Reply Quote 0
                    • H
                      hengst
                      last edited by

                      i removed everything and restarted Mango.

                      The "value index: set to 1 was indeed the bottleneck. ( i checked to see what difference 0 or 1 made.

                      so i have data again,

                      The errors
                      "
                      WARN 2016-10-31 23:57:49,316 (com.serotonin.m2m2.rt.dataSource.PollingDataSource$2.execute:228) - PSU-tcp_ip: poll scheduled at 2016/10/31 23:57:49.316 aborted because Task Currently Runnining
                      "
                      in terminal are still there do.

                      i don t care at the moment, as getting things running is more important to me at the moment.

                      now i start building COMMAND and RESPONSE from the beginning of the forum..

                      1 Reply Last reply Reply Quote 0
                      • phildunlapP
                        phildunlap
                        last edited by

                        I mentioned how to fix that, you would turn your timeout down from 50000 ms to less than your polling interval, so less than 5000.

                        1 Reply Last reply Reply Quote 0
                        • H
                          hengst
                          last edited by

                          That fixed it indeed.

                          i noticed i can check scripting code by clicking on the "little green Script dot".

                          Its still not clear to me.

                          • Data source collects makes connection to device. ( interval for set here )
                            that is the easy part,

                          • tcp/ip Data point asks for data ( command data point )

                          • tcp/ip Data point response listen for data

                          • tcp/ip Data point "link" this to Scripting data point, "message queue" datapoint.

                          • in the "link" script screen i put in ?? which pieces of code ?

                          • in the Script Data source i also put in which pieces ?

                          i tried a lot of combinations, but i don t see it.

                          1 Reply Last reply Reply Quote 0
                          • phildunlapP
                            phildunlap
                            last edited by

                            0_1478012753217_point-links.png

                            Response --> Point Link to parse values --> Scripting Data Source to process message queue into points' values

                            1 Reply Last reply Reply Quote 0
                            • H
                              hengst
                              last edited by hengst

                              Alright i got it. thnx.

                              i had little play with :

                              var busVoltage = /[0-9A-Fa-f]{46}([0-9A-Fa-f]{8}).*/.exec(source.value);
                              var extractedValue = busVoltage[1];

                              print (busVoltage[1]);

                              Script result:
                              42453939

                              so that works, i found code for converting the hex to float, but no knowledge of writing (java) coding structure is a show stopper at the moment. but i do have fun learning , gehehe

                              1 Reply Last reply Reply Quote 0
                              • phildunlapP
                                phildunlap
                                last edited by

                                Nice!

                                All the scripts use JavaScript.

                                1 Reply Last reply Reply Quote 0
                                • H
                                  hengst
                                  last edited by hengst

                                  little update ,

                                  i found that i need to convert in javascript the with sort of

                                  function hex2float(num) {
                                  var sign = (num & 0x80000000) ? -1 : 1;
                                  var exponent = ((num >> 23) & 0xff) - 127;
                                  var mantissa = 1 + ((num & 0x7fffff) / 0x7fffff);
                                  return sign * mantissa * Math.pow(2, exponent);
                                  }
                                  
                                  
                                  
                                  window.alert (hex2float("0xA4703942"));
                                  //flipped does the trick
                                  window.alert (hex2float("0x423970A4"));
                                  // outcome 46,36..... ( not rounded )
                                  
                                  ``
                                  
                                  so little progress here.
                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    hengst
                                    last edited by

                                    Perfectum Resultativum ;

                                    0_1478170444805_upload-5743d503-afdb-46f8-8648-2edc42e2fdcc

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      hengst
                                      last edited by

                                      now put all this in Mango needs again some pointers i think..

                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        hengst
                                        last edited by

                                        i got this in " point links as script " , is this ok ?

                                        0_1478275755900_upload-2b88dd9b-44ca-49ba-82c2-ab67bf96dfa0

                                        and what to put in :

                                        the script - source script. ?

                                        i tried 1000 different combinations. and reading the wiki / manuals. but sorry, i don't
                                        get it...

                                        1 Reply Last reply Reply Quote 0
                                        • phildunlapP
                                          phildunlap
                                          last edited by

                                          Looking at your message queue, there are no identifiers. I assume this is because this is always for the same point. You could connect the point link to a point directly representing that value, if there is only one point's value in a message. Otherwise, you'll want some identifiers so that your script can parse the message queue and set points identified by the identifier to the value. I would have the identifiers in an object, where the object looks something like...

                                          { "identifier1" : p334, .....}
                                          

                                          Where p334 is the variable name for the context point of the script.

                                          1 Reply Last reply Reply Quote 0
                                          • H
                                            hengst
                                            last edited by

                                            identifiers, object etc, is probably JavaScript terms....hmm and i was thinking it was almost done, gehehe.
                                            i need a neighbor with programming skills ( the neighbors house is for sale btw )
                                            so back to learning books ..

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