plc4x icon indicating copy to clipboard operation
plc4x copied to clipboard

"Modbus plus"

Open splatch opened this issue 3 years ago • 9 comments

This pull request solves few errors I spotted while trying to use plc4j modbus stuff. First of all, it adds support for String outputs from modbus requests, so holding:3000:STRING[30] will bring back up to 15 character text which wasn't covered properly by codegen till now. It works with vstring stuff Ben added a while ago. Then there is second part which is actual modbus plus stuff. I provided sample request/responses I acquired from inverter, so its possible to see actual packets and payload mapping. For now I did stick with structs as identification answer is nested structure with variable list of elements.

splatch avatar Apr 19 '22 22:04 splatch

Seems C templates needs to be updated as well to handle string fields. Sadly I can't handle that part.

splatch avatar Apr 20 '22 09:04 splatch

Ther test.mspec contains vstring fields ... could you please elaborate on what is actually not working? In this case the test.mspec should be extended with an example that doesn't work. Then I'll take care of fixing this.

chrisdutz avatar Apr 20 '22 10:04 chrisdutz

Ther test.mspec contains vstring fields ... could you please elaborate on what is actually not working? In this case the test.mspec should be extended with an example that doesn't work. Then I'll take care of fixing this.

I think it might be related to use of vstring inside data-io:

        ['STRING' List
            [simple vstring '8 * numberOfValues' value encoding='"UTF-8"']
        ]
        ['WSTRING' List
            [simple vstring '16 * numberOfValues' value encoding='"UTF-16"']
        ]

For Java problem was that case statement was catching this as List, so there is a need to verify plain type read from buffer. If its String then, output is not an array but, just an string.

splatch avatar Apr 20 '22 10:04 splatch

Your mspec fragment looks a bit fishy in general ... the type you define as "List" and not as "String" and where does the "numberOfValues" come from?

chrisdutz avatar Apr 20 '22 10:04 chrisdutz

Your mspec fragment looks a bit fishy in general ... the type you define as "List" and not as "String" and where does the "numberOfValues" come from?

Its being called when you declare field data type as STRING[10].

splatch avatar Apr 20 '22 10:04 splatch

"List" would require a field of type array labeled "value" .... So I think this should be "STRING" instead ... but the variable of the length I can't see where it's coming from.

chrisdutz avatar Apr 20 '22 10:04 chrisdutz

I get your point as it is tricky. For me with high level language it makes sense to avoid construction of a String[] {"a", "b", "c", "d" } and return directly a String "abcd" to the caller.

splatch avatar Apr 20 '22 10:04 splatch