• 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
    43.4k
    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

      I tracked down the software engineer of the device ( how about that , gehehe ) he is writing a excel sheet for frame calculation Monday.

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

        playing and gambling, ( couldn't wait till Monday ) i found the command :

        7e 30 32 30 30 30 31 34 32 30 30 30 30 30 32 30
        30 30 31 36 43 0d

        ( request node ID command )

        will result in :

        ~02000142040000AD or

        7e 30 32 30 30 30 31 34 32 30 34 30 30 30 30 41 44

        I found this with the tool : https://sourceforge.net/projects/scriptcommunicator/
        as i almost work all the time with Linux, this was a golden tool to play around with the commands.

        i used these settings for the usb-rs485 communication :

        0_1477734194513_upload-8ce15371-5806-4a16-9939-b21806928882

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

          "
          While implementing this will teach you a lot about Mango and this device, I can't help but wonder if it'll save you time and money to use a device that has a standard protocol? "

          I know,
          i ordered it with the idea to use it as with a build in SNMP agent ( as most network devices have these days ) but i didn't look good at the specs, as a result i cant add it to my ( LibreNMS ) monitoring, because its a "dumb" device.

          The device is sold as width TCP/IP connection option and default rs485. ( i bought width both )
          as i also added a Kwh meter to the setup, ( see topic SDM120-ModBus ) which is also rs485(ModBus) i needed another monitoring tool. and it looks like Mango is filling the gap here, as it does SNMP and rs485(modbus) etc..

          As its a VERY cool thing to build and learn, and by posting the results ( in the end as a HOW TO summary ) i am contributing my part to the community's , i am convinced it will help others.

          When i got it running it also benefits "Mango" , as then we are going to use it at customers for monitoring anything the want.
          Anyway i love it already very much.

          so, back to lab.

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

            alright. i got everything complete.

            at the point i had figured out how the frame structure functioned, i got some explanation from the other side of the world.

            it was in Chinese language, but i have translated it with big brother google.

            0_1477746072797_io-codes-recti_translated.pdf

            So i think its time to get something done in Mango,

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

              Nice! You should be able to test the examples in that document by simply setting 'COMMAND' to the hex (without the spaces, I would think) and checking the RESPONSE point. Then you can experiment with either parsing the values out through regex serial points or implementing the extractMessageInformation function in the point link. You can still use regex in the script, doing the regular JavaScript syntax:

              var messageData = /7E(.*)0D/.exec(RESPONSE.value); //source.value in the actual point link script
              var messageBody = messageData[1];
              
              1 Reply Last reply Reply Quote 0
              • H
                hengst
                last edited by

                Jup, that works :

                0_1477748487474_upload-8158d6a8-465a-4c8c-9254-380c6c316944

                "
                implementing the extractMessageInformation function in the point link. You can still use regex in the script, doing the regular JavaScript syntax:

                that is new for me.. but banging my head on the desk and grabbing a cold beer and we are good to go another few hours gehehe.

                Thanks for the pointers Phil.

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

                  Nice! That looks like the ASCII (since it doesn't begin with HEX) payload perhaps? Maybe it would be better to just do the regex parsing on the Serial Data source points, then, if you don't have to do any of the conversion to or from hex.

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

                    I had a little throwback....

                    after i did get this response i was lost in how everything worked in Mango,
                    so i thought it would be good to start over from scratch.

                    also i changed the source from "serial data source" to " tcp/ip" data source ( as that is what i need to use in the end )
                    ( the PSU happens to have both options to get the information )

                    that shouldn't make a big difference in the working flow of mango i think.

                    i tested the commands over tcp/ip with SerialComm program to confirm and it works just like Serial.

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

                      "Shouldn't make a big difference..."

                      I wouldn't think so either. Do you still have the same setting for sending hex? You can always test the TCP/IP data source against netcat, to see what's coming out of it. Simply nc -l 9876 and point the TCP/IP data source at that machine's 9876 port.

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

                        9876 would than be the port i use i guess ? ( which is 9999 in my case )

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

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • H
                            hengst
                            last edited by

                            I used tcpdump , and looks like there is interaction,

                            0_1477930282597_upload-66409ea6-ec39-4a22-be72-c7c7674ac23e

                            1 Reply Last reply Reply Quote 0
                            • 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
                                            • First post
                                              Last post