Skip to content

Commit

Permalink
Added serial capture
Browse files Browse the repository at this point in the history
  • Loading branch information
Randy Sargent committed Feb 5, 2011
1 parent 1a7e411 commit 23f5baf
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 42 deletions.
50 changes: 8 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
DATE ?= 110205

ZEOS = $(wildcard *.zeo)
CSVS = $(patsubst %.zeo,%.hypnogram.csv,$(ZEOS))

all-csv: $(CSVS)

#%.zeo: hex/%.zeo
# ./hex2binary <$^ >$@

%.hypnogram.csv: %.zeo
./raw2csv.py $^

current: anne-$(DATE).hypnogram.csv

sync:
rsync -av john-2.local:/Users/anne/education/bodytrack/zeologger/raw-data/\*.zeo .

connect:
connect.sh anne-$(DATE).zeo

csv:
-./raw2csv.py -f anne-$(DATE).zeo

plot-follow:
echo "set datafile separator ','" > gnuplot.script
echo "set xdata time" >> gnuplot.script
echo "set timefmt '%m/%d/%Y %H:%M:%S'" >> gnuplot.script
echo "set format x '%H:%M:%S'" >> gnuplot.script
echo "plot 'anne-$(DATE).hypnogram.csv' every ::2 using 1:6" >> gnuplot.script
echo "! sleep 5" >> gnuplot.script
echo "reread" >> gnuplot.script
gnuplot gnuplot.script

plot:
echo "set datafile separator ','" > gnuplot.script
echo "set xdata time" >> gnuplot.script
echo "set timefmt '%m/%d/%Y %H:%M:%S'" >> gnuplot.script
echo "set format x '%H:%M:%S'" >> gnuplot.script
echo "plot 'anne-$(DATE).hypnogram.csv' every ::2 using 1:6" >> gnuplot.script
gnuplot -p gnuplot.script
BINARIES=hex2binary dump-serial
all: $(BINARIES)

dump-serial: dump-serial.cpp
g++ dump-serial.cpp -o dump-serial

hex2binary: hex2binary.c
gcc -Wall hex2binary.c -o hex2binary

# plot 'anne-110202.spectrogram.csv' every ::2 using 1:6 with lines title '2-4 Hz', 'anne-110202.spectrogram.csv' every ::2 using 1:7 with lines title '4-8 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:8 with lines title '8-13 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:9 with lines title '11-14 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:10 with lines title '13-18 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:11 with lines title '18-21 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:($12*10) with lines title "30-50 Hz (x10)" smooth bezier, 'anne-110202.hypnogram.csv' every ::2 using 1:($6*.1)
clean:
rm -f $(BINARIES)


24 changes: 24 additions & 0 deletions dump-serial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
char *filename = argv[1];
int fd = open(filename, O_RDONLY | O_NONBLOCK);
FILE *in= fdopen(fd, "r");

char buf[200];
sprintf(buf, "stty -f %s 38400 -crtscts", filename);
system(buf);
sprintf(buf, "stty -f %s", filename);
system(buf);

fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | ~O_NONBLOCK);

while (1) {
int c = getc(in);
putchar(c);
fflush(stdout);
}
}
50 changes: 50 additions & 0 deletions raw2csv/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
DATE ?= 110205

ZEOS = $(wildcard *.zeo)
CSVS = $(patsubst %.zeo,%.hypnogram.csv,$(ZEOS))

all-csv: $(CSVS)

#%.zeo: hex/%.zeo
# ./hex2binary <$^ >$@

%.hypnogram.csv: %.zeo
./raw2csv.py $^

current: anne-$(DATE).hypnogram.csv

sync:
rsync -av john-2.local:/Users/anne/education/bodytrack/zeologger/raw-data/\*.zeo .

connect:
connect.sh anne-$(DATE).zeo

csv:
-./raw2csv.py -f anne-$(DATE).zeo

plot-follow:
echo "set datafile separator ','" > gnuplot.script
echo "set xdata time" >> gnuplot.script
echo "set timefmt '%m/%d/%Y %H:%M:%S'" >> gnuplot.script
echo "set format x '%H:%M:%S'" >> gnuplot.script
echo "plot 'anne-$(DATE).hypnogram.csv' every ::2 using 1:6" >> gnuplot.script
echo "! sleep 5" >> gnuplot.script
echo "reread" >> gnuplot.script
gnuplot gnuplot.script

plot:
echo "set datafile separator ','" > gnuplot.script
echo "set xdata time" >> gnuplot.script
echo "set timefmt '%m/%d/%Y %H:%M:%S'" >> gnuplot.script
echo "set format x '%H:%M:%S'" >> gnuplot.script
echo "plot 'anne-$(DATE).hypnogram.csv' every ::2 using 1:6" >> gnuplot.script
gnuplot -p gnuplot.script


hex2binary: hex2binary.c
gcc -Wall hex2binary.c -o hex2binary

clean:
rm hex2binary

# plot 'anne-110202.spectrogram.csv' every ::2 using 1:6 with lines title '2-4 Hz', 'anne-110202.spectrogram.csv' every ::2 using 1:7 with lines title '4-8 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:8 with lines title '8-13 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:9 with lines title '11-14 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:10 with lines title '13-18 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:11 with lines title '18-21 Hz' smooth bezier, 'anne-110202.spectrogram.csv' every ::2 using 1:($12*10) with lines title "30-50 Hz (x10)" smooth bezier, 'anne-110202.hypnogram.csv' every ::2 using 1:($6*.1)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 23f5baf

Please sign in to comment.