Skip to content

Commit

Permalink
Added register description enumeration.
Browse files Browse the repository at this point in the history
  • Loading branch information
rombrew committed Sep 14, 2024
1 parent 1522380 commit 79e35b6
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 123 deletions.
2 changes: 1 addition & 1 deletion pgui/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ void config_default(struct config_phobia *fe)

strcpy(fe->fuzzy, "setpoint");

fe->regfile = 490;
fe->regfile = 500;
}

21 changes: 21 additions & 0 deletions pgui/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ link_reg_postproc(struct link_pmc *lp, struct link_reg *reg)
if (lk_stod(&dval, reg->val) != NULL) {

reg->mode |= LINK_REG_TYPE_FLOAT;

reg->fval = (float) dval;

if (reg->started != 0) {
Expand Down Expand Up @@ -301,6 +302,8 @@ link_reg_postproc(struct link_pmc *lp, struct link_reg *reg)
&& reg->lval >= 0
&& reg->lval < LINK_COMBO_MAX) {

reg->mode |= LINK_REG_TYPE_ENUM;

if (reg->combo[reg->lval] == NULL) {

reg->combo[reg->lval] = link_mballoc(lp, LINK_NAME_MAX);
Expand Down Expand Up @@ -882,6 +885,7 @@ void link_push(struct link_pmc *lp)
if (serial_fputs(priv->fd, priv->lbuf) == SERIAL_OK) {

reg->queued = lp->clock;

lp->locked = lp->clock + lp->quantum;
}

Expand All @@ -894,6 +898,23 @@ void link_push(struct link_pmc *lp)
if (serial_fputs(priv->fd, priv->lbuf) == SERIAL_OK) {

reg->queued = lp->clock;

lp->locked = lp->clock + lp->quantum;
}

break;
}

if ( (reg->mode & LINK_REG_TYPE_ENUM) != 0
&& reg->enumerated == 0) {

sprintf(priv->lbuf, "enum_reg %i" LINK_EOL, reg_ID);

if (serial_fputs(priv->fd, priv->lbuf) == SERIAL_OK) {

reg->queued = lp->clock;
reg->enumerated = lp->clock;

lp->locked = lp->clock + lp->quantum;
}

Expand Down
3 changes: 3 additions & 0 deletions pgui/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ enum {

LINK_REG_TYPE_INT = (1UL << 8),
LINK_REG_TYPE_FLOAT = (1UL << 9),

LINK_REG_TYPE_ENUM = (1UL << 10)
};

enum {
Expand All @@ -43,6 +45,7 @@ struct link_reg {
int modified;
int fetched;
int queued;
int enumerated;

char sym[LINK_NAME_MAX];
char val[LINK_NAME_MAX];
Expand Down
Loading

0 comments on commit 79e35b6

Please sign in to comment.