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

View file

@ -44,7 +44,7 @@ int main(int argc, char **argv) {
goto error_capture_open;
}
} 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()");
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) {
goto error_io;
} else if (len < sizeof(data)) {
} else if (len && len < sizeof(data)) {
goto error_io;
}
@ -143,18 +143,18 @@ error_gettimeofday:
int hexagram_capture_replay(hexagram_capture *capture,
hexagram_can_if *can_if,
float speed) {
ssize_t len;
uint32_t timestamp[2],
usec_last = 0;
struct can_frame frame;
while (1) {
if ((len = hexagram_capture_read(capture,
&timestamp[0],
&timestamp[1],
&frame)) < 0) {
ssize_t len = hexagram_capture_read(capture,
&timestamp[0],
&timestamp[1],
&frame);
if (len < 0) {
goto error_io;
} else if (len == 0) {
break;