Skip to content

Commit

Permalink
Merge branch 'trygvis'
Browse files Browse the repository at this point in the history
  • Loading branch information
keesj committed Dec 27, 2009
2 parents 036d383 + 4183922 commit dba4693
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# vim: noexpandtab
sinclude Makefile.local

VERSION = 1.0

CFLAGS ?= -g
CFLAGS += -Wall
CFLAGS += `$(PKG_CONFIG) --cflags $(PKGS)`
Expand Down Expand Up @@ -31,3 +34,19 @@ sinclude .deps
.deps: $(wildcard *.h)
$(CC) $(CFLAGS) $(CPPFLAGS) -MM *.c > .deps
$(MAKE) -C firmware .deps

# Misc

test:

install:
mkdir -p $(DESTDIR)/usr/bin
cp main $(DESTDIR)/usr/bin/slogic
chmod +x $(DESTDIR)/usr/bin/slogic

dist:
date=`git log --date=iso --pretty="format:%ci"|sed -n -e "s,\(....\)-\(..\)-\(..\) \(..\):\(..\).*,\1\2\3\4\5," -e 1p`; \
echo "Creating archive in ../saleae-logic-libusb-$(VERSION)-$$date.tar.gz"; \
git archive --prefix=saleae-logic-libusb-$(VERSION)-$$date/ HEAD | gzip > ../saleae-logic-libusb-$(VERSION)-$$date.tar.gz

.PHONY: dist all run
6 changes: 6 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ o When starting up and the device is connected, reset it somehow. If stuff
fails the next run will fail with a timeout. - Trygve

o Add a ctrl-c handler which shuts down all transfers and closes libusb. - Trygve

o Create a .a/.so in addition to the main programs.
o Create a .so implementation of LogicInterface.h so that other can link
against our implementation.
o Create a deb/set of deb files and publish them so that people can
o Publish API documentation.
17 changes: 12 additions & 5 deletions slogic.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void slogic_read_samples_callback(struct libusb_transfer *transfer)
struct slogic_recording *recording = internal_recording->recording;
assert(stransfer);

if (internal_recording->recording->recording_state != RUNNING) {
if (internal_recording->done) {
/*
* This will happen if there was more incoming transfers when the
* callback wanted to stop recording. The outer method will handle
Expand Down Expand Up @@ -305,6 +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));

switch (transfer->status) {
default:
/* Make the compiler shut up */
Expand Down Expand Up @@ -389,6 +391,9 @@ void slogic_execute_recording(struct slogic_handle *handle, struct slogic_record
}
}

recording->recording_state = RUNNING;
internal_recording->done = false;

/* Switch the logic to streaming read mode */
/* KEJO: pause as in delay between samples.. */
fprintf(recording->debug_file, "pause=%d\n", recording->sample_rate->pause);
Expand Down Expand Up @@ -426,19 +431,21 @@ void slogic_execute_recording(struct slogic_handle *handle, struct slogic_record
}

if (internal_recording->recording->recording_state != COMPLETED_SUCCESSFULLY) {
fprintf(recording->debug_file, "FAIL!\n");
fprintf(recording->debug_file, "FAIL! recording_state=%d\n", internal_recording->recording->recording_state);
} else {
fprintf(recording->debug_file, "SUCCESS!\n");
}

fprintf(recording->debug_file, "Total number of samples read: %i\n", internal_recording->sample_count);
fprintf(recording->debug_file, "Total number of transfers: %i\n", internal_recording->transfer_counter);

fprintf(recording->debug_file, "Time elapsed: %ds %dus\n", (int)start.tv_sec, (int)start.tv_usec);
fprintf(recording->debug_file, "Time elapsed: %ds %dus\n", (int)end.tv_sec, (int)end.tv_usec);
int sec = end.tv_sec - start.tv_sec;
int usec = (end.tv_usec - start.tv_usec) / 1000;
fprintf(recording->debug_file, "Time elapsed: %ds %dms\n", sec, usec);
if(usec < 0) {
sec--;
usec = 1 - usec;
}
fprintf(recording->debug_file, "Time elapsed: %d.%03ds\n", sec, usec);

free_internal_recording(internal_recording);
}

0 comments on commit dba4693

Please sign in to comment.