Help with a serial data point
-
Hello,
How would I bring in the below string as a data point’s value via serial connection? This is a HEX string and the only constant is the starting 7e so I’m struggling to come up with the point’s point id, point value ID and regex. To start, I would like to bring in the whole string or everything after the 7e as the point’s value but I may eventually parse it out into separate data points (possibly for another question, we’ll see if I can figure that part out). I have the data source set up and see this value in the log but cannot seem to get the data point to recognize it as a value.
Here’s the string: 7e0012920013a20040c33746114d4101001000000088
Thanks,
-
Hi jmln5000,
To your future question, here's a thread where I helped someone with the general shape of implementing a device's customer protocol using the serial data source: https://forum.infiniteautomation.com/topic/2517/chinese-brand-psu_monitoring-rs485-and-mango It's a pretty long read and we go many things, but he got it doing what he wanted by the end.
To your now question, you probably want a catchall point to start getting the hang of things. From that thread:
"""- Serial Data Souce:
configuration in hex: true message regex: ().* point identifier index: 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.
"""
-
This post is deleted! -
I’m not sure that I am maintaining the hex format from Mango's data source to the data point. When I add the data source and select ‘configuration is in Hex’, I see my expected output in the log:
7e0012920013a20040c337461ec84101001000000000
I then created a data point in the serial data source called serialDataPoint01 and added that to a script as var sdata01. Both the data point details page and the script: print (sdata01) just return garbage:
value: ~��@�7F�A
Just for the fun of it, I converted the garbage to hex with a script and got close but not exact:
7e 00 12 fd 00 13 fd 00 40 fd 37 46 1e fd 41 01 00 10 00 00 00 00
Any thoughts on where I’m going wrong?
Thanks,
-
I’m not sure that I am maintaining the hex format from Mango's data source to the data point. When I add the data source and select ‘configuration is in Hex’, I see my expected output in the log:
7e0012920013a20040c337461ec84101001000000000
I then created a data point in the serial data source called serialDataPoint01 and added that to a script as var sdata01. Both the data point details page and the script: print (sdata01) just return garbage:
value: ~��@�7F�A
Just for the fun of it, I converted the garbage to hex with a script and got close but not exact:
7e 00 12 fd 00 13 fd 00 40 fd 37 46 1e fd 41 01 00 10 00 00 00 00
Any thoughts on where I’m going wrong?
Thanks,
I could still use some help with this one please. If I set a point value using a single hex value from a serial device, I just see garbage in the data point details view or by scripting [print(serialDataPoint.value)]. I read through the entire suggested blog post several times and it makes sense but I’m not getting far enough with my setup to even think about parsing the hex string. For the sake of simple testing I am now feeding a single hex value to mango via serial connection from an arduino. All hex values that I send to Mango show up perfectly in the serial connection log but show up as garbage in the point value. I can then turn most of these garbage values back into valid hex values with a small script that converts ascii to hex but some values do not work in this conversion like 0x7e for example, which turns to fd.
-
Phil and Mango Team -
This thread has been quiet for a while so I just want to reach out one last time for help before giving up on mango. So you don't feel like you're wasting time, my intent here is to ultimately purchase several mango es devices for an industrial project that I am involved in. I have successfully tested and used a couple of other configurations for this but I am impressed with mango and very interested in making a switch if we can solve this simple hex value problem. I’m not asking for custom code to parse the values. All I am asking is to get a hex value from a serial data source into the value of a data point so that I can script around it. The scripting and UI design, everything else I can handle. I just think that when I check the value hex box in a serial data source, that the resulting hex value should carry throughout mango as hex and not turn to garbage when I view it in any of the several ways I have discussed or try to script on it. Please either tell me its a bug with a fix date or point me in the right direction. I am very serious about making this work, given up many hours of my time to do to so and now I’m at a complete loss.
Some additional detail since last post:
For test purposes I am sending 0xfe from arduino every 5 seconds.
I can also duplicate this with my other existing and known-good end devices, several other configurations in mango, and any number of hex values but for simplicity, I am testing with an arduino plugged into my windows 10 laptop’s USB port.
If I follow your above blog post excerpt exactly, I get one character of garbage in the response’s data point value viewed by either the data point details utility or by scripting print response.value in a scripting data point.
Just for fun, I tried and can convert some of these garbage values back to hex but not all.
Please help. I really want Mango to work for this project!
--Jason
-
Hi Jason,
Have you tried setting your data point type as Alphanumeric. If you want to have your values displayed in a hex format in Mango I think the only way to do that would be to have the Data Point Alphanumeric.
It might be helpful for us to understand better why you need the data values preserved in Hex. Mango doesn't have a Hex rendering option for display of values but you might be able to use an Alphanumeric point for this but will depend on what other things you are trying to do with the data
-
Hi Joel,
Your question is leading me to think about this a little different. I'm wrapped up in how this looks but I don't really need to see my values. I need to parse that hex string, perform some logic on a couple values and then act upon it. If the value is intact at it's binary state in memory (and I bet it is), I should be able to do that without seeing it. I will take that approach this week and see what I come up with.
Thanks so much!
- Jason