Closed rben closed 12 years ago
Thanks for your contribution. I will work on getting them into the source code by the end of next week. In the future, a diff or better yet, a pull request, would streamline things. You can find documentation about pull requests on Github at Help.Github.
Using usbscale on ubuntu 11.10 was problematic and after analyzing debug data I discovered a type mismatch in usbscale.c
I would suggest you change the debug printf to reduce lines. Perhaps the following:
FROM:
ifdef DEBUG
endif
TO:
ifdef DEBUG
endif
ALSO: fprintf(stderr, "It has descriptors:\n\tmanufc: %d\n\tprodct: %d\n\tserial: %d\n\tclass: %d\n\tsubclass: %d\n", TO: fprintf(stderr, "It has descriptors: manufc: %d, prodct: %d, serial: %d, class: %d, subclass: %d; ",
Finally - In my debugging to track down the type mismatch I added the following to the print_scale_data call after the following statement: double weight = (double)(dat[4] + (dat[5] << 8)) / 10;
ifdef DEBUG
endif
With the suggested debug messages my output looked as follows:
Found scale 1446:6a73 (bus 3, device 9):It has descriptors: manufc: 1, prodct: 2, serial: 3, class: 0, subclass: 0; Manufacturer: ELANE 3, 4, b, ff, 8d, 0, 3, 4, b, ffffffff, ffffff8d, 0, -11.5 oz
The negative output was due to the mismatch when applying the follwing in the code: double weight = (double)(dat[4] + (dat[5] << 8)) / 10;
Solution: Suggest you change print_scale_data in usbscale.c:
FROM: static int print_scaledata(char); and static int print_scaledata(char dat) {
TO: static int print_scaledata(unsigned char); and static int print_scaledata(unsigned char dat) { respectively.
This should unify the type between the function and the "data" type which it is called with.
It would be really great if debug could just be switched on the command line.