CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Wed Nov 22, 2017 10:25 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Aug 24, 2016 6:57 am 
Offline

Joined: Wed Dec 30, 2015 5:35 am
Posts: 3
Hello!
I'm using PLCHandler library.
Having simple IEC project with an array of strings
Code:
PROGRAM PLC_PRG
VAR
_arr_string : ARRAY[1..10] OF STRING(10) := ['aaa','bbb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj'];
END_VAR

I got the list of variables by calling GetAllItems().
PlcSymbolDesc for this variable contains
Code:
'Application.PLC_PRG._arr_string', typeID(131085)-'ARRAY [1..10] OF STRING'-'ARRAY : DATATYPE_STRING', size '110', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[10]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[1]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[2]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[3]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[4]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[5]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[6]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[7]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[8]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'
'Application.PLC_PRG._arr_string[9]', typeID(13)-'STRING'-'SIMPLE : DATATYPE_STRING', size '11', access 'b', RefId '0', offset '0'

Reading the data by SyncReadVarsFromPlc() brings me the following (hex trace):
- for single array element 'Application.PLC_PRG._arr_string[1]' - (length 11) - a a a 00 00 00 00 00 00 00 00 hex
- for array 'Application.PLC_PRG._arr_string' - (length 110) - a a a 00 00 00 00 00 00 00 00 b b b 00 00 00 00 00 00 00 00 c c c 00 00 00 00 00 00 00 00 d d d 00 00 00 00 00 00 00 00 e e e 00 00 00 00 00 00 00 00 f f f 00 00 00 00 00 00 00 00 g g g 00 00 00 00 00 00 00 00 h h h 00 00 00 00 00 00 00 00 i i i 00 00 00 00 00 00 00 00 j j j 00 00 00 00 00 00 00 00 hex

The question is - how can I parse the data block (length 110 bytes) which I received for whole array variable _arr_string? There is no info about length of each array element in PlcSymbolDesc for _arr_string.The length of each element can only be seen in PlcSymbolDesc for _arr_string[XXX] - 11 bytes. But symbol descriptions for the array and its elements are only linked by the symbol names - I think it's not the right way to get array element size by comparing the names of PlcSymbolDesc structures. The same with the symbol type name of the variable ('ARRAY [1..10] OF STRING') in the field PlcSymbolDesc.pszType. Is there any other _more_simple_ way to handle this?

BR, Eugene


Top
   
PostPosted: Fri Jan 27, 2017 8:21 pm 
Offline
Frequent User
Frequent User

Joined: Thu Jun 14, 2007 9:49 am
Posts: 985
you can always ask the LEN of any string.

_________________
shooter@home.nl
computer shooter
paul deelen
jacob van wassenaerstraat 29
NL 5224 GG 's-Hertogenbosch
skype shooter paul.deelen
phone +31736139136


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited