m4api
m4api is a Linux/Mac/?*BSD program for monitoring and configuring Mini-Box M4-ATX power supplies.
m4api replaces the Windows-only programs that are supplied with the PSU.
Last update: Jan. 30, 2010.
The Code
You can get a snapshot of the Git tree.
$ git clone git://ram.umd.edu/bits/m4api.git
Requirements
m4api requires libusb (version 0.1.x).
Examples -- CLI | API
# Monitor input and output voltage levels: $ ./m4 -diag loop -- 1262486581 VIN: 11.34 IGN: 11.23 33V: 3.33 5V: 5.06 12V: 12.18 TEMP: +28 -- 1262486582 VIN: 11.34 IGN: 11.34 ... # Display your PSU's configuration: $ ./m4 -config IGN_HIGH: 5.84 V IGN_LOW: 5.50 V IGN_DBC: 500 ms PSU_DELAY: 1 sec ... # Check or update specific variables: $ ./m4 -config VIN_MIN_ON 9.55 V $ ./m4 -config VIN_MIN_ON 10.0 $ ./m4 -config VIN_MIN_ON 9.99 V
Examples -- API | CLI
#include <stdio.h> #include "m4api.h" int main (int argc, char **argv) { float fval; int ival; /* m4api will handle conversion to 8- or 16-bit integer */ struct m4Diagnostics diag; struct usb_dev_handle *dev; dev = m4Init(); if (!dev) { perror("m4Init"); return -1; } /* Read in diagnostics */ if (m4GetDiag(dev, &diag)) return -1; printf("VIN = %0.2f\n", diag.vin); printf("V33 = %0.2f\n", diag.v33); /* Get and update a voltage level */ if (m4GetFloat(dev, M4_VIN_MIN_ON, &fval)) return -1; printf("VIN_MIN_ON was %0.2f", fval); fval = 10.0; if (m4SetFloat(dev, M4_VIN_MIN_ON, fval)) return -1; if (m4GetFloat(dev, M4_VIN_MIN_ON, &fval)) return -1; printf(", now %0.2f\n", fval); /* Update an integer */ if (m4GetInteger(dev, M4_IGN_DBC, &ival)) return -1; printf("IGN_DBC was %d", ival); ival += 10; if (m4SetInteger(dev, M4_IGN_DBC, ival)) return -1; if (m4GetInteger(dev, M4_IGN_DBC, &ival)) return -1; printf (", now %d\n", ival); return 0; }
Last modified
by ktossell on 01/30/2010 04:08:45 PM (2 years ago)
