ohhh yeah that's the good shit

This commit is contained in:
XANTRONIX Development 2019-02-16 01:39:43 -06:00
parent 4ae8dd7339
commit b82884f23c
3 changed files with 11 additions and 10 deletions

View file

@ -6,6 +6,7 @@ INCLUDE_PATH = ../include
CFLAGS += -I$(INCLUDE_PATH) CFLAGS += -I$(INCLUDE_PATH)
LDFLAGS = -L../src -lhexagram LDFLAGS = -L../src -lhexagram
STATIC = ../src/libhexagram.a
EXAMPLES = capture convert pcapread replay EXAMPLES = capture convert pcapread replay
@ -13,8 +14,8 @@ RM = /bin/rm
all: $(EXAMPLES) all: $(EXAMPLES)
$(EXAMPLES): %: %.c $(EXAMPLES): %: %.c $(STATIC)
$(CC) $(CFLAGS) $< -o $@ ../src/libhexagram.a $(CC) $(CFLAGS) $< -o $@ $(STATIC)
clean: clean:
$(RM) -f $(EXAMPLES) $(RM) -f $(EXAMPLES)

View file

@ -44,7 +44,7 @@ int main(int argc, char **argv) {
goto error_capture_open; goto error_capture_open;
} }
} else if (argc == 3) { } else if (argc == 3) {
if ((capture = hexagram_capture_open_file(argv[2], O_CREAT | O_WRONLY)) == NULL) { if ((capture = hexagram_capture_open_file(argv[2], O_CREAT | O_TRUNC | O_WRONLY)) == NULL) {
perror("hexagram_capture_open_file()"); perror("hexagram_capture_open_file()");
goto error_capture_open; goto error_capture_open;

View file

@ -96,7 +96,7 @@ ssize_t hexagram_capture_read(hexagram_capture *capture,
if ((len = read(capture->fd, &data, sizeof(data))) < 0) { if ((len = read(capture->fd, &data, sizeof(data))) < 0) {
goto error_io; goto error_io;
} else if (len < sizeof(data)) { } else if (len && len < sizeof(data)) {
goto error_io; goto error_io;
} }
@ -143,18 +143,18 @@ error_gettimeofday:
int hexagram_capture_replay(hexagram_capture *capture, int hexagram_capture_replay(hexagram_capture *capture,
hexagram_can_if *can_if, hexagram_can_if *can_if,
float speed) { float speed) {
ssize_t len;
uint32_t timestamp[2], uint32_t timestamp[2],
usec_last = 0; usec_last = 0;
struct can_frame frame; struct can_frame frame;
while (1) { while (1) {
if ((len = hexagram_capture_read(capture, ssize_t len = hexagram_capture_read(capture,
&timestamp[0], &timestamp[0],
&timestamp[1], &timestamp[1],
&frame)) < 0) { &frame);
if (len < 0) {
goto error_io; goto error_io;
} else if (len == 0) { } else if (len == 0) {
break; break;