scpi-parser icon indicating copy to clipboard operation
scpi-parser copied to clipboard

SCPI-99:9.4 Implement "fan-out" register support

Open sandsbl opened this issue 9 years ago • 5 comments

As part of our SCPI instrument development, we have come upon a need to include "fan-out" registers for certain bits in QUEStionable and OPERation status registers as defined in section 9.4 of the SCPI-99 spec. I propose adding this as a feature-request for the scpi-parser library. I am willing to work on this feature, as we are in the most immediate need for it, but I would like to get some feedback on my thoughts on how to proceed. I am thinking to take the following steps to implement this feature:

  • Add the member scpi_fanout_reg_t * fanout_registers; to _scpi_t context structure
    This would be a pointer to an array of device-specific fanout registers that would need to be defined in scpi_context.c. Each fanout register could be defined in types.h as

    struct  _scpi_fanout_reg_t {
    scpi_reg_val_t val;
    scpi_reg_name_t parent_reg;
    scpi_reg_val_t parent_bit;
    int32_t parent_fanout_reg;
    scpi_bool_t is_nested;
    };
    typedef struct _scpi_fanout_reg_t scpi_fanout_reg_t;
    

    This specifies the register value val, its standard parent register parent_reg (one of OPER or QUES), and the summary bit to which this fanout is logically summed parent_bit. Since the standard specifies the potential for multiple layers of nesting fanout registers, the last two members would handle this case. If is_nested is TRUE, then the fanout register at index parent_fanout_reg is updated as a summary bit.

  • Extend SCPI_RegXXX functions in IEEE488.c
    The following functions would need to have their "fanout" analogs added to handle scpi_fanout_reg_t registers:
    SCPI_RegSet -> SCPI_RegSetFanout SCPI_RegSetBits -> SCPI_RegSetFanoutBits SCPI_RegClearBits -> SCPI_RegClearFanoutBits SCPI_RegGetFanout -> SCPI_RegGetFanout regUpdate -> regUpdateFromFanout
    Additionally, there is a need for a new function SCPI_RegCheckBits that would check if a particular register bit from OPER or QUES is a summary bit. This would presumably be used e.g. when a *CLS command is issued or when a summary bit is read in order to clear its associated fanout registers.

  • Update SCPI_CoreCLS in IEEE488.c
    Clear fanout registers.

  • Update QUEStionable and OPERation status callbacks as well as SCPI_StatusPreset in minimal.c
    Handle fanout registers.

Please advise with suggestions or issues I may have forgot.

sandsbl avatar Sep 26 '16 03:09 sandsbl

I thing, there was no discussion about this in the past.

Can you propose a pull request with this functionality?

j123b567 avatar Sep 26 '16 08:09 j123b567

Yes, I can start working on it.

sandsbl avatar Sep 27 '16 03:09 sandsbl

@sandsbl Have you implemented this feature?

PolyPik avatar Apr 15 '20 21:04 PolyPik

No, I haven't had a chance to, sorry. Moved to another project.

On Wed, Apr 15, 2020 at 5:51 PM PolyPik [email protected] wrote:

@sandsbl https://github.com/sandsbl Have you implemented this feature?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/j123b567/scpi-parser/issues/81#issuecomment-614298393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6RJT7TRBDYHLGQPOAFPLTRMYT7BANCNFSM4CQYN7BQ .

sandsbl avatar Apr 16 '20 00:04 sandsbl

Well you did a pretty good job of describing what needs to be done. I think I can implement the changes on my own.

PolyPik avatar Apr 16 '20 00:04 PolyPik

Should be fixed by #114

j123b567 avatar Jan 16 '23 10:01 j123b567

@PolyPik , do you happen to have an example or test case that uses device specific registers? I'm trying to use the functionality, to flag that a digital input has changed level. I am investigating how to use the extension by trying to use it in my project. An example or reference project would be helpful.

jancumps avatar Sep 13 '23 19:09 jancumps

I figured it out. I managed to build a set of instrument specific registers,
make them fan out to a bit of the OPERATION STATUS register, etc...
Took me a good week to fully make it happen :) - partly because I wanted a good integration with TinyUSB's TMCUSB with service requests.

documentation link.

jancumps avatar Sep 22 '23 14:09 jancumps