projects
/
libam7xxx.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Indent header_data fields when dumping headers
[libam7xxx.git]
/
src
/
am7xxx.c
diff --git
a/src/am7xxx.c
b/src/am7xxx.c
index
182ea27
..
483eaf7
100644
(file)
--- a/
src/am7xxx.c
+++ b/
src/am7xxx.c
@@
-26,30
+26,16
@@
#define AM7XXX_VENDOR_ID 0x1de1
#define AM7XXX_PRODUCT_ID 0xc101
#define AM7XXX_VENDOR_ID 0x1de1
#define AM7XXX_PRODUCT_ID 0xc101
-#if 1
-static uint8_t reference_image_header[] = {
- 0x02, 0x00, 0x00, 0x00,
- 0x00,
- 0x10,
- 0x3e,
- 0x10,
- 0x01, 0x00, 0x00, 0x00,
- 0x20, 0x03, 0x00, 0x00,
- 0xe0, 0x01, 0x00, 0x00,
- 0x53, 0xE8, 0x00, 0x00
-};
-#endif
-
static void dump_image_header(struct am7xxx_image_header *i)
{
if (i == NULL)
return;
printf("Image header:\n");
static void dump_image_header(struct am7xxx_image_header *i)
{
if (i == NULL)
return;
printf("Image header:\n");
- printf("
format:
0x%08x (%u)\n", i->format, i->format);
- printf("
width:
0x%08x (%u)\n", i->width, i->width);
- printf("
height:
0x%08x (%u)\n", i->height, i->height);
- printf("
image size:
0x%08x (%u)\n", i->image_size, i->image_size);
+ printf("
\tformat:
0x%08x (%u)\n", i->format, i->format);
+ printf("
\twidth:
0x%08x (%u)\n", i->width, i->width);
+ printf("
\theight:
0x%08x (%u)\n", i->height, i->height);
+ printf("
\timage size:
0x%08x (%u)\n", i->image_size, i->image_size);
}
static void dump_header(struct am7xxx_header *h)
}
static void dump_header(struct am7xxx_header *h)
@@
-78,6
+64,8
@@
static void dump_header(struct am7xxx_header *h)
static inline unsigned int in_80chars(unsigned int i)
{
static inline unsigned int in_80chars(unsigned int i)
{
+ /* The 3 below is the length of "xx " where xx is the hex string
+ * representation of a byte */
return ((i+1) % (80/3));
}
return ((i+1) % (80/3));
}
@@
-99,7
+87,10
@@
static int send_data(am7xxx_device dev, uint8_t *buffer, unsigned int len)
int ret;
int transferred;
int ret;
int transferred;
+#if DEBUG
dump_buffer(buffer, len);
dump_buffer(buffer, len);
+ printf("\n");
+#endif
ret = libusb_bulk_transfer(dev, 1, buffer, len, &transferred, 0);
if (ret != 0 || (unsigned int)transferred != len) {
ret = libusb_bulk_transfer(dev, 1, buffer, len, &transferred, 0);
if (ret != 0 || (unsigned int)transferred != len) {
@@
-131,6
+122,11
@@
static int send_header(am7xxx_device dev, struct am7xxx_header *h)
uint8_t *buffer;
int ret;
uint8_t *buffer;
int ret;
+#if DEBUG
+ dump_header(h);
+ printf("\n");
+#endif
+
buffer = calloc(AM7XXX_HEADER_WIRE_SIZE, 1);
if (buffer == NULL) {
perror("calloc buffer");
buffer = calloc(AM7XXX_HEADER_WIRE_SIZE, 1);
if (buffer == NULL) {
perror("calloc buffer");
@@
-204,12
+200,6
@@
int am7xxx_send_image(am7xxx_device dev,
},
};
},
};
- dump_header(&h);
- printf("\n");
-
- printf("Dump Buffers\n");
- dump_buffer(reference_image_header, sizeof(struct am7xxx_header));
-
ret = send_header(dev, &h);
if (ret < 0)
return ret;
ret = send_header(dev, &h);
if (ret < 0)
return ret;