Documentation
¶
Overview ¶
Package go-dcdcusb interfaces with the DCDCUSB power supply from mini-box (https://www.mini-box.com/DCDC-USB) via USB port and allows you to retrive the status of the power supply
it depends upon GoUSB which in turn depends upon the libusb C library, thus CGO is required for this module
Please see the GoUSB pages for hints on compiling for platforms other than linux ¶
Building ¶
Compile with the tag nogousb to disable compiling with USB Support. Then the only option available is a Simulator Mode that replays a previously captured session.
Example ¶
dc := dcdcusb.DcDcUSB{}
logsink := log.New(os.Stdout, "", 0)
log := stdr.New(logsink)
dc.Init(log, false)
if ok, err := dc.Scan(); !ok {
log.Error(err, "Scan Failed")
return
}
defer dc.Close()
for i := 0; i < 100; i++ {
ctx, cancel := context.WithTimeout(context.Background(), (1 * time.Second))
dc.GetAllParam(ctx)
cancel()
time.Sleep(1 * time.Second)
}
dc.Close()
Index ¶
- type DcDcUSB
- func (dc *DcDcUSB) Close()
- func (dc *DcDcUSB) GetAllParam(ctx context.Context) (Params, error)
- func (dc *DcDcUSB) Init(log logr.Logger, simulation bool)
- func (dc *DcDcUSB) IsConnected() bool
- func (dc *DcDcUSB) Scan() (bool, error)
- func (dc *DcDcUSB) SetCapture(enabled bool)
- func (dc *DcDcUSB) SetUSBDebug(level int)
- type DcdcModet
- type DcdcStatet
- type Params
- type Peripheralst
- type TimerConfigt
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DcDcUSB ¶
type DcDcUSB struct {
// contains filtered or unexported fields
}
Main Structure for the DCDCUSB Communications
func (*DcDcUSB) GetAllParam ¶
Gets All current Params from the DCDCUSB power Supply. Set a Timeout/Deadline Context to cancel slow calls
func (*DcDcUSB) Init ¶
Initialize the DCDCUSB Communications. Should be first function called before any other methods are called Pass a logr.Logger as the logger for this package and set simulation to true if you wish to reply a Captured Session instead of live data.
func (*DcDcUSB) IsConnected ¶ added in v0.0.2
Returns if we are connected to the Power Supply
func (*DcDcUSB) Scan ¶
Scan for a DCDCUSB connection, returns true if found, or false (and optional error) if there was a failure setting up communications with it.
func (*DcDcUSB) SetCapture ¶ added in v0.0.2
Capture Data from the Power Supply and save it to dcdcusb.txt for replay via the simulator later
func (*DcDcUSB) SetUSBDebug ¶
Set the debug level for the GoUSB Library
type DcdcStatet ¶
type DcdcStatet int
const ( StateOk DcdcStatet = 7 StateIgnOff DcdcStatet = 8 StateHardOffCountdown DcdcStatet = 16 StateUnknown DcdcStatet = 255 )
func (DcdcStatet) String ¶
func (i DcdcStatet) String() string
type Params ¶
type Params struct {
// What the Vout Setting is configured for
VoutSet float32 `json:"vout_set"`
// What Voltage the Config Jumpers are set for VOut
VoutConfig float32 `json:"vout_config"`
// The Input Voltage
Vin float32 `json:"vin"`
// The Ignition Voltage
Vign float32 `json:"vign"`
// What the Actual VOut Voltage is
VoutActual float32 `json:"vout_actual"`
// Status of Various Peripherals
Peripherals Peripheralst `json:"peripherals"`
// ?? (Not Output Enabled?)
Output bool `json:"output"`
// ??
AuxVIn bool `json:"aux_v_in"`
// Firmware Version?
Version string `json:"version"`
// State of the Power Supply
State DcdcStatet `json:"state"`
// Config Registers (unknown)
CfgRegisters byte `json:"cfg_registers"`
// Voltage Flags (Unknown)
VoltFlags byte `json:"volt_flags"`
// Timer Flags (Unknown)
TimerFlags byte `json:"timer_flags"`
// The configured countdown times for the Timer upon Power Loss
TimerConfig TimerConfigt `json:"timer_config"`
// Current Power Loss Debounce Timer
TimerWait time.Duration `json:"timer_wait"`
// Current VOut Countdown Timer
TimerVOut time.Duration `json:"timer_v_out"`
// Current VAux Countdown timer
TimerVAux time.Duration `json:"timer_v_aux"`
// Current Power Switch Toggle Count Down Timer
TimerPRWSW time.Duration `json:"timer_prwsw"`
// Current Soft Off Countdown Timer
TimerSoftOff time.Duration `json:"timer_soft_off"`
// Current Hard Off Countdown Timer
TimerHardOff time.Duration `json:"timer_hard_off"`
// Current Script Position
ScriptPointer byte `json:"script_pointer"`
// Current Operating Mode
Mode DcdcModet `json:"mode"`
}
Overall Status of the DCDCUSB Power Supply
type Peripheralst ¶
type Peripheralst struct {
// ??
OutSwVin bool `json:"out_sw_vin"`
// ??
OutPsw bool `json:"out_psw"`
// ??
OutStartOutput bool `json:"out_start_output"`
// Status of the Onboard Led
OutLed bool `json:"out_led"`
// If the VOut is within range.
InVoutGood bool `json:"in_vout_good"`
}
Status of Various Peripherals
type TimerConfigt ¶
type TimerConfigt struct {
// After Ignition Lost, this the time waiting till we toggle the Power Switch I/F
OffDelay time.Duration `json:"off_delay"`
// After the Power Switch I/F is toggled, this is the delay before we cut power
HardOff time.Duration `json:"hard_off"`
}
Represents the Settings for Off and Hardoff Delays when power is lost