News:

  • June 28, 2026, 06:00:15 PM

Login with username, password and session length

Author Topic: Outstanding Update for Do-more!  (Read 44745 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3612
  • Darth Ladder
Re: Outstanding Update for Do-more!
« Reply #15 on: September 20, 2017, 04:04:28 PM »
MAPIO doesn't provide anything you couldn't already do, but it does provide a nicely compact display. I still like using it for the application clarity.

I have been too, but now with COPY as an alternative, I might switch to using that instead.  Have to give it a test run.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Outstanding Update for Do-more!
« Reply #16 on: September 20, 2017, 04:16:30 PM »
Here's all the gory details of what COPY can do for you.   ;D

See the attached .PDF

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3612
  • Darth Ladder
Re: Outstanding Update for Do-more!
« Reply #17 on: September 20, 2017, 04:23:48 PM »
Nice chart!  So it looks like if you want that, COPY (element/value oriented) and MEMCOPY (value agnostic/byte oriented) cover everything except for clearing strings.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Outstanding Update for Do-more!
« Reply #18 on: September 20, 2017, 04:47:44 PM »
Nice chart!  So it looks like if you want that, COPY (element/value oriented) and MEMCOPY (value agnostic/byte oriented) cover everything except for clearing strings.

COPY also does NOT support setting a STRING or RANGE of STRINGs to a String Literal, whether it's "" or "Hello, world!".

STRINIT may be a new instruction some day.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3612
  • Darth Ladder
Re: Outstanding Update for Do-more!
« Reply #19 on: September 20, 2017, 05:37:37 PM »
Why does MEMCOPY not work into a string?  Danger of including the string terminator?  IS there a string terminator, or you just set the .LEN?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3612
  • Darth Ladder
Re: Outstanding Update for Do-more!
« Reply #20 on: September 20, 2017, 07:00:29 PM »
Oh yeah, that reminds me I was going to put in a feature request to have all UI configuration settings in a common file and have new installs offer to copy the existing configuration settings if any exist.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Outstanding Update for Do-more!
« Reply #21 on: September 21, 2017, 11:56:24 AM »
Why does MEMCOPY not work into a string?  Danger of including the string terminator?  IS there a string terminator, or you just set the .LEN?
MEMCOPY supports STRINGs.  The Source and Destination .MaxLength values must match (since the instruction is just blindly copying memory bytes from the Source to the Destination).  If the .MaxLength values do NOT match, use STRPRINT or STRSUB - or (duh) the new COPY instruction!

There is no NUL termination character, unless you put one there.  The structure's .Length member specifies the "length".  Note that if you do append a "$00", it WILL be accounted for in the .Length member!

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3612
  • Darth Ladder
Re: Outstanding Update for Do-more!
« Reply #22 on: September 21, 2017, 02:00:09 PM »
Oops!  I was looking at "Write a text to a string" and "Write a text to a range of strings" which MEMCOPY doesn't do, but missed "Write a string to a string" and so on, which it does.

Which raises the question: What do mean by "string" vs. "text"?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Outstanding Update for Do-more!
« Reply #23 on: September 21, 2017, 02:14:22 PM »
Which raises the question: What do mean by "string" vs. "text"?

String is a memory based element that is a String structure.  Text should be stated as being a "string literal" (yes, quote-pun intended).

SS0 is a string
"Hello, world!" is a string literal; text in the chart

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Outstanding Update for Do-more!
« Reply #24 on: September 22, 2017, 02:22:42 PM »
How do we populate a user structure with values? I am not seeing in the PDF above how to copy or move or whatever, 7 N or V type locations into a structure I have created which is 7 mixed items of unsigned word or signed word and 16 bit items (which are to be pulled out of the first item.) These are values I would want to read from a Modbus TCP device using MRX.

I don't seem to be able to have the structure be a destination for the MRX. But I also don't seem to be able to simply transfer values from N0-N6 into my heap-item/structure. I figure I can't directly get the bits copied but thought I could do the 7 words at one go.

Hopefully I am just missing something.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Outstanding Update for Do-more!
« Reply #25 on: September 22, 2017, 02:30:32 PM »
Structures are kinda special, and in general we haven't encouraged memory layout awareness or access. I guess now that we are allowing you to make your own, we may need to revisit that and make structures valid a source or target everywhere it makes sense. Until we do that, I guess you will have to resort to using MEMCOPY to move data between structures and block memory.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Outstanding Update for Do-more!
« Reply #26 on: September 22, 2017, 02:32:15 PM »
This is where it can get tricky.

If you understand C unions, you could do it memory based using MEMCOPY if you laid out your UDT EXACTLY like the Holding Register layout.

If you have never done C unions or what that means or looks like, then just use the new COPY instruction.  Casting is allowed.

COPY
N0 MyStruct.FieldA
N1 MyStruct.FieldB
N2:R MyStruct.RealField
N4:0 MyStruct.BitA
N4:1 MyStruct.BitB
N4:2 MyStruct.BitC
etc.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Outstanding Update for Do-more!
« Reply #27 on: September 22, 2017, 02:40:29 PM »
If you want a lesson on C unions, export your UDT and paste it here.  Also, list the definition of your Holding Registers (are they all signed 16 bit integers?  are some bit masks?  are some REAL?).  UDT layouts can be customized EXACTLY for this purpose.

Note that structures MUST be DWORD aligned, but your remote device data is 7 WORDs (3.5 DWORDs), so your UDT will a PAD with an 8th word.  But that is OK - we can make it work.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Outstanding Update for Do-more!
« Reply #28 on: September 22, 2017, 03:07:42 PM »
...we may need to revisit that and make structures valid a source or target everywhere it makes sense.

Yes please!  :)

This is where it can get tricky.

If you understand C unions, you could do it memory based using MEMCOPY if you laid out your UDT EXACTLY like the Holding Register layout.

If you have never done C unions or what that means or looks like, then just use the new COPY instruction.  Casting is allowed.


Well I don't know C but I did figure it out already. You provided enough tools in the configuration, along with that tip and the error messages in MEMCOPY. I did have to COPY the N0 to N7 before the MEMCOPY so N7 would get broken out into the bits in the structure for the last 16 items. That was just a lucky layout on my end.

But I am not sure how well this will work for me in the real world. My test was just a subset of what I would like to have (words to be written via MWX as well as MRX reads in the same structure.) Add in the tendency for manufacturers to randomly move things around and this could get ugly in the real world.

Seriously, for this one product, ModbusRTU requires I add one to the offset and ModbusTCP requires I don't. And some things get moved around product to product or even between revisions of the firmware.

Is there a way to populate a Data View with all of a structure's members without having to pick them one at a time?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Outstanding Update for Do-more!
« Reply #29 on: September 22, 2017, 03:12:07 PM »
Is there a way to populate a Data View with all of a structure's members without having to pick them one at a time?

If you want them on their own line, enter the first field of the desired struct then press Shift-Control-Enter.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO