Jump to content
OMRON Forums

Pointer array declarations in Script


DaveBarnett

Recommended Posts

I've declared some pointer arrays in script  like this:

Capt_Ptrs.PNG.44eb77ff11b756a4d653f500e049ad95.PNG

It compiles...and works as expected...but, surely there must be a more compact/elegant way to get the same result?  And, why is the editor complaining with the red squiggles ??

The SRM has the example:

ptr FirstIoCardReg(8)->u.io:$A00000.8.8+   
But, I couldn't get that kind of syntax to work.....   Am I missing something??

 

Link to comment
Share on other sites

Hi @DaveBarnett,

What I know about that kind of syntax is this equivalence
 

Sys.Udata[0] // u.user:0
Sys.Udata[1] // u.user:4
Sys.Udata[2] // u.user:8
Sys.Udata[3] // u.user:c

The same applies for Idata, Fdata and Ddata (respecting the data structure organization)

The u.user structure follows something like this
u.user:{Beginning of that memory}:{Number of bits shifted}:{Number of bits}.
Haven't been able to find the purpose of the "+" on your example, maybe is something specific for the BufIO.

I'm also interested if there is anyway more elegant of handling those structures.


 

image.png

Link to comment
Share on other sites

For the Sys.Udata[x] stucture this seems to work
 

ptr pUdata(8)->u.user:$24.0.32+ 
  	// OR u.user:36.0.32+
  	// OR u.user:36+ ,if not using offset or setting the maximum size

 

pUdata(0),8
M8192=0
M8193=0
M8194=0
M8195=0
M8196=0
M8197=0
M8198=0
M8199=0
M8192,8->
M8192->u.user:$24
M8193->u.user:$28
M8194->u.user:$2c
M8195->u.user:$30
M8196->u.user:$34
M8197->u.user:$38
M8198->u.user:$3c
M8199->u.user:$40

Sys.Udata[9]=9,10,11,12,13,14,15,16
pUdata(0),8
M8192=9
M8193=10
M8194=11
M8195=12
M8196=13
M8197=14
M8198=15
M8199=16

 

Edited by leandro.martins
  • Thanks 1
Link to comment
Share on other sites

  • 4 weeks later...

If I want to declare an array of bytes in contiguous memory area, what should the the syntax like?

 

Tried  this but I get a "sparse" array of bytes and this makes it impossible to reconstruct words and double words from a byte-only process image

i get:

appoIn(0),10->u.user:100.0.8+
appoIn(0),10->
M8192->u.user:$64.0.8
M8193->u.user:$68.0.8
M8194->u.user:$6c.0.8
M8195->u.user:$70.0.8
M8196->u.user:$74.0.8
M8197->u.user:$78.0.8
M8198->u.user:$7c.0.8
M8199->u.user:$80.0.8
M8200->u.user:$84.0.8
M8201->u.user:$88.0.8

I would like to have 

m8192->u.user:$64.0.8

m8192->u.user:$64.8.8 

and so on

 

Link to comment
Share on other sites

The “+” syntax with “ptr” declarations does not function at the “byte” level, only with word level definitions. You would need to manually generate M-variable definitions and “#define” (function like macro definitions) names for your “byte” array. In this case do not use M-variable numbers in the “auto declared range” (MVARSTART and above). 

#define    myArray(i) P[(800+i)]  
m800->u.user:$64.0.8
m801->u.user:$64.8.8
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...