News:

  • October 18, 2026, 07:49:43 PM

Login with username, password and session length

Author Topic: Bug? CALL and Heap (UDT) for Input/Output  (Read 6511 times)

Mike@Forshock

  • Sr. Member
  • ****
  • Posts: 59
Bug? CALL and Heap (UDT) for Input/Output
« on: January 25, 2021, 11:26:10 AM »
Have an issue that I hadnt noticed before with the CALL function and Heap items (Read: NOT Data-blocks)

Create a UDT (OPT_BatteryMon) and create two different Heap Items referencing the UDT. (eg. OPT_SolarBattery, BatteryMon_TMPST)
In the CALL function set the Optional inputs: Input Value (OPT_SolarBattery), Into Subroutine (BatteryMon_TMPST)
Shows the Red, config/function error circle and gives the following:
Code: [Select]
Found 1 error editing CALL.
...
      Parameter Description
===== ========= ====================
[  4]    CALL      Input Parameter #1 passing 1 OPT_BatteryMon structs from Input-Value OPT_SolarBattery Into BatteryMon_TMPST invalid because: When Source is a Heap element, Range must be 1 Source Element
Error above uses the heap items we have in out program:
OPT_BatteryMon is the UDT used for both Heap Items
OPT_SolarBattery is the item that refers to a specific item to monitor (in this case it is a solar site the PLC is connected on/in/to, and is an optional feature within our program)
BatteryMon_TMPST is a temporary item that we copy to/from to process within a shared subroutine call to process all of the battery monitoring (Charge/Discharge Rates, Ah, Runtimes, etc.)

If we change the OPT_SolarBattery heap item to a data-block and reference as "0" the call will work correctly.
If we use the explicit MEMCOPY function before and after the CALL (with no input/output) it works correctly.

Thanks for all the work you guys do
« Last Edit: January 25, 2021, 11:30:25 AM by Mike@Forshock »

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3850
    • Host Engineering
Re: Bug? CALL and Heap (UDT) for Input/Output
« Reply #1 on: January 25, 2021, 04:48:13 PM »
Yeah - the COPY/CALL utilize MEMCOPY behind the scenes.

When you have a DESTINATION in MEMCOPY that is a heap item, it was making sure that the MEMCOPY "count" specified the count as NUMBER OF DESTINATION elements.

However, the COPY/CALL looked at the SOURCE to see if the SOURCE was HEAP, and it set the "behind the scenes" MEMCOPY "count" to be NUMBER OF SOURCE elements.

Hence, the low level MEMCOPY instruction complained.

So the issue is that if MEMCOPY is doing HEAP to HEAP, then allow the "count" parameter to be 1 SOURCE OR 1 DESTINATION (since they are both heap).

I tried it, and it seems to work (see attached screen shot).  I hope to get this in a new 2.8 update version of Designer due out soon.  Gotta test it some more (we don't like bugs any more than you do).

Mike@Forshock

  • Sr. Member
  • ****
  • Posts: 59
Re: Bug? CALL and Heap (UDT) for Input/Output
« Reply #2 on: January 25, 2021, 05:05:47 PM »
Copy that, appreciate the response and look forward to more features.

Mike