Skip to content

Commit

Permalink
Intenting the code
Browse files Browse the repository at this point in the history
  • Loading branch information
keesj committed Dec 29, 2009
1 parent dba4693 commit c86913a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool parse_args(int argc, char **argv)
libusb_debug_level = strtol(optarg, &endptr, 10);
if (*endptr != '\0' || libusb_debug_level < 0 || libusb_debug_level > 3) {
short_usage("Invalid libusb debug level, must be a positive integer between "
"0 and 3: %s", optarg);
"0 and 3: %s", optarg);
return false;
}
break;
Expand Down Expand Up @@ -147,7 +147,7 @@ bool parse_args(int argc, char **argv)

int count = 0;
int sum = 0;
bool on_data_callback(uint8_t *data, size_t size, void *user_data)
bool on_data_callback(uint8_t * data, size_t size, void *user_data)
{
bool more = sum < 24 * 1024 * 1024;
fprintf(stderr, "Got sample: size: %zu, #samples: %d, aggregate size: %d, more: %d\n", size, count, sum, more);
Expand Down
12 changes: 7 additions & 5 deletions slogic.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct slogic_sample_rate sample_rates[] = {

static const int n_sample_rates = sizeof(sample_rates) / sizeof(struct slogic_sample_rate);

void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t *size)
void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t * size)
{
*sample_rates_out = sample_rates;
*size = n_sample_rates;
Expand Down Expand Up @@ -149,7 +149,7 @@ void slogic_close(struct slogic_handle *handle)
free(handle);
}

void slogic_tune(struct slogic_handle *handle, FILE *debug_file, size_t transfer_buffer_size,
void slogic_tune(struct slogic_handle *handle, FILE * debug_file, size_t transfer_buffer_size,
unsigned int n_transfer_buffers, unsigned int transfer_timeout, int libusb_debug_level)
{
assert(handle);
Expand Down Expand Up @@ -305,7 +305,8 @@ void slogic_read_samples_callback(struct libusb_transfer *transfer)

internal_recording->done = true;

fprintf(internal_recording->recording->debug_file, "Transfer failed: %s\n", libusb_transfer_status_to_string(transfer->status));
fprintf(internal_recording->recording->debug_file, "Transfer failed: %s\n",
libusb_transfer_status_to_string(transfer->status));

switch (transfer->status) {
default:
Expand Down Expand Up @@ -431,7 +432,8 @@ void slogic_execute_recording(struct slogic_handle *handle, struct slogic_record
}

if (internal_recording->recording->recording_state != COMPLETED_SUCCESSFULLY) {
fprintf(recording->debug_file, "FAIL! recording_state=%d\n", internal_recording->recording->recording_state);
fprintf(recording->debug_file, "FAIL! recording_state=%d\n",
internal_recording->recording->recording_state);
} else {
fprintf(recording->debug_file, "SUCCESS!\n");
}
Expand All @@ -441,7 +443,7 @@ void slogic_execute_recording(struct slogic_handle *handle, struct slogic_record

int sec = end.tv_sec - start.tv_sec;
int usec = (end.tv_usec - start.tv_usec) / 1000;
if(usec < 0) {
if (usec < 0) {
sec--;
usec = 1 - usec;
}
Expand Down
6 changes: 3 additions & 3 deletions slogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum slogic_recording_state {
* - Trygve
*/

void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t *size);
void slogic_available_sample_rates(struct slogic_sample_rate **sample_rates_out, size_t * size);

struct slogic_sample_rate *slogic_parse_sample_rate(const char *str);

Expand All @@ -66,13 +66,13 @@ void slogic_close(struct slogic_handle *handle);
* struct slogic_tunable with a set of unions for each tunable.
*/
void slogic_tune(struct slogic_handle *handle,
FILE *debug_file,
FILE * debug_file,
size_t transfer_buffer_size,
unsigned int n_transfer_buffers, unsigned int transfer_timeout, int libusb_debug_level);

int slogic_readbyte(struct slogic_handle *handle, unsigned char *out);

typedef bool(*slogic_on_data_callback) (uint8_t *data, size_t size, void *user_data);
typedef bool(*slogic_on_data_callback) (uint8_t * data, size_t size, void *user_data);

struct slogic_recording {
struct slogic_sample_rate *sample_rate;
Expand Down
12 changes: 6 additions & 6 deletions usbutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Data structure debugging.
*/

static void dump_endpoint_descriptor(FILE *file, int i, const struct libusb_endpoint_descriptor *endpoint_descriptor)
static void dump_endpoint_descriptor(FILE * file, int i, const struct libusb_endpoint_descriptor *endpoint_descriptor)
{
char *direction = ((endpoint_descriptor->bEndpointAddress & 0x80) == LIBUSB_ENDPOINT_IN) ? "in" : "out";

Expand All @@ -20,7 +20,7 @@ static void dump_endpoint_descriptor(FILE *file, int i, const struct libusb_endp
fprintf(file, " Sync address: %d\n", endpoint_descriptor->bSynchAddress);
}

static void dump_interface(FILE *file, int i, const struct libusb_interface *interface)
static void dump_interface(FILE * file, int i, const struct libusb_interface *interface)
{
fprintf(file, " Interface #%d: Descriptors: (%d)\n", i, interface->num_altsetting);
const struct libusb_interface_descriptor *interface_descriptor = interface->altsetting;
Expand All @@ -39,7 +39,7 @@ static void dump_interface(FILE *file, int i, const struct libusb_interface *int
}
}

void usbutil_dump_config_descriptor(FILE *file, struct libusb_config_descriptor *config_descriptor)
void usbutil_dump_config_descriptor(FILE * file, struct libusb_config_descriptor *config_descriptor)
{
/* TODO: Decode bytes to strings */
fprintf(file, "Configuration descriptor:\n");
Expand All @@ -53,7 +53,7 @@ void usbutil_dump_config_descriptor(FILE *file, struct libusb_config_descriptor
}
}

void usbutil_dump_device_descriptor(FILE *file, struct libusb_device_descriptor *device_descriptor)
void usbutil_dump_device_descriptor(FILE * file, struct libusb_device_descriptor *device_descriptor)
{
/* TODO: Decode bytes to strings */
fprintf(file, "Device descriptor:\n");
Expand All @@ -72,7 +72,7 @@ void usbutil_dump_device_descriptor(FILE *file, struct libusb_device_descriptor
/*
* This method looks if the kernel already has a driver attached to the device. if so I will take over the device.
*/
static enum libusb_error claim_device(libusb_device_handle *dev, int interface)
static enum libusb_error claim_device(libusb_device_handle * dev, int interface)
{
enum libusb_error err;
if (libusb_kernel_driver_active(dev, interface)) {
Expand Down Expand Up @@ -109,7 +109,7 @@ static enum libusb_error claim_device(libusb_device_handle *dev, int interface)
* Iterates over the usb devices on the usb busses and returns a handle to the
* first device found that matches the predefined vendor and product id
*/
libusb_device_handle *open_device(libusb_context *ctx, int vendor_id, int product_id)
libusb_device_handle *open_device(libusb_context * ctx, int vendor_id, int product_id)
{
// discover devices
libusb_device **list;
Expand Down
2 changes: 1 addition & 1 deletion usbutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Iterates over the usb devices on the usb busses and returns a handle to the
* first device found that matches the predefined vendor and product id
*/
libusb_device_handle *open_device(libusb_context *ctx, int vendor_id, int product_id);
libusb_device_handle *open_device(libusb_context * ctx, int vendor_id, int product_id);

const char *libusb_transfer_status_to_string(enum libusb_transfer_status transfer_status);

Expand Down

0 comments on commit c86913a

Please sign in to comment.