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

Chinese brand PSU_monitoring rs485 and Mango


  • I would like to add a Chines brand PSU monitorng device to Mango.
    from now on called "PSU"

    connection in between is PC -usb_rs485 adapter and PSU is rs485 port.

    0_1477579559365_PSUmonitoring_protocol.pdf

    at the moment i am trying to get a "hit" with the Modscan node scan with following settings. but no luck

    0_1477579694887_upload-83782730-4a57-44fc-84c1-33dd89dccdb9

    It looks not like a standard Modbus protocol to me ( iam a newby) , and i dont know what protocol its talks , or what i should use in Mango.

    maybe someone can shine a light on it, and helping complete this how to.


  • That is not a modbus protocol. That's a custom serial protocol, by the brief looks of it.

    This protocol could be implemented using a Scripting Data Source, a Point Link and a Serial Data Source, but I would not expect it to be easy.

    From briefly reading the document, you'll want something like...

    1. Serial Data Souce:
    configuration in hex: true
    message regex: ().*
    point identifier index: 1
    
    1. Two serial data points, I will call one 'COMMAND' and one 'RESPONSE'
    COMMAND:
    data type: alphanumeric
    value regex: .*
    value index: 0
    settable: true
    identifier: COMMAND
    
    RESPONSE:
    data type: alphanumeric
    value regex: .*
    value index: 0
    settable: false
    identifier:
    

    The RESPONSE serial point will catch everything, and COMMAND will be the place we send queries of values from.

    1. Create a Scriping Data Source, don't worry about the script just yet. Create a point on the scripting data source, call it 'Message Queue' and give it the variable name 'mesq' or whatever you like. Make it settable.
    2. Create a Point Link from the RESPONSE to the Message Queue. In the script body of the Point Link,
    //pseudocode
    function extractMessageInformation( message ) {
        //You would have to implement this based on the protocol
        // "message" should appear as the full hexadecimal of the message as a string meaning
        // every two characters is a byte. Part of your protocol says the actual data segment is
        // ASCII encoded, so you may need to pass that substring to an hex_to_ascii( string ) function
        // or the other way around. You'll want to return a string with an identifier and value
        // I will presume they are identifier-value
    }
    
    message = extractMessageInformation(source.value);
    return target.value + message + ";";
    
    1. Create the script on the scripting data source. Add points to the context for every point you are reading from the meter, so that you can set the parsed values out to these points.
    var identifierMap = { "messageIdentifier" : contextPoint1 ....  }
    var processMessages = mesq.value; //Note this is imperfect, if the point link sets between these
    mesq.set(""); //a message can be lost. You could use mesq.lastValues(2) to check that you get [processMessages, ""]
    var index = -1;
    while( (index = processMessages.indexOf(";")) != -1 ) {
        messageInfo = processMessages.substr(0, index).split("-");
        identifierMap[ messageInfo[0] ].set(messageInfo[1]);
        processMessages = processMessages.substr(index+1);
    }
    

    And that about does it! We try not to get too involved in understanding particular protocols in free support (you are welcome to post them, though), but hopefully this is enough to give you some idea.


  • I forgot to discuss reading values. For that you'll have the script issue the set() to the COMMAND point on its regular cron, in the form of a hexadecimal string. This is where you may need to encode the ASCII into the hex before setting the point, since your protocol is expecting something like "7F0DAAABBBCCCDDDEEEFFF123456" but you'll have to be able to encode the checksum and length fields, or you can hardcode a bunch of queries.

    READ_QUERY_1 = "7F0DXXXXXXXXXXXXXXXXXXXXXCRC0D";
    COMMAND.set(READ_QUERY_1);
    

    If you want the user to be able to query for something easily, you can have an alphanumeric point using a point link to set the COMMAND point and constructing the protocol overhead for you in 'setting' the query point to get information from the device.


  • WOW, my head is spinning. thnx Phil. love to dive into this.

    strange it is not a common protocol. why would someone create something different....

    so far i cant find the device/node with the modbus scan , probably because of the protocol difference.

    i do have reactions on the device when sending random bits with Mango. so i know there can be communication over the wire.

    back to the learning books..


  • One can have quite a bit of fun with Mango!

    It may have more than one communication mode, but I do not believe the document you posted describes a modbus implementation. The Modbus scan tool doesn't always work, so you're better off testing with the point locator test tool or the range read tool.

    A hardware developer may choose to write a custom protocol because it is easiest for them, but judging from the size of the document there's quite a bit of commands to fully implement it.


  • This post is deleted!

  • This post is deleted!

  • I would get started with the Serial Data source COMMAND and RESPONSE points. That way you can send any example hexidecimal from the document by setting the command point to that value (from anywhere in Mango that you can set points) and see the response in the response point.


  • so far i got :

    0_1477605011307_upload-c8d81ab0-00e0-4b6d-9864-d9eea6885769


    0_1477605112543_upload-69887503-73a5-4fe9-966c-ed5c360fa576


    0_1477605151292_upload-bf84e49b-72cc-45f6-81fb-a2bc582d7a3b


    0_1477605207735_upload-b90619f1-e2db-4274-8617-d1bcbba6b90f


    0_1477605237897_upload-af423953-ae5f-4c8b-aca0-e317ff60767a

    i am no programmer, can read some code. but think i can start to create a first COMMAND at this point from the Hex code thats in the manual ?


  • I would make the Message Queue point on the scripting data source (it also has data points) as an alphanumeric. You won't need RESPONSE in your script context.

    I think if you have the COMMAND and RESPONSE points configured you should be able to test setting the command and getting a response, without having to worry about parsing the response at all. That way you won't go too far into getting a message parsing script working before learning how a few messages behave.

    I should also have noted you could use the Serial Data source's regex fields to parse out the values, removing the need for the script except for polling the data. But, I didn't recommend that because the payload is ASCII so I figured you would need to do some conversion anyway.


  • i think i need a simple query to start, so requesting the module ID should be a good start ( which is 2 at the moment ) .

    i am struggling to make a code out of the manual data, can take a while when i have figured that out.

    0_1477607004363_upload-993a113b-a8d0-401c-b993-ea9a84e3d6a0


  • almost a whole day , still no clue what is should put in for VER ADR LENGHT COMMAND_INFO CHKSUM

    I look for a reference for learn how to read it.....


  • There is an example data frame provided in the document, item 3.5. It's not the most impressive or elucidating explanation, though.

    Looks to me like the version is 02 but transmitted as 3032 (so in setting the hex COMMAND point you'd use 3032, I am guessing, as well as the whole upper row. ADR appears to be the address of the device-1 (they say they're using address 3, but encode 30303032 (0002)!) LENGTH will depend on your command, as will the value for COMMAND_INFO. CHKSUM will require adding up the bytes of the message and doing a remainder operation, it's stated what it is in 3.3, but it's a one byte checksum, and perhaps the internet will describe that to you better than this document, if required.

    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?


  • Also something is clearly wrong about my understanding of that, since the data length of sending a 3032 is two bytes (0b00110000 0b00110010) but it's clearly stated to be one byte for the version number. Then, why is 02 on the lower row? This is why i don't get over involved in every protocol that comes by... they aren't always easy to make sense of. So is it sending the 7F [LOWER ROW] 0D? Then what is the point of the top row?


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


  • 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


  • "
    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.


  • 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,


  • 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];
    

  • 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.