Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on November 04, 2020, 02:20:19 PM
-
Looking for input on how to perform the following:
I would like to store an ASCII string in a UDT. I can't do this directly. What are my options and/or limitations to storing a numeric representation of a string within a UDT?
-
Better to just have a corresponding string associated with the specific UDT.
If it's a heap-item named Recipe, have a heap-item STRING called RecipeName.
If it's a block of 100 called Recipe (Recipe0-Recipe99), create a corresponding block of 100 STRINGs called RecipeName.
The two are coupled by the index value, i.e. Recipe42 and RecipeName42 correspond with each other.
-
What's the likelihood of string being added to the UDT in the future?
-
What's the likelihood of string being added to the UDT in the future?
It would require nesting of structures. That's hard for several technical reasons.
We have ideas, just not sure when we will attack it.
-
What's the likelihood of string being added to the UDT in the future?
In the short term, no. We would like to add it some time in the future (nesting structures, for example), but that is "long term".
-
I guess something equivalent to an AB AOI isn't in the works in the short term then either?
-
I guess something equivalent to an AB AOI isn't in the works in the short term then either?
Actually, it might be. We're taking a hard look at adding a textual language for the next major release, and one of the goals is to add functions callable from in a MATH instruction.
-
Please do. I'd really like to use one (or the equivalent thereof) for expansion of a current project.
-
We've been talking about this a bit today. Maybe there is a way to get strings in UDTs. We may hit a snag we haven't identified yet, but we're gonna explore an idea we have.
-
<time passes>
...this can be done.
-
How easily and how soon?
-
How easily and how soon?
Not easily enough to sneak into 2.8 (next month), but barring unforeseen gotchas, I'd guess summer for the next release.
After realizing there is a solution that doesn't require nesting structures, no single thing appears to be hard, but there are many things.
-
Strings in UDT's! Yay!
-
Please also look at what it would take to write to a Memory.Real location using the MRX command.
-
Please also look at what it would take to write to a Memory.Real location using the MRX command.
I don't understand what this means. Is it a different Modbus function code?
-
Sorry, that really wasn't clear. It's in regards to what can be done with UDTs. Let me clarify:
After creating a UDT and assigning it to a memory location I would like to be able to use that UDT with the MRX command to write the modbus value into. For example:
Read address 40001, two consecutive registers --> store in MyUDT.Real. At current time if I try to do this I get the error message: Do-more Element not valid for the given Modbus Function: Cannot be a structure or structure field.
This is related to this post in that I would like to store the string in the UDT and the read modbus value into the UDT. I now have to create my UDT, create a helper string array and now create a helper real array to store read modbus values.
-
Sorry, that really wasn't clear. It's in regards to what can be done with UDTs. Let me clarify:
After creating a UDT and assigning it to a memory location I would like to be able to use that UDT with the MRX command to write the modbus value into. For example:
Read address 40001, two consecutive registers --> store in MyUDT.Real. At current time if I try to do this I get the error message: Do-more Element not valid for the given Modbus Function: Cannot be a structure or structure field.
This is related to this post in that I would like to store the string in the UDT and the read modbus value into the UDT. I now have to create my UDT, create a helper string array and now create a helper real array to store read modbus values.
Ah, makes sense.
I don't think there is any inherent limitation that would prevent this. This isn't the first request we've had for targeting portions of structure in comm functions. We'll look at it.
-
Also, tried MOVE(MyUDT[InderectReference].Float:UW0 to V0). This doesn't work. Don't know if this is related or not to this conversation.
-
Also, tried MOVE(MyUDT[InderectReference].Float:UW0 to V0). This doesn't work. Don't know if this is related or not to this conversation.
You can't cast a struct field. The limitation is in how DmD stores element references, there isn't enough space.
We are looking at relaxing the some of the restrictions on source and destination for MRX/MWX/MEMCOPY/etc. Please understand that the reason for the limitations was to keep users from doing things they will probably regret. We now realize that while those limitations needs to stay in place for built-in structures, we can easily relax them for UDTs.
-
Not easily enough to sneak into 2.8 (next month), but barring unforeseen gotchas, I'd guess summer for the next release.
Any updates regarding the ability to add Strings in UDT?
-
Any updates regarding the ability to add Strings in UDT?
Support for full nesting of structures, including strings, will be in 2.9, due out next month.
-
Also, tried MOVE(MyUDT[InderectReference].Float:UW0 to V0). This doesn't work. Don't know if this is related or not to this conversation.
Not sure if IndirectReference is a V register or an expression, but only a V or V + offset can be used as an index in any instruction other than MATH.
How about MEMCOPY instead of MOVE? (bearing in mind your index can only be a V or V + offset for the same reason) I't's just shuffling bit and bytes so it might be a little less picky. AND, with MEMCOPY, you wouldn't need to cast because you specify the length of the copy in the instruction.
-
Support for full nesting of structures, including strings, will be in 2.9, due out next month.
Awesome, thank you! 8)