projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update Releasing with wisdom from 1.8.4 release process
[fw/altos]
/
ao-tools
/
ao-chaosread
/
ao-chaosread.c
diff --git
a/ao-tools/ao-chaosread/ao-chaosread.c
b/ao-tools/ao-chaosread/ao-chaosread.c
index 82831201c1b3ffe1e7c1ddf87470f8cb1b6dd80b..6d860139f71487a59dbd3f9d8e6433532fa018b4 100644
(file)
--- a/
ao-tools/ao-chaosread/ao-chaosread.c
+++ b/
ao-tools/ao-chaosread/ao-chaosread.c
@@
-74,7
+74,7
@@
chaoskey_match(libusb_device *dev, char *match_serial)
goto out;
}
goto out;
}
- ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, device_serial, match_len + 1);
+ ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber,
(unsigned char *)
device_serial, match_len + 1);
if (ret < 0) {
fprintf(stderr, "failed to get serial number: %s\n", libusb_strerror(ret));
if (ret < 0) {
fprintf(stderr, "failed to get serial number: %s\n", libusb_strerror(ret));
@@
-103,7
+103,6
@@
chaoskey_open(char *serial)
int ret;
ssize_t num;
libusb_device **list;
int ret;
ssize_t num;
libusb_device **list;
- libusb_device *device = NULL;
int d;
ck = calloc(sizeof (struct chaoskey), 1);
int d;
ck = calloc(sizeof (struct chaoskey), 1);
@@
-173,12
+172,6
@@
chaoskey_close(struct chaoskey *ck)
free(ck);
}
free(ck);
}
-void
-chaoskey_transfer_callback(struct libusb_transfer *transfer)
-{
- struct chaoskey *ck = transfer->user_data;
-}
-
#define ENDPOINT 0x86
int
#define ENDPOINT 0x86
int
@@
-202,7
+195,9
@@
chaoskey_read(struct chaoskey *ck, void *buffer, int len)
}
len -= transferred;
buf += transferred;
}
len -= transferred;
buf += transferred;
+ total += transferred;
}
}
+ return total;
}
static const struct option options[] = {
}
static const struct option options[] = {
@@
-234,7
+229,7
@@
main (int argc, char **argv)
int infinite = 0;
int bytes = 0;
int infinite = 0;
int bytes = 0;
- while ((c = getopt_long(argc, argv, "s:l:", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "s:l:
ib
", options, NULL)) != -1) {
switch (c) {
case 's':
serial = optarg;
switch (c) {
case 's':
serial = optarg;
@@
-283,8
+278,17
@@
main (int argc, char **argv)
int i;
for (i = 0; i < got / 2; i++)
putchar((buf[i] >> 1 & 0xff));
int i;
for (i = 0; i < got / 2; i++)
putchar((buf[i] >> 1 & 0xff));
- } else
- write(1, buf, got);
+ } else {
+ int i;
+ int ret;
+ for (i = 0; i < got; i += ret) {
+ ret = write(1, ((char *) buf) + i, got - i);
+ if (ret <= 0) {
+ perror("write");
+ exit(1);
+ }
+ }
+ }
length -= got;
}
exit(0);
length -= got;
}
exit(0);