Chinese brand PSU_monitoring rs485 and Mango
-
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 :
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.
-
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 :
-
"
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 :
"
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.
-
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.
-
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.
-
"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. -
9876 would than be the port i use i guess ? ( which is 9999 in my case )