Store PLCnext CommunityPLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. Dzmitry Ivaniuk
  2. PLCnext Technology & PLCnext Controls
  3. Tuesday, 11 June 2019

There are some limitations with defining port variables. Examples of incorrect code for the plcncli but correct for C++:

 const int size = 10;
//#port
//#attributes(Output|Retain)
uint8 NVRAM1[ size ] = {0}; //Variable for size
 //#port
//#attributes(Output|Retain)
uint8 NVRAM2[ 10 * 1024 ] = {0}; //Some mathematical operations inside brackets
 void start()
{
running = 1;
} //No semicolon after bracket

//#port
//#attributes(Output|Retain)
uint8 NVRAM3[ 49000 ] = {0};

The plcncli just ignore this lines.

This one is correct:

 //#port
//#attributes(Output|Retain)
uint8 NVRAM[ 49000 ] = {0};

But it generate a warning message:

 Scanning dependencies of target PtusaPLCnextEngineer
[cmake]: [ 1%] Building CXX object CMakeFiles/PtusaPLCnextEngineer.dir/intermediate/code/PtusaMainCmpntProgramProvider.cpp.o
[cmake]: [ 2%] Building CXX object CMakeFiles/PtusaPLCnextEngineer.dir/intermediate/code/PtusaPLCnextEngineerLibrary.meta.cpp.o
[cmake]: In file included from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/strings.h:23:0,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/string.h:431,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/boost/range/detail/implementation_help.hpp:18,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/boost/range/end.hpp:24,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/boost/range/functions.hpp:19,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/boost/range/iterator_range_core.hpp:38,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/boost/algorithm/string/replace.hpp:16,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/plcnext/Arp/System/Core/BasicString.hxx:12,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/plcnext/Arp/System/Core/TypeSystem.h:8,
[cmake]: from /opt/pxc/sdk/AXCF2152/2019.3/sysroots/cortexa9t2hf-neon-pxc-linux-gnueabi/usr/include/plcnext/Arp/System/Core/Arp.h:19,
[cmake]: from /home/id/ptusa_git/PAC_control_projects/main_control_prg/eclipse/projects/PLCnext-linux-PLCnextEngineer/intermediate/code/PtusaPLCnextEngineerLibrary.meta.cpp:1:
[cmake]: /home/id/ptusa_git/PAC_control_projects/main_control_prg/eclipse/projects/PLCnext-linux-PLCnextEngineer/intermediate/code/PtusaPLCnextEngineerLibrary.meta.cpp: In member function ‘void PtusaPLCnextEngineer::PtusaPLCnextEngineerLibrary::InitializeTypeDomain()’:
[cmake]: /home/id/ptusa_git/PAC_control_projects/main_control_prg/eclipse/projects/PLCnext-linux-PLCnextEngineer/intermediate/code/PtusaPLCnextEngineerLibrary.meta.cpp:21:45: warning: offsetof within non-standard-layout type ‘PtusaPLCnextEngineer::PtusaMainPrg’ is undefined [-Winvalid-offsetof]
[cmake]: { "NVRAM", offsetof(::PtusaPLCnextEngineer::PtusaMainPrg, NVRAM), DataType::UInt8 | DataType::Array, "", sizeof(uint8), alignof(uint8), { 49000 }, StandardAttribute::Output | StandardAttribute::Retain },
[cmake]: ^
[cmake]: [ 3%] Building CXX object CMakeFiles/PtusaPLCnextEngineer.dir/src/PtusaMainPrg.cpp.o

 

Also, from this message

 axcf2152 user.err [29457]: root ERROR - Retain Memory Size: 49208, maximum is 49140

user retain memory available  size is 49140?

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Dzmitry,

The observations with Port variable definitions can be explained by the way the plcncli is used to build an Eclipse project. The Eclipse build process calls the plcncli commands "generate code" and "generate config", which generates (repsectively) intermediate C++ code and XML configuration data. It does this by parsing the program and component header files, looking for port definitions. The current plcncli parser isn't anywhere near as clever as the C++ compiler, which explains why only the simplest port definitions are currently supported.

The compiler warnings on a valid port definition are a known issue with the current version of the plcncli.

And yes, the available Retain memory really is that size:

11 06 2019 17 26 02

 

 

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.