Cleanups for thesis inclusion
This commit is contained in:
parent
150732ee3c
commit
75dfbb28b3
|
@ -25,6 +25,6 @@ calibrate: calibrate.o serial-util.o gpib.o zoom.o
|
||||||
dctest: LDFLAGS=-lpthread
|
dctest: LDFLAGS=-lpthread
|
||||||
dctest: dctest.o serial-util.o gpib.o zoom.o mt19937ar.o
|
dctest: dctest.o serial-util.o gpib.o zoom.o mt19937ar.o
|
||||||
|
|
||||||
dactest: dactest.o serial-util.o gpib.o zoom.o mt19937ar.o
|
dactest: dactest.o serial-util.o gpib.o zoom.o mt19937ar.o
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o read calibrate dctest dactest
|
rm -f *.o read calibrate dctest dactest
|
||||||
|
|
140
pc/calibrate.c
140
pc/calibrate.c
|
@ -21,7 +21,6 @@ void single_sweep(int zoom);
|
||||||
void calibrate(int zoom, int gpib);
|
void calibrate(int zoom, int gpib);
|
||||||
void sweep_ota(int zoom, int gpib, int ota_sweep_count);
|
void sweep_ota(int zoom, int gpib, int ota_sweep_count);
|
||||||
void hold_ota(int zoom, int gpib, int ota_cmd);
|
void hold_ota(int zoom, int gpib, int ota_cmd);
|
||||||
void hold_ota2(int zoom, int gpib, int ota_cmd);
|
|
||||||
|
|
||||||
#define info(x...) fprintf(stderr,x)
|
#define info(x...) fprintf(stderr,x)
|
||||||
|
|
||||||
|
@ -30,9 +29,10 @@ void handle_sig(int sig) { g_quit = 1; }
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// char *zoomdev=strdup("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A6007wag-if00-port0");
|
char *zoomdev=strdup("/dev/serial/by-id/usb-FTDI_FT232R_"
|
||||||
char *zoomdev=strdup("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A6007wc5-if00-port0");
|
"USB_UART_A6007wc5-if00-port0");
|
||||||
char *gpibdev=strdup("/dev/serial/by-id/usb-Prologix_Prologix_GPIB-USB_Controller_PXQQY20G-if00-port0");
|
char *gpibdev=strdup("/dev/serial/by-id/usb-Prologix_Prologix_"
|
||||||
|
"GPIB-USB_Controller_PXQQY20G-if00-port0");
|
||||||
int getopt_index;
|
int getopt_index;
|
||||||
int zoom, gpib;
|
int zoom, gpib;
|
||||||
int do_write = 0;
|
int do_write = 0;
|
||||||
|
@ -60,7 +60,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "Z:G:szw:o:l:h?",
|
while ((c = getopt_long(argc, argv, "Z:G:szw:o:l:h?",
|
||||||
long_opts, &getopt_index)) != -1) {
|
long_opts, &getopt_index)) != -1) {
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case 'Z':
|
case 'Z':
|
||||||
free(zoomdev);
|
free(zoomdev);
|
||||||
|
@ -108,18 +108,26 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help) {
|
if (help) {
|
||||||
fprintf(stderr, "Zoom Nilm Calibration Tool\n");
|
fprintf(stderr, "Zoom Nilm Calibration Tool\n");
|
||||||
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
||||||
fprintf(stderr, " -Z, --zoom-device %-14s zoom NILM serial port\n", "/dev/xxx" /*zoomdev*/);
|
fprintf(stderr, " -Z, --zoom-device %-14s "
|
||||||
fprintf(stderr, " -G, --gpib-device %-14s GPIB serial port\n", "/dev/xxx" /*gpibdev*/);
|
"zoom NILM serial port\n", "/dev/xxx" /*zoomdev*/);
|
||||||
fprintf(stderr, " -w, --write-dac %-14d write one value to the DAC constantly\n", write_cmd);
|
fprintf(stderr, " -G, --gpib-device %-14s "
|
||||||
fprintf(stderr, " -s, --single-sweep do a single sweep on the PIC\n");
|
"GPIB serial port\n", "/dev/xxx" /*gpibdev*/);
|
||||||
fprintf(stderr, " -z, --zero set DAC value such that ADC input is centered\n");
|
fprintf(stderr, " -w, --write-dac %-14d "
|
||||||
fprintf(stderr, " -o, --ota-sweep %-14d sweep OTA\n", ota_sweep_count);
|
"write one value to the DAC constantly\n", write_cmd);
|
||||||
fprintf(stderr, " -l, --ota-hold %-14d hold OTA constant\n", ota_cmd);
|
fprintf(stderr, " -s, --single-sweep "
|
||||||
fprintf(stderr, " -h, --help this help\n");
|
"do a single sweep on the PIC\n");
|
||||||
|
fprintf(stderr, " -z, --zero "
|
||||||
|
"set DAC value such that ADC input is centered\n");
|
||||||
|
fprintf(stderr, " -o, --ota-sweep %-14d "
|
||||||
|
"sweep OTA\n", ota_sweep_count);
|
||||||
|
fprintf(stderr, " -l, --ota-hold %-14d "
|
||||||
|
"hold OTA constant\n", ota_cmd);
|
||||||
|
fprintf(stderr, " -h, --help "
|
||||||
|
"this help\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +159,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
switch (ota_opt) {
|
switch (ota_opt) {
|
||||||
case 1:
|
case 1:
|
||||||
sweep_ota(zoom, gpib, ota_sweep_count);
|
sweep_ota(zoom, gpib, ota_sweep_count);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
hold_ota(zoom, gpib, ota_cmd);
|
hold_ota(zoom, gpib, ota_cmd);
|
||||||
|
@ -173,7 +181,7 @@ void calibrate(int zoom, int gpib)
|
||||||
int zero;
|
int zero;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
int dac[ZOOM_SWEEP_COUNT];
|
int dac[ZOOM_SWEEP_COUNT];
|
||||||
int adc[ZOOM_SWEEP_COUNT];
|
int adc[ZOOM_SWEEP_COUNT];
|
||||||
|
|
||||||
info("Initializing Zoom NILM\n");
|
info("Initializing Zoom NILM\n");
|
||||||
if (zoom_init(zoom) < 0) goto fail;
|
if (zoom_init(zoom) < 0) goto fail;
|
||||||
|
@ -198,7 +206,7 @@ void calibrate(int zoom, int gpib)
|
||||||
// for (idesired = -0.2; idesired <= 0.2 && !g_quit; idesired += 0.02) {
|
// for (idesired = -0.2; idesired <= 0.2 && !g_quit; idesired += 0.02) {
|
||||||
info("Zeroing\n");
|
info("Zeroing\n");
|
||||||
if (zoom_zero_start(zoom) < 0) goto fail;
|
if (zoom_zero_start(zoom) < 0) goto fail;
|
||||||
|
|
||||||
info("Setting current: %.8f\n", idesired);
|
info("Setting current: %.8f\n", idesired);
|
||||||
keithley_current(gpib, idesired);
|
keithley_current(gpib, idesired);
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
|
@ -229,7 +237,7 @@ fail:
|
||||||
info("Failed (code %d)\n", r);
|
info("Failed (code %d)\n", r);
|
||||||
goto safecleanup;
|
goto safecleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_dac(int zoom, int dac)
|
void write_dac(int zoom, int dac)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
@ -237,7 +245,7 @@ void write_dac(int zoom, int dac)
|
||||||
if (zoom_init(zoom) < 0)
|
if (zoom_init(zoom) < 0)
|
||||||
errx(1, "init failed");
|
errx(1, "init failed");
|
||||||
|
|
||||||
if (dac < 0)
|
if (dac < 0)
|
||||||
dac = 0;
|
dac = 0;
|
||||||
if (dac > 65535)
|
if (dac > 65535)
|
||||||
dac = 65535;
|
dac = 65535;
|
||||||
|
@ -256,7 +264,7 @@ void single_sweep(int zoom)
|
||||||
{
|
{
|
||||||
int i, r;
|
int i, r;
|
||||||
int dac[ZOOM_SWEEP_COUNT];
|
int dac[ZOOM_SWEEP_COUNT];
|
||||||
int adc[ZOOM_SWEEP_COUNT];
|
int adc[ZOOM_SWEEP_COUNT];
|
||||||
|
|
||||||
info("Initializing Zoom NILM\n");
|
info("Initializing Zoom NILM\n");
|
||||||
if (zoom_init_nozero(zoom) < 0) goto fail;
|
if (zoom_init_nozero(zoom) < 0) goto fail;
|
||||||
|
@ -311,7 +319,7 @@ void sweep_ota(int zoom, int gpib, int ota_sweep_count)
|
||||||
char zcmd[128];
|
char zcmd[128];
|
||||||
int mycmd = 0;
|
int mycmd = 0;
|
||||||
int cmd_inc = 4096;
|
int cmd_inc = 4096;
|
||||||
|
|
||||||
info("Initializing Zoom NILM\n");
|
info("Initializing Zoom NILM\n");
|
||||||
if (zoom_init(zoom) < 0) goto fail;
|
if (zoom_init(zoom) < 0) goto fail;
|
||||||
|
|
||||||
|
@ -346,14 +354,14 @@ void sweep_ota(int zoom, int gpib, int ota_sweep_count)
|
||||||
errx(1, "write failed");
|
errx(1, "write failed");
|
||||||
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
||||||
errx(1, "read timeout");
|
errx(1, "read timeout");
|
||||||
|
|
||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
iactual = keithley2002_read(gpib);
|
iactual = keithley2002_read(gpib);
|
||||||
|
|
||||||
printf("%d %.8f\n",(int)(mycmd + j), iactual);
|
printf("%d %.8f\n",(int)(mycmd + j), iactual);
|
||||||
}
|
}
|
||||||
|
|
||||||
mycmd += cmd_inc;
|
mycmd += cmd_inc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -384,7 +392,7 @@ void hold_ota(int zoom, int gpib, int ota_cmd)
|
||||||
int r = 0;
|
int r = 0;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
char zcmd[128];
|
char zcmd[128];
|
||||||
|
|
||||||
info("Initializing Zoom NILM\n");
|
info("Initializing Zoom NILM\n");
|
||||||
if (zoom_init(zoom) < 0) goto fail;
|
if (zoom_init(zoom) < 0) goto fail;
|
||||||
|
|
||||||
|
@ -413,90 +421,16 @@ void hold_ota(int zoom, int gpib, int ota_cmd)
|
||||||
errx(1, "write failed");
|
errx(1, "write failed");
|
||||||
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
||||||
errx(1, "read timeout");
|
errx(1, "read timeout");
|
||||||
|
|
||||||
usleep(100);
|
usleep(100);
|
||||||
|
|
||||||
info("Holding OTA\n");
|
info("Holding OTA\n");
|
||||||
for (i = 0; i <= 500 && !g_quit; i++){
|
for (i = 0; i <= 500 && !g_quit; i++){
|
||||||
|
|
||||||
iactual = keithley2002_read2(gpib, &tx);
|
iactual = keithley2002_read2(gpib, &tx);
|
||||||
|
|
||||||
printf("%.12f %.12f\n", tx, iactual);
|
printf("%.12f %.12f\n", tx, iactual);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// return to zero
|
|
||||||
buf[0] = '0';
|
|
||||||
if (safewrite(zoom, buf, 1) != 1)
|
|
||||||
errx(1, "write failed");
|
|
||||||
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
|
||||||
errx(1, "read timeout");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
safecleanup:
|
|
||||||
return;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
info("Failed (code %d)\n", r);
|
|
||||||
goto safecleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hold_ota2(int zoom, int gpib, int ota_cmd)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int r = 0;
|
|
||||||
char buf[128];
|
|
||||||
char zcmd[128];
|
|
||||||
int dac1, dac2, adc1, adc2;
|
|
||||||
|
|
||||||
info("Initializing Zoom NILM\n");
|
|
||||||
if (zoom_init(zoom) < 0) goto fail;
|
|
||||||
|
|
||||||
//info("Initializing GPIB\n");
|
|
||||||
//if (gpib_init(gpib) < 0) goto fail;
|
|
||||||
|
|
||||||
//info("Initializing Keithley 2002 Multimeter\n");
|
|
||||||
//if (gpib_addr(gpib, 23) < 0) goto fail;
|
|
||||||
//if (keithley2002_init2(gpib) < 0) goto fail;
|
|
||||||
//if (isnan(keithley2002_read(gpib))) goto fail;
|
|
||||||
|
|
||||||
buf[0] = '0';
|
|
||||||
if (safewrite(zoom, buf, 1) != 1)
|
|
||||||
errx(1, "write failed");
|
|
||||||
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
|
||||||
errx(1, "read timeout");
|
|
||||||
drain(zoom);
|
|
||||||
|
|
||||||
if(ota_cmd > 65535 || ota_cmd < 0)
|
|
||||||
errx(1, "ota command out-of-range");
|
|
||||||
|
|
||||||
if(sprintf(zcmd,"v%.4x",(ota_cmd)) < 5)
|
|
||||||
errx(1, "fail hex conversion");
|
|
||||||
|
|
||||||
if (safewrite(zoom, zcmd, 5) != 5)
|
|
||||||
errx(1, "write failed");
|
|
||||||
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
|
||||||
errx(1, "read timeout");
|
|
||||||
|
|
||||||
usleep(100);
|
|
||||||
|
|
||||||
zcmd[0] = ' ';
|
|
||||||
|
|
||||||
info("Holding OTA\n");
|
|
||||||
for (i = 0; i <= 1000 && !g_quit; i++){
|
|
||||||
|
|
||||||
if(safewrite(zoom,zcmd,1) != 1)
|
|
||||||
errx(1, "write failed");
|
|
||||||
|
|
||||||
if (fdgets(buf, 128, zoom, 1000) == NULL)
|
|
||||||
errx(1, "read timeout");
|
|
||||||
|
|
||||||
if (sscanf(buf,"%x %d %x %d", &dac1, &dac2, &adc1, &adc2) != 4)
|
|
||||||
errx(1, "read error");
|
|
||||||
|
|
||||||
printf("%d %d\n", dac2, adc2);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return to zero
|
// return to zero
|
||||||
|
|
24
pc/dactest.c
24
pc/dactest.c
|
@ -28,8 +28,10 @@ void handle_sig(int sig) { g_quit = 1; }
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *zoomdev=strdup("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A6007wc5-if00-port0");
|
char *zoomdev=strdup("/dev/serial/by-id/usb-FTDI_"
|
||||||
char *gpibdev=strdup("/dev/serial/by-id/usb-Prologix_Prologix_GPIB-USB_Controller_PXQQY20G-if00-port0");
|
"FT232R_USB_UART_A6007wc5-if00-port0");
|
||||||
|
char *gpibdev=strdup("/dev/serial/by-id/usb-Prologix_"
|
||||||
|
"Prologix_GPIB-USB_Controller_PXQQY20G-if00-port0");
|
||||||
int getopt_index;
|
int getopt_index;
|
||||||
int zoom, gpib;
|
int zoom, gpib;
|
||||||
unsigned long seed = 1337;
|
unsigned long seed = 1337;
|
||||||
|
@ -46,7 +48,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "Z:G:s:h?",
|
while ((c = getopt_long(argc, argv, "Z:G:s:h?",
|
||||||
long_opts, &getopt_index)) != -1) {
|
long_opts, &getopt_index)) != -1) {
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case 'Z':
|
case 'Z':
|
||||||
free(zoomdev);
|
free(zoomdev);
|
||||||
|
@ -68,14 +70,17 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help) {
|
if (help) {
|
||||||
fprintf(stderr, "Zoom Nilm DC Test\n");
|
fprintf(stderr, "Zoom Nilm DC Test\n");
|
||||||
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
||||||
fprintf(stderr, " -Z, --zoom-device %-14s zoom NILM serial port\n", "/dev/xxx" /*zoomdev*/);
|
fprintf(stderr, " -Z, --zoom-device %-14s "
|
||||||
fprintf(stderr, " -G, --gpib-device %-14s GPIB serial port\n", "/dev/xxx" /*gpibdev*/);
|
"zoom NILM serial port\n", "/dev/xxx" /*zoomdev*/);
|
||||||
|
fprintf(stderr, " -G, --gpib-device %-14s "
|
||||||
|
"GPIB serial port\n", "/dev/xxx" /*gpibdev*/);
|
||||||
fprintf(stderr, " -s, --seed %-16ld random seed\n", seed);
|
fprintf(stderr, " -s, --seed %-16ld random seed\n", seed);
|
||||||
fprintf(stderr, " -h, --help this help\n");
|
fprintf(stderr, " -h, --help "
|
||||||
|
"this help\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +128,8 @@ void write_random(int zoom, int gpib)
|
||||||
zoom_write_dac(zoom, dac);
|
zoom_write_dac(zoom, dac);
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
meas = keithley2002_read(gpib);
|
meas = keithley2002_read(gpib);
|
||||||
printf("%ld.%06ld %d %.12f\n", now.tv_sec, now.tv_usec, dac, meas);
|
printf("%ld.%06ld %d %.12f\n", now.tv_sec, now.tv_usec,
|
||||||
|
dac, meas);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,4 +140,4 @@ fail:
|
||||||
info("Failed\n");
|
info("Failed\n");
|
||||||
goto safecleanup;
|
goto safecleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
39
pc/dctest.c
39
pc/dctest.c
|
@ -27,8 +27,10 @@ static void handle_sig(int sig) { g_quit = 1; }
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *zoomdev=strdup("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A6007wc5-if00-port0");
|
char *zoomdev=strdup("/dev/serial/by-id/usb-FTDI_"
|
||||||
char *gpibdev=strdup("/dev/serial/by-id/usb-Prologix_Prologix_GPIB-USB_Controller_PXQQY20G-if00-port0");
|
"FT232R_USB_UART_A6007wc5-if00-port0");
|
||||||
|
char *gpibdev=strdup("/dev/serial/by-id/usb-Prologix_"
|
||||||
|
"Prologix_GPIB-USB_Controller_PXQQY20G-if00-port0");
|
||||||
int rate=500000;
|
int rate=500000;
|
||||||
unsigned long seed = 1337;
|
unsigned long seed = 1337;
|
||||||
int getopt_index;
|
int getopt_index;
|
||||||
|
@ -47,7 +49,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "Z:G:r:s:h?",
|
while ((c = getopt_long(argc, argv, "Z:G:r:s:h?",
|
||||||
long_opts, &getopt_index)) != -1) {
|
long_opts, &getopt_index)) != -1) {
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case 'Z':
|
case 'Z':
|
||||||
free(zoomdev);
|
free(zoomdev);
|
||||||
|
@ -74,15 +76,17 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help) {
|
if (help) {
|
||||||
fprintf(stderr, "Zoom Nilm DC Test Tool\n");
|
fprintf(stderr, "Zoom Nilm DC Test Tool\n");
|
||||||
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
||||||
fprintf(stderr, " -Z, --zoom-device %-9s zoom NILM serial port\n", "/dev/xxx");
|
fprintf(stderr, " -Z, --zoom-device %-9s "
|
||||||
fprintf(stderr, " -G, --gpib-device %-9s GPIB serial port\n", "/dev/xxx");
|
"zoom NILM serial port\n", "/dev/xxx");
|
||||||
|
fprintf(stderr, " -G, --gpib-device %-9s "
|
||||||
|
"GPIB serial port\n", "/dev/xxx");
|
||||||
fprintf(stderr, " -r, --rate %-16d baud rate\n", rate);
|
fprintf(stderr, " -r, --rate %-16d baud rate\n", rate);
|
||||||
fprintf(stderr, " -s, --seed %-16ld random seed\n", seed);
|
fprintf(stderr, " -s, --seed %-16ld random seed\n", seed);
|
||||||
fprintf(stderr, " -h, --help this help\n");
|
fprintf(stderr, " -h, --help this help\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +106,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* do the dc test */
|
/* do the dc test */
|
||||||
dctest(zoom, gpib);
|
dctest(zoom, gpib);
|
||||||
|
|
||||||
close(zoom);
|
close(zoom);
|
||||||
close(gpib);
|
close(gpib);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -139,7 +143,7 @@ int process_adc_dac(const uint8_t *buf, struct threadinfo_t *ti)
|
||||||
tmp = ((buf[0] & 0x0F) << 8) | buf[1];
|
tmp = ((buf[0] & 0x0F) << 8) | buf[1];
|
||||||
|
|
||||||
/* sign-extend ADC value */
|
/* sign-extend ADC value */
|
||||||
if (tmp & 0x0800)
|
if (tmp & 0x0800)
|
||||||
tmp |= 0xF000;
|
tmp |= 0xF000;
|
||||||
else
|
else
|
||||||
tmp &= ~0xF000;
|
tmp &= ~0xF000;
|
||||||
|
@ -156,7 +160,7 @@ int process_adc_dac(const uint8_t *buf, struct threadinfo_t *ti)
|
||||||
pthread_mutex_unlock(&ti->mutex);
|
pthread_mutex_unlock(&ti->mutex);
|
||||||
|
|
||||||
/* write it out */
|
/* write it out */
|
||||||
printf("%d %.12f %.12f %.8f %5d %5d %d\n",
|
printf("%d %.12f %.12f %.8f %5d %5d %d\n",
|
||||||
stable,
|
stable,
|
||||||
idesired,
|
idesired,
|
||||||
iactual,
|
iactual,
|
||||||
|
@ -198,7 +202,8 @@ static int process(const uint8_t *buf, int len, struct threadinfo_t *ti)
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
/* badly formed data; eat one byte and retry */
|
/* badly formed data; eat one byte and retry */
|
||||||
info("throwing away 0x%02x '%c'\n", buf[0], isprint(buf[0]) ? buf[0] : '.');
|
info("throwing away 0x%02x '%c'\n", buf[0],
|
||||||
|
isprint(buf[0]) ? buf[0] : '.');
|
||||||
buf++;
|
buf++;
|
||||||
n++;
|
n++;
|
||||||
goto retry;
|
goto retry;
|
||||||
|
@ -219,11 +224,11 @@ static void *read_data(void *arg)
|
||||||
len = 0;
|
len = 0;
|
||||||
while (!ti->quit_flag) {
|
while (!ti->quit_flag) {
|
||||||
int processed, n;
|
int processed, n;
|
||||||
n = saferead_timeout(ti->fd,
|
n = saferead_timeout(ti->fd,
|
||||||
buf + len,
|
buf + len,
|
||||||
sizeof(buf) - len,
|
sizeof(buf) - len,
|
||||||
1000);
|
1000);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
err(1, "read");
|
err(1, "read");
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -284,7 +289,7 @@ static void dctest(int zoom, int gpib)
|
||||||
/* Init Keithley */
|
/* Init Keithley */
|
||||||
info("Initializing GPIB\n");
|
info("Initializing GPIB\n");
|
||||||
if (gpib_init(gpib) < 0) { info("failed\n"); goto out1; }
|
if (gpib_init(gpib) < 0) { info("failed\n"); goto out1; }
|
||||||
|
|
||||||
info("Initializing Keithley\n");
|
info("Initializing Keithley\n");
|
||||||
if (gpib_addr(gpib, 24) < 0) { info("failed\n"); goto out1; }
|
if (gpib_addr(gpib, 24) < 0) { info("failed\n"); goto out1; }
|
||||||
if (keithley_init(gpib) < 0) { info("failed\n"); goto out2; }
|
if (keithley_init(gpib) < 0) { info("failed\n"); goto out2; }
|
||||||
|
@ -339,7 +344,7 @@ static void dctest(int zoom, int gpib)
|
||||||
#define K_MIN -0.5 /* keithley min, amps */
|
#define K_MIN -0.5 /* keithley min, amps */
|
||||||
#define K_MAX 0.5 /* keithley max, amps */
|
#define K_MAX 0.5 /* keithley max, amps */
|
||||||
#define STEPSIZE 0.03 /* max size of small step, in amps */
|
#define STEPSIZE 0.03 /* max size of small step, in amps */
|
||||||
|
|
||||||
/* Choose any value within the Keithley range */
|
/* Choose any value within the Keithley range */
|
||||||
double desired = genrand(K_MIN, K_MAX);
|
double desired = genrand(K_MIN, K_MAX);
|
||||||
info("Big step: %.12f\n", desired);
|
info("Big step: %.12f\n", desired);
|
||||||
|
@ -352,7 +357,7 @@ static void dctest(int zoom, int gpib)
|
||||||
/* Choose a few more values nearby */
|
/* Choose a few more values nearby */
|
||||||
for (i = 0; i < STEPS && !g_quit; i++) {
|
for (i = 0; i < STEPS && !g_quit; i++) {
|
||||||
desired += genrand(-STEPSIZE/2, STEPSIZE/2);
|
desired += genrand(-STEPSIZE/2, STEPSIZE/2);
|
||||||
if (desired < -1.0)
|
if (desired < -1.0)
|
||||||
desired = -1.0;
|
desired = -1.0;
|
||||||
if (desired > 1.0)
|
if (desired > 1.0)
|
||||||
desired = 1.0;
|
desired = 1.0;
|
||||||
|
@ -376,4 +381,4 @@ out2:
|
||||||
out1:
|
out1:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
if (safewrite(fd, string, ____l) != ____l) return rv; \
|
if (safewrite(fd, string, ____l) != ____l) return rv; \
|
||||||
if (safewrite(fd, "\r", 1) != 1) return rv; } while(0)
|
if (safewrite(fd, "\r", 1) != 1) return rv; } while(0)
|
||||||
#define gput(string) gputv(string, -1)
|
#define gput(string) gputv(string, -1)
|
||||||
|
|
||||||
int gpib_init(int fd)
|
int gpib_init(int fd)
|
||||||
{
|
{
|
||||||
gput("++mode 1");
|
gput("++mode 1");
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
A C-program for MT19937, with initialization improved 2002/1/26.
|
A C-program for MT19937, with initialization improved 2002/1/26.
|
||||||
Coded by Takuji Nishimura and Makoto Matsumoto.
|
Coded by Takuji Nishimura and Makoto Matsumoto.
|
||||||
|
|
||||||
Before using, initialize the state by using init_genrand(seed)
|
Before using, initialize the state by using init_genrand(seed)
|
||||||
or init_by_array(init_key, key_length).
|
or init_by_array(init_key, key_length).
|
||||||
|
|
||||||
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
3. The names of its contributors may not be used to endorse or promote
|
3. The names of its contributors may not be used to endorse or promote
|
||||||
products derived from this software without specific prior written
|
products derived from this software without specific prior written
|
||||||
permission.
|
permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
#include "mt19937ar.h"
|
#include "mt19937ar.h"
|
||||||
|
|
||||||
/* Period parameters */
|
/* Period parameters */
|
||||||
#define N 624
|
#define N 624
|
||||||
#define M 397
|
#define M 397
|
||||||
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
|
#define MATRIX_A 0x9908b0dfUL /* constant vector a */
|
||||||
|
@ -58,8 +58,8 @@ void init_genrand(unsigned long s)
|
||||||
{
|
{
|
||||||
mt[0]= s & 0xffffffffUL;
|
mt[0]= s & 0xffffffffUL;
|
||||||
for (mti=1; mti<N; mti++) {
|
for (mti=1; mti<N; mti++) {
|
||||||
mt[mti] =
|
mt[mti] =
|
||||||
(1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
|
(1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
|
||||||
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
|
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
|
||||||
/* In the previous versions, MSBs of the seed affect */
|
/* In the previous versions, MSBs of the seed affect */
|
||||||
/* only MSBs of the array mt[]. */
|
/* only MSBs of the array mt[]. */
|
||||||
|
@ -95,7 +95,7 @@ void init_by_array(unsigned long init_key[], int key_length)
|
||||||
if (i>=N) { mt[0] = mt[N-1]; i=1; }
|
if (i>=N) { mt[0] = mt[N-1]; i=1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
|
mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generates a random number on [0,0xffffffff]-interval */
|
/* generates a random number on [0,0xffffffff]-interval */
|
||||||
|
@ -124,7 +124,7 @@ unsigned long genrand_int32(void)
|
||||||
|
|
||||||
mti = 0;
|
mti = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
y = mt[mti++];
|
y = mt[mti++];
|
||||||
|
|
||||||
/* Tempering */
|
/* Tempering */
|
||||||
|
@ -145,29 +145,29 @@ long genrand_int31(void)
|
||||||
/* generates a random number on [0,1]-real-interval */
|
/* generates a random number on [0,1]-real-interval */
|
||||||
double genrand_real1(void)
|
double genrand_real1(void)
|
||||||
{
|
{
|
||||||
return genrand_int32()*(1.0/4294967295.0);
|
return genrand_int32()*(1.0/4294967295.0);
|
||||||
/* divided by 2^32-1 */
|
/* divided by 2^32-1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generates a random number on [0,1)-real-interval */
|
/* generates a random number on [0,1)-real-interval */
|
||||||
double genrand_real2(void)
|
double genrand_real2(void)
|
||||||
{
|
{
|
||||||
return genrand_int32()*(1.0/4294967296.0);
|
return genrand_int32()*(1.0/4294967296.0);
|
||||||
/* divided by 2^32 */
|
/* divided by 2^32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generates a random number on (0,1)-real-interval */
|
/* generates a random number on (0,1)-real-interval */
|
||||||
double genrand_real3(void)
|
double genrand_real3(void)
|
||||||
{
|
{
|
||||||
return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
|
return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
|
||||||
/* divided by 2^32 */
|
/* divided by 2^32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generates a random number on [0,1) with 53-bit resolution*/
|
/* generates a random number on [0,1) with 53-bit resolution*/
|
||||||
double genrand_res53(void)
|
double genrand_res53(void)
|
||||||
{
|
{
|
||||||
unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
|
unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
|
||||||
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
||||||
}
|
}
|
||||||
/* These real versions are due to Isaku Wada, 2002/01/09 added */
|
/* These real versions are due to Isaku Wada, 2002/01/09 added */
|
||||||
|
|
||||||
|
|
31
pc/read.c
31
pc/read.c
|
@ -21,7 +21,8 @@ int process(const uint8_t *buf, int len);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *device=strdup("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A6007wc5-if00-port0");
|
char *device=strdup("/dev/serial/by-id/usb-FTDI_FT232R_"
|
||||||
|
"USB_UART_A6007wc5-if00-port0");
|
||||||
int rate=500000;
|
int rate=500000;
|
||||||
int fd;
|
int fd;
|
||||||
int getopt_index;
|
int getopt_index;
|
||||||
|
@ -45,7 +46,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "d:r:xDunsh?",
|
while ((c = getopt_long(argc, argv, "d:r:xDunsh?",
|
||||||
long_opts, &getopt_index)) != -1) {
|
long_opts, &getopt_index)) != -1) {
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case 'd':
|
case 'd':
|
||||||
free(device);
|
free(device);
|
||||||
|
@ -78,7 +79,7 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help) {
|
if (help) {
|
||||||
fprintf(stderr, "Zoom Nilm Client\n");
|
fprintf(stderr, "Zoom Nilm Client\n");
|
||||||
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
fprintf(stderr, "usage: %s [options]\n\n", *argv);
|
||||||
|
@ -86,9 +87,12 @@ int main(int argc, char *argv[])
|
||||||
fprintf(stderr, " -r, --rate %-16d baud rate\n", rate);
|
fprintf(stderr, " -r, --rate %-16d baud rate\n", rate);
|
||||||
fprintf(stderr, " -x, --hex hex out\n");
|
fprintf(stderr, " -x, --hex hex out\n");
|
||||||
fprintf(stderr, " -D, --dec dec out\n");
|
fprintf(stderr, " -D, --dec dec out\n");
|
||||||
fprintf(stderr, " -u, --unprocessed dump raw unprocessed data\n");
|
fprintf(stderr, " -u, --unprocessed "
|
||||||
fprintf(stderr, " -n, --no-calibrate skip calibration routine\n");
|
"dump raw unprocessed data\n");
|
||||||
fprintf(stderr, " -s, --screen send \\r instead of \\n\n");
|
fprintf(stderr, " -n, --no-calibrate "
|
||||||
|
"skip calibration routine\n");
|
||||||
|
fprintf(stderr, " -s, --screen "
|
||||||
|
"send \\r instead of \\n\n");
|
||||||
fprintf(stderr, " -h, --help this cruft\n");
|
fprintf(stderr, " -h, --help this cruft\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -107,14 +111,14 @@ int main(int argc, char *argv[])
|
||||||
while (1) {
|
while (1) {
|
||||||
int processed, n;
|
int processed, n;
|
||||||
n = read(fd, buf + len, sizeof(buf) - len);
|
n = read(fd, buf + len, sizeof(buf) - len);
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
err(1, "read");
|
err(1, "read");
|
||||||
len += n;
|
len += n;
|
||||||
processed = process((uint8_t *) buf, len);
|
processed = process((uint8_t *) buf, len);
|
||||||
memmove(buf, buf + processed, len - processed);
|
memmove(buf, buf + processed, len - processed);
|
||||||
len -= processed;
|
len -= processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,12 +136,12 @@ int process_adc_dac(const uint8_t *buf)
|
||||||
|
|
||||||
if (buf[0] & 0x10)
|
if (buf[0] & 0x10)
|
||||||
overflow = 1;
|
overflow = 1;
|
||||||
else
|
else
|
||||||
overflow = 0;
|
overflow = 0;
|
||||||
|
|
||||||
tmp = ((buf[0] & 0x0F) << 8) | buf[1];
|
tmp = ((buf[0] & 0x0F) << 8) | buf[1];
|
||||||
/* sign-extend ADC value */
|
/* sign-extend ADC value */
|
||||||
if (tmp & 0x0800)
|
if (tmp & 0x0800)
|
||||||
tmp |= 0xF000;
|
tmp |= 0xF000;
|
||||||
else
|
else
|
||||||
tmp &= ~0xF000;
|
tmp &= ~0xF000;
|
||||||
|
@ -155,8 +159,8 @@ int process_adc_dac(const uint8_t *buf)
|
||||||
if (overflow)
|
if (overflow)
|
||||||
printf(" **** adc may have clamped");
|
printf(" **** adc may have clamped");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen)
|
if (screen)
|
||||||
printf("\033[K\r");
|
printf("\033[K\r");
|
||||||
else
|
else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -200,7 +204,8 @@ int process(const uint8_t *buf, int len)
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
/* badly formed data; eat one byte and retry */
|
/* badly formed data; eat one byte and retry */
|
||||||
fprintf(stderr,"throwing away 0x%02x '%c'\n", buf[0], isprint(buf[0]) ? buf[0] : '.');
|
fprintf(stderr,"throwing away 0x%02x '%c'\n",
|
||||||
|
buf[0], isprint(buf[0]) ? buf[0] : '.');
|
||||||
buf++;
|
buf++;
|
||||||
n++;
|
n++;
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|
|
@ -26,12 +26,12 @@ static int rate_to_constant(int baudrate) {
|
||||||
B(50); B(75); B(110); B(134); B(150);
|
B(50); B(75); B(110); B(134); B(150);
|
||||||
B(200); B(300); B(600); B(1200); B(1800);
|
B(200); B(300); B(600); B(1200); B(1800);
|
||||||
B(2400); B(4800); B(9600); B(19200); B(38400);
|
B(2400); B(4800); B(9600); B(19200); B(38400);
|
||||||
B(57600); B(115200); B(230400); B(460800); B(500000);
|
B(57600); B(115200); B(230400); B(460800); B(500000);
|
||||||
B(576000); B(921600); B(1000000);B(1152000);B(1500000);
|
B(576000); B(921600); B(1000000);B(1152000);B(1500000);
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
#undef B
|
#undef B
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open serial port in raw mode, with custom baudrate if necessary */
|
/* Open serial port in raw mode, with custom baudrate if necessary */
|
||||||
int serial_open(const char *device, int rate)
|
int serial_open(const char *device, int rate)
|
||||||
|
@ -54,7 +54,7 @@ int serial_open(const char *device, int rate)
|
||||||
serinfo.flags &= ~ASYNC_SPD_MASK;
|
serinfo.flags &= ~ASYNC_SPD_MASK;
|
||||||
serinfo.flags |= ASYNC_SPD_CUST;
|
serinfo.flags |= ASYNC_SPD_CUST;
|
||||||
serinfo.custom_divisor = (serinfo.baud_base + (rate / 2)) / rate;
|
serinfo.custom_divisor = (serinfo.baud_base + (rate / 2)) / rate;
|
||||||
if (serinfo.custom_divisor < 1)
|
if (serinfo.custom_divisor < 1)
|
||||||
serinfo.custom_divisor = 1;
|
serinfo.custom_divisor = 1;
|
||||||
if (ioctl(fd, TIOCSSERIAL, &serinfo) < 0)
|
if (ioctl(fd, TIOCSSERIAL, &serinfo) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -121,7 +121,7 @@ ssize_t safewrite(int fd, const void *buf, size_t count)
|
||||||
size_t nwritten = 0;
|
size_t nwritten = 0;
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
ssize_t r = write(fd, buf, count);
|
ssize_t r = write(fd, buf, count);
|
||||||
|
|
||||||
if (r < 0 && errno == EINTR)
|
if (r < 0 && errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -142,9 +142,9 @@ int drain_timeout(int fd, int msec)
|
||||||
int ret;
|
int ret;
|
||||||
while (1) {
|
while (1) {
|
||||||
ret = saferead_timeout(fd, buf, sizeof(buf), msec);
|
ret = saferead_timeout(fd, buf, sizeof(buf), msec);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Like fprintf, but to a fd, using safewrite. */
|
/* Like fprintf, but to a fd, using safewrite. */
|
||||||
|
@ -170,7 +170,8 @@ char *fdgets(char *s, int size, int fd, int timeout_ms)
|
||||||
int ret;
|
int ret;
|
||||||
int nread = 0;
|
int nread = 0;
|
||||||
|
|
||||||
/* Not very efficient, needs to read one char at a time to avoid buffering */
|
/* Not very efficient; needs to read one char at a time to
|
||||||
|
* avoid buffering */
|
||||||
while (nread < (size - 1)) {
|
while (nread < (size - 1)) {
|
||||||
ret = saferead_timeout(fd, &s[nread], 1, timeout_ms);
|
ret = saferead_timeout(fd, &s[nread], 1, timeout_ms);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
|
@ -194,6 +195,8 @@ void chomp(char *s)
|
||||||
{
|
{
|
||||||
int len = strlen(s);
|
int len = strlen(s);
|
||||||
/* do it twice to remove \r\n as well */
|
/* do it twice to remove \r\n as well */
|
||||||
if (len > 1 && (s[len - 1] == '\r' || s[len - 1] == '\n')) s[--len] = '\0';
|
if (len > 1 && (s[len - 1] == '\r' || s[len - 1] == '\n'))
|
||||||
if (len > 1 && (s[len - 1] == '\r' || s[len - 1] == '\n')) s[--len] = '\0';
|
s[--len] = '\0';
|
||||||
|
if (len > 1 && (s[len - 1] == '\r' || s[len - 1] == '\n'))
|
||||||
|
s[--len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,10 @@
|
||||||
#include "zoom.h"
|
#include "zoom.h"
|
||||||
#include "serial-util.h"
|
#include "serial-util.h"
|
||||||
|
|
||||||
#define zputs(s) do { if (safewrite(fd, s, strlen(s)) != strlen(s)) return -1; } while(0)
|
#define zputs(s) do { if (safewrite(fd, s, strlen(s)) != strlen(s)) \
|
||||||
#define zputc(ch) do { const char ____c = ch; if (safewrite(fd, &____c, 1) != 1) return -1; } while(0)
|
return -1; } while(0)
|
||||||
|
#define zputc(ch) do { const char ____c = ch; \
|
||||||
|
if (safewrite(fd, &____c, 1) != 1) return -1; } while(0)
|
||||||
|
|
||||||
static int last_dac, last_adc;
|
static int last_dac, last_adc;
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ int zoom_sweep(int fd, int dac[ZOOM_SWEEP_COUNT], int adc[ZOOM_SWEEP_COUNT])
|
||||||
int zoom_write_dac(int fd, int dac)
|
int zoom_write_dac(int fd, int dac)
|
||||||
{
|
{
|
||||||
char s[128];
|
char s[128];
|
||||||
|
|
||||||
sprintf(s, "v%04x", dac);
|
sprintf(s, "v%04x", dac);
|
||||||
zputs(s);
|
zputs(s);
|
||||||
if (verify_prompt(fd) < 0)
|
if (verify_prompt(fd) < 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user