Mehdi
Mehdi

Reputation: 113

How to define an array in VxWorks Shell?

How can I define an array in VxWorks shell?
For example if I want to have the following:

myArray[3] = {1,2,3};

Upvotes: 3

Views: 2230

Answers (1)

mjs
mjs

Reputation: 3005

I am not sure you can, directly. You may be able to allocate some memory using eg malloc though, and then set the memory according to the values you want - something like the below should do

//Allocate the array
-> myArray = malloc( 3 )   
// use the m Command to edit the memory
-> m &myArray 
// do this for each element you want to set
-> 0x12ff3120 1
-> 0x12ff3121 2
// Check the memory
d &myArray
-> 0x12ff3120:             0001 0002 0003 0000

This works assuming you want an array of char sized elements. For other sizes, modifiy the m command to edit in eg word sized blocks:

->m &myArray 4

Upvotes: 5

Related Questions