summaryrefslogtreecommitdiff
path: root/ao-tools
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2018-03-18 15:47:31 -0600
committerBdale Garbee <bdale@gag.com>2018-03-18 15:47:31 -0600
commit7b614380f307cb5e27f2a05281bc76c4ace93334 (patch)
treed243b069a134233f4b98e35769193a1244fc57f8 /ao-tools
parent16a9d8617b2d2092d166a85ada4349601afb0dce (diff)
parent39023ed6e29103a85bfad505506fa0dbf4dc1112 (diff)
Merge branch 'master' into branch-1.8
Diffstat (limited to 'ao-tools')
-rw-r--r--ao-tools/ao-chaosread/ao-chaosread.114
-rw-r--r--ao-tools/ao-chaosread/ao-chaosread.c22
-rw-r--r--ao-tools/ao-usbload/ao-usbload.c4
3 files changed, 32 insertions, 8 deletions
diff --git a/ao-tools/ao-chaosread/ao-chaosread.1 b/ao-tools/ao-chaosread/ao-chaosread.1
index ead8afb2..e6ed2fac 100644
--- a/ao-tools/ao-chaosread/ao-chaosread.1
+++ b/ao-tools/ao-chaosread/ao-chaosread.1
@@ -33,6 +33,20 @@ one found.
\-l length | --length length
Set the amount of data to read. Suffixes 'k', 'M' and 'G' are
supported. The default is 1k.
+.TP
+\-i | --infinite
+Read an unlimited amount of data.
+.TP
+\-b | --bytes
+For each 16-bit value read, output bits 1-8 as a byte, don't output
+bit 0 or bits 9-15 at all.
+.TP
+\-c | --cooked
+Read whitened data from the device. The default is to read raw data
+from the noise source.
+.TP
+\-r | --raw
+Read raw data from the noise source. This is the default.
.SH USAGE
.I ao-chaosread
reads noise data.
diff --git a/ao-tools/ao-chaosread/ao-chaosread.c b/ao-tools/ao-chaosread/ao-chaosread.c
index 6d860139..8a814a00 100644
--- a/ao-tools/ao-chaosread/ao-chaosread.c
+++ b/ao-tools/ao-chaosread/ao-chaosread.c
@@ -172,10 +172,11 @@ chaoskey_close(struct chaoskey *ck)
free(ck);
}
-#define ENDPOINT 0x86
+#define COOKED_ENDPOINT 0x85
+#define RAW_ENDPOINT 0x86
int
-chaoskey_read(struct chaoskey *ck, void *buffer, int len)
+chaoskey_read(struct chaoskey *ck, int endpoint, void *buffer, int len)
{
uint8_t *buf = buffer;
int total = 0;
@@ -184,7 +185,7 @@ chaoskey_read(struct chaoskey *ck, void *buffer, int len)
int ret;
int transferred;
- ret = libusb_bulk_transfer(ck->handle, ENDPOINT, buf, len, &transferred, 10000);
+ ret = libusb_bulk_transfer(ck->handle, endpoint, buf, len, &transferred, 10000);
if (ret) {
if (total)
return total;
@@ -205,12 +206,14 @@ static const struct option options[] = {
{ .name = "length", .has_arg = 1, .val = 'l' },
{ .name = "infinite", .has_arg = 0, .val = 'i' },
{ .name = "bytes", .has_arg = 0, .val = 'b' },
+ { .name = "cooked", .has_arg = 0, .val = 'c' },
+ { .name = "raw", .has_arg = 0, .val = 'r' },
{ 0, 0, 0, 0},
};
static void usage(char *program)
{
- fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]] [--infinite] [--bytes]\n", program);
+ fprintf(stderr, "usage: %s [--serial=<serial>] [--length=<length>[kMG]] [--infinite] [--bytes] [--cooked] [--raw]\n", program);
exit(1);
}
@@ -228,8 +231,9 @@ main (int argc, char **argv)
int this_time;
int infinite = 0;
int bytes = 0;
+ int endpoint = RAW_ENDPOINT;
- while ((c = getopt_long(argc, argv, "s:l:ib", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "s:l:ibcr", options, NULL)) != -1) {
switch (c) {
case 's':
serial = optarg;
@@ -252,6 +256,12 @@ main (int argc, char **argv)
case 'b':
bytes = 1;
break;
+ case 'c':
+ endpoint = COOKED_ENDPOINT;
+ break;
+ case 'r':
+ endpoint = RAW_ENDPOINT;
+ break;
default:
usage(argv[0]);
break;
@@ -269,7 +279,7 @@ main (int argc, char **argv)
this_time = sizeof(buf);
if (!infinite && length < sizeof(buf))
this_time = (int) length;
- got = chaoskey_read(ck, buf, this_time);
+ got = chaoskey_read(ck, endpoint, buf, this_time);
if (got < 0) {
perror("read");
exit(1);
diff --git a/ao-tools/ao-usbload/ao-usbload.c b/ao-tools/ao-usbload/ao-usbload.c
index 758eb696..31ee138a 100644
--- a/ao-tools/ao-usbload/ao-usbload.c
+++ b/ao-tools/ao-usbload/ao-usbload.c
@@ -402,9 +402,9 @@ main (int argc, char **argv)
old_len = ucs2len(old_product);
if (new_len != old_len || memcmp(new_product, old_product, new_len * 2) != 0) {
fprintf(stderr, "USB product mismatch (device is ");
- putucs2str(new_product, stderr);
- fprintf(stderr, ", image is ");
putucs2str(old_product, stderr);
+ fprintf(stderr, ", image is ");
+ putucs2str(new_product, stderr);
fprintf(stderr, ")\n");
done(cc, 1);
}