Skip to content

Conversation

@guirodrigueslima
Copy link
Contributor

@guirodrigueslima guirodrigueslima commented Jul 2, 2025

Hi there, Leandro!

At LNLS, we have a new project under development using deltatau with Pmac IOC. We noticed a problem when instantiating a dynamic variable with the .substitutions file (pmacVariableWrite.template).

To instantiate multiple variables, the pmacCommandStore::buildCommandString function generates an addition of 40 variables in a 1024 char. However, the SSHDriver::write function needs to perform an ECHO and the static buffer size is 512 char. If the buffer size passed to SSHDriver::write is greater than 512 char, an error is accused in the function (no match), generating a false error of connection loss and reconnection with the deltatau controller.

To solve the problem, I changed the buffer size to 2048 char, following the same pattern as the rest of the sshDriver.cpp code.

I am attaching the replacements file for you to reproduce the same problem with the current version.

mgn-b-pb08.substitutions.txt

To instantiate multiple variables, the pmacCommandStore::buildCommandString
function generates an addition of 40 variables in a 1024 char. However, the
SSHDriver::write function needs to perform an ECHO and the static buffer size
is 512 char. If the buffer size passed to SSHDriver::write is greater than
512 char, an error is generated in the function (no match), generating a false
error of connection loss and reconnection with the deltatau controller.
To solve the problem, the buffer size was changed to 2048 char.
@guirodrigueslima
Copy link
Contributor Author

guirodrigueslima commented Jul 3, 2025

I checked that pull request #108 is doing something similar on line 483, but it uses PPMAC_DOUBLE_MAX_LENGTH and changes some things. Anyway, you can try running the substitutions file to reproduce the problem.

@LeandroMartinsdS
Copy link
Contributor

Hi @guirodrigueslima,

Sorry for the long silence.

I haven't had the chance of testing your changes yet, but they look reasonable.
As you mentioned, the #108 already covers this, but I'm not fully convinced what the maximum buffer size should be.

Your approach is more conservative, so I'm happy to merge your changes, while testing thoroughly what are the limitations.

I expect to be merging early next week

@LeandroMartinsdS
Copy link
Contributor

LeandroMartinsdS commented Oct 1, 2025

I finally got back to this.

I'll go ahead and merge this PR, as it was already part of the roadmap.

However, I’d like to document a few important points for future reference:

  • The issue we observed isn’t related to the number of variables, but rather to the string length of each VAR.
    Even with buff[512], everything works as expected if we rename the variables to Mx (where x ranges from 0 to 16383), making sure to avoid conflicts with existing ones.

  • At the controller level in the PMAC, we can use M pointers to reference more descriptive variable names, such as
    M1000->SM_Z_CMD_INIT.

  • Keep in mind that pmacVariableWrite.template defines RBV records to be polled in the medium loop.
    If some variables are meant only for monitoring (not control), consider using pmacVariableRead.template instead, which allows specifying the polling loop for each variable.

  • It’s also a good idea to set DTYP and TYPE appropriately based on the intended use of each variable.

@LeandroMartinsdS LeandroMartinsdS merged commit 3401b14 into DiamondLightSource:dls-master Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants