#ifndef __XFR_H__
#define __XFR_H__

typedef struct {
  int    port; // serial port fd
  double VOut; // Volts output
  double VSet; // Voltage set-point
  double IOut; // Amps output
  double ISet; // Amps set-point
  int    OutEnabled; // 1-enabled. 0-disabled
  int    err; // error register
  int    asts; // asts register
  int    sts; // sts status register
  int    fault; // fault register
} XFRState_t;

// Programming Commands
int xfrInit (int xfr_port); // CLR command
int xfrEnableOutput (int xfr_port); // OUT 1 command
int xfrDisableOutput (int xfr_port); // OUT 0 command
int xfrOverVoltSet (int xfr_port, double ovp); // OVSET command
int xfrReset (int xfr_port); // RST command
int xfrTrigger (int xfr_port); // TRG command
int xfrVMax (int xfr_port, double Vmax); // VMAX command
int xfrSetVolts (int xfr_port, double volts); // VSET command
int xfrIMax (int xfr_port, double current); // IMAX command
int xfrSetCurrent (int xfr_port, double current); // ISET command

// Query Commands
int xfrGetIOut (int xfr_port, double *Iout); // IOUT? command
int xfrGetISet (int xfr_port, double *Iset); // ISET? command
int xfrGetOut (int xfr_port, int *status); // OUT? command
int xfrGetVOut (int xfr_port, double *volts); // VOUT? command
int xfrGetVSet (int xfr_port, double *Vset); // VSET? command
int xfrGetErr (int xfr_port, int *err); // ERR? command
 // ASTS?, STS?, and FAULT? commands
int xfrGetStatus (int xfr_port, int *astatus, int *status, int *fault);

#endif /* __XFR_H__ */

