Skip to content

Document long-string options: FTVL=STRING waveform vs lsi/lso (40-char MAX_STRING_SIZE) #49

Description

@kgofron

Context

While integrating ioc-tasplot (PyDevice IOC for TAS scan plotting), we hit EPICS’s 40-character string limit when exposing file paths (~90 characters) through PVs.

Investigation showed this is expected EPICS behavior, but the right PyDevice record choice is not obvious from the README alone.

Observation: waveform with FTVL=STRING

PyDevice’s waveform support for FTVL=STRING caps each element at MAX_STRING_SIZE (40), matching EPICS base (epicsTypes.h):

// pydev_waveform.cpp
std::string cval = sval.substr(0, MAX_STRING_SIZE - 1);

That is correct for EPICS string waveforms (an array of fixed 40-char slots), but it is not suitable for a single long pathname.

Question: Could the README explicitly state that FTVL=STRING waveforms are limited to 40 characters per element, and are intended for arrays of short strings, not single long text fields?

What worked: lsi / lso (EPICS 3.15+)

Switching path PVs to lsi/lso with SIZV=255 and enabling pydev315.dbd worked well. PyDevice’s pydev_lsi.cpp / pydev_lso.cpp correctly use rec->sizv for storage.

Remaining friction was on the client side, not PyDevice:

  • Plain caget TAS:Plot:FilePath_RBV → truncated at 40 chars (DBR_STRING)
  • caget -S TAS:Plot:FilePath_RBV.$ → full path

See EPICS field modifiers ($) and EPICS tech-talk on Phoebus long strings.

Alternative: waveform with FTVL=CHAR

Historically, long text used a CHAR waveform as a byte blob (NORD = length). PyDevice appears to support this, but from Python it means returning byte lists, and Phoebus needs Format=String plus the .$ modifier. For text fields, lsi/lso seem simpler.

Question: Is there a recommended PyDevice pattern for “single long string” PVs today? Our conclusion: prefer lsi/lso over CHAR waveforms for path/error text — please confirm or correct.

Suggested documentation additions

  1. Record choice table

    Goal Record type PyDevice notes
    Single long string (path, error) lsi / lso Requires pydev315.dbd; set SIZV; clients use .$
    Array of short strings waveform FTVL=STRING 40 chars per element (MAX_STRING_SIZE)
    Legacy long text blob waveform FTVL=CHAR NORD = length; less ergonomic from Python
    Numeric plot data waveform FTVL=DOUBLE Works well
  2. Note that dbpf / iocsh on lso strings may truncate at 40 chars; use template field(VAL,...) at load time, Python pydev() before iocInit, or CA clients with the .$ modifier.

  3. Optional: mention that input lsi/lso readbacks may need field(SCAN, ...) (or I/O Intr) so CA clients see updates without an explicit process trigger.

Environment

  • EPICS Base R7.0.7
  • PyDevice (vendored in ioc-tasplot src/)
  • Python 3.10
  • Clients: caget/caput, Phoebus Display

Not asking for

A change to make FTVL=STRING hold arbitrary-length strings — that would duplicate lsi/lso and diverge from EPICS record semantics. Documentation and a clear “use lsi/lso for long text” recommendation would be enough.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions