mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-24 05:01:03 +02:00
spi: spidev_test: Cleaned hexadecimal dump
Signed-off-by: Adrian Remonda <adrianremonda@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
c517d838eb
commit
b78ce7ed54
@@ -15,6 +15,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@@ -35,6 +36,33 @@ static uint8_t bits = 8;
|
|||||||
static uint32_t speed = 500000;
|
static uint32_t speed = 500000;
|
||||||
static uint16_t delay;
|
static uint16_t delay;
|
||||||
|
|
||||||
|
static void hex_dump(const void *src, size_t length, size_t line_size, char *prefix)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
const unsigned char *address = src;
|
||||||
|
const unsigned char *line = address;
|
||||||
|
unsigned char c;
|
||||||
|
|
||||||
|
printf("%s | ", prefix);
|
||||||
|
while (length-- > 0) {
|
||||||
|
printf("%02X ", *address++);
|
||||||
|
if (!(++i % line_size) || (length == 0 && i % line_size)) {
|
||||||
|
if (length == 0) {
|
||||||
|
while (i++ % line_size)
|
||||||
|
printf("__ ");
|
||||||
|
}
|
||||||
|
printf(" | "); /* right close */
|
||||||
|
while (line < address) {
|
||||||
|
c = *line++;
|
||||||
|
printf("%c", (c < 33 || c == 255) ? 0x2E : c);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
if (length > 0)
|
||||||
|
printf("%s | ", prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void transfer(int fd)
|
static void transfer(int fd)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -76,12 +104,7 @@ static void transfer(int fd)
|
|||||||
if (ret < 1)
|
if (ret < 1)
|
||||||
pabort("can't send spi message");
|
pabort("can't send spi message");
|
||||||
|
|
||||||
for (ret = 0; ret < ARRAY_SIZE(tx); ret++) {
|
hex_dump(rx, ARRAY_SIZE(rx), 32, "RX");
|
||||||
if (!(ret % 6))
|
|
||||||
puts("");
|
|
||||||
printf("%.2X ", rx[ret]);
|
|
||||||
}
|
|
||||||
puts("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_usage(const char *prog)
|
static void print_usage(const char *prog)
|
||||||
|
Reference in New Issue
Block a user