FlexSEA Wiki


User Tools

Site Tools


User R/W variables

The User R/W (read/write) variables are internal variables that can be used freely by the user. They are typically used during the development process before a custom command is written, or for quick experiments. Using Actuator Package scripts, it is possible to write and read these values from the device. These functions are found in the commwrapper file of the repo.

Writing values can be done by calling writeUser. It provides the following interface:

void writeUser(int devId, int index, int val)

Sending the command to read the buffer on the device uses the readUser command:

void readUser(int devId)

Once that command has been sent, you must run the following command to fetch the received values.

int* getUserRead()

A demo script can be found in the Python scripts in the userRW.py file.

Testing the script

To test the script, loop back the user R/W write buffer values into the read buffer. To do this, you must modify the code running on your act pack's manage. Add the following line into mainFSM4() in main_fsm.c:

for(int i =0; i < 4; i++){user_data_1.r[i] = user_data_1.w[i];}

If you would like to stream the read and write buffers, you can also add it to the genVars. Adding the following lines to mainFSMx() will achieve that:

for(int i = 0; i < 4; i++){rigid1.mn.genVar[i] = user_data_1.w[i];}
for(int i = 4; i < 8; i++){rigid1.mn.genVar[i] = user_data_1.r[i-4];}

Note: Be sure that there are no other uses of the genVars.

Implementation tips & Known limitations

  1. The scripts rely on the ActPack command, a bidirectional command that writes to and reads from the device every cycle. It is a very efficient way to exchange data and avoid bus collisions. User R/W can be used sporadically, but it should never be called at tens or hundreds of hurts. Doing so will create problems with the ActPack command. If you need to regularly update or receive a value, consider replacing ActPack with a custom command that includes your user-specific variables.
  2. The r and w variables are not the same! Writing to w[0] will not give you back the value in r[0].
userrw.txt · Last modified: 2019/03/19 16:14 by jfduval