This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rpi' of localhost:/home/git/sensorgnome into rpi
- Loading branch information
Showing
49 changed files
with
12,472 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
get_clocks: get_clocks.c | ||
gcc -O3 -o get_clocks get_clocks.c -lrt | ||
strip get_clocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"info": "default deployment", | ||
"who": "who is responsible for this deployment", | ||
"contact": "contact information for responsible party", | ||
"shortLabel": "SG1", | ||
"acquire": { | ||
"gps": { | ||
"secondsBetweenFixes": 300 | ||
}, | ||
"USB": { | ||
"portInfo": [ | ||
"info for USB hub port 1", | ||
"info for USB hub port 2", | ||
"info for USB hub port 3", | ||
"info for USB hub port 4", | ||
"info for USB hub port 5", | ||
"info for USB hub port 6", | ||
"info for USB hub port 7", | ||
"info for USB hub port 8", | ||
"info for USB hub port 9", | ||
"info for USB hub port 10" | ||
], | ||
"portLabel": [ | ||
"p1", | ||
"p2", | ||
"p3", | ||
"p4", | ||
"p5", | ||
"p6", | ||
"p7", | ||
"p8", | ||
"p9", | ||
"p10" | ||
] | ||
}, | ||
"plans": [ | ||
{ | ||
"key": { | ||
"port": ".*", | ||
"devType": "funcube.*" | ||
}, | ||
"rate": 48000, | ||
"channels": 2, | ||
"schedule": { | ||
"type": "AlwaysOn" | ||
}, | ||
"devParams": [ | ||
{ | ||
"name": "frequency", | ||
"schedule": { | ||
"type": "Constant", | ||
"value": 166.376 | ||
} | ||
} | ||
], | ||
"raw": { | ||
"enabled": false, | ||
"chunkMinutes": 1 | ||
}, | ||
"plugins": [ | ||
{ | ||
"library": "lotek-plugins.so", | ||
"name": "findpulsefdbatch", | ||
"outputID": "pulses", | ||
"params": [ | ||
{ | ||
"name": "plen", | ||
"value": 2.5 | ||
}, | ||
{ | ||
"name": "minfreq", | ||
"value": 2 | ||
}, | ||
{ | ||
"name": "maxfreq", | ||
"value": 24 | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"key": { | ||
"port": ".*", | ||
"devType": "usbAudio" | ||
}, | ||
"rate": 48000, | ||
"channels": 1, | ||
"schedule": { | ||
"type": "AlwaysOn" | ||
}, | ||
"raw": { | ||
"enabled": true, | ||
"chunkMinutes": 60 | ||
} | ||
} | ||
] | ||
}, | ||
"module_options": { | ||
"find_tags": { | ||
"params": [ | ||
"--default-freq", 166.380, | ||
"--pulse-slop", 1.5 | ||
], | ||
"enabled": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
SensorGnome policies on event callbacks and timer chains | ||
(notes by a javascript newbie) | ||
|
||
* SensorGnome's Matron object (singleton instance is "TheMatron"). | ||
TheMatron is the central event emitter, which is handy for debugging. | ||
|
||
* Policy for event handlers requiring 'this': Use prototype methods, | ||
bind to this in constructor to make a closure, then pass the closure; | ||
this simplifies debugging, and avoids duplicating method code for | ||
every object (as private methods do). | ||
|
||
Example. | ||
To handle event "eventName" from object "EmitObj" | ||
// handler: | ||
MyClass.prototype.eventName = function(...) { | ||
stuff using "this" | ||
} | ||
|
||
// closure: | ||
in Myclass constructor, | ||
this.this_eventName = this.eventName.bind(this); | ||
|
||
// registration: | ||
EmitObj.on("eventName", this.this_eventName); | ||
|
||
* Bind: only use "this.XXX.bind(this)" in the constructor of | ||
an object, as shown above. | ||
|
||
* Policy for setTimeout loops: | ||
i.e. where a callback from setTimeout eventually calls setTimeout with | ||
the same callback. Use an extra "self" parameter to setTimout; don't use | ||
bind or anonymous functions as this will leak memory (fast!). | ||
|
||
Suppose method "onTimer" is called by a timeout, and that eventually | ||
leads to another timeout being set on "onTimer" (perhaps in another | ||
method). | ||
|
||
Here's how to do this: | ||
MyClass = function() { | ||
var self = this | ||
... | ||
// handler | ||
MyClass.prototype.onTimer = function(self, args) { | ||
// stuff using self and args | ||
// | ||
// inside the method which sets the timeout | ||
setTimeout (self.onTimer, delay, self); | ||
|
||
* Events | ||
The events listed here are mainly emitted via the Matron object's public emit() method, but can be | ||
be listened for by anyone. | ||
|
||
** devAdded | ||
*** args = [dev] | ||
dev = { | ||
path: // path_to_device, | ||
attr:{ | ||
type: // device type | ||
port: // usb hub port number | ||
usbPath: // libusb-style path to device in form "x:y" | ||
alsaDev: // ALSA device number | ||
stat: // fs.fileStat output for path | ||
} | ||
} | ||
*** emitters: | ||
**** HubMan | ||
when device added to watched dir (e.g. "/dev/sensorgnome") | ||
*** listeners: | ||
**** Matron | ||
- consult Deployment for a plan; if found, create an appropriate device object with | ||
the first found plan | ||
**** GPS | ||
- set baud rate for device, | ||
- if successful, open the device for reading and begin reading and parsing fixes | ||
|
||
** devRemoved | ||
*** args = [dev] | ||
dev = same arg as when "devAdded" was emitted for the device | ||
*** emitters: | ||
**** HubMan | ||
when device removed from watched dir | ||
*** listeners: | ||
**** GPS | ||
shut down the reader for the device | ||
**** usbAudio | ||
- tell VAH to close device | ||
|
||
** devStalled | ||
*** args = [vahDev] | ||
vahDev: label of VAH device as given by its vahOpen event | ||
|
||
*** emitters: | ||
**** VAH when receiving a JSON message on stderr of vamp-alsa-host | ||
** vahOpen | ||
*** args = [devPar, callback, callbackParams] | ||
- devPar = { | ||
port: usb port of device | ||
dev: ALSA device name (e.g. "hw:0") | ||
rate: the hardware sampling rate to request from the device | ||
channels: the number of channels (mono=1 or stereo=2) we want | ||
} | ||
- callback: function which receives the JSON reply object | ||
from vamp-alsa-host | ||
- callbackParams: additional parameter object passed to callback after | ||
the reply object | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
Repeatedly get values of realtime and monotonic clocks with microsecond | ||
precision as a JSON string of the form | ||
{"real":XXX.XXXXXX,"mono":YYY.YYYYYY} | ||
Each time a character is read from stdin, the time is read and a JSON | ||
string is written to stdout, which is then flushed. | ||
If an error occurs on reading stdin, get_clocks terminates. | ||
If started with an argument, that is assumed to be the filename of a PPS | ||
signal hardware line, and the realtime and monotonic clocks for that PPS | ||
signal are also output. | ||
Author: John Brzustowski | ||
Licence: public domain | ||
*/ | ||
#include <time.h> | ||
#include <stdio.h> | ||
#include <poll.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <fcntl.h> | ||
|
||
main (int argc, char *argv[]) { | ||
struct timespec tmm, tmr, ppsm, ppsr; | ||
double real, mono, ppsreal, ppsmono; | ||
struct pollfd pollFDs[2]; | ||
int numFD = 0; | ||
int i; | ||
int rv; | ||
char buf; | ||
|
||
pollFDs[numFD].fd = fileno(stdin); | ||
pollFDs[numFD++].events = POLLIN; | ||
if (argc > 1) { | ||
pollFDs[numFD].fd = open(argv[1], O_RDONLY); | ||
pollFDs[numFD++].events = POLLPRI; | ||
} | ||
|
||
for (;;) { | ||
rv=poll(pollFDs, numFD, -1); | ||
printf("Poll returned %d\n", rv); | ||
if (pollFDs[0].revents & (POLLERR | POLLHUP)) | ||
break; | ||
if (numFD > 1 && pollFDs[1].revents & POLLPRI) { | ||
clock_gettime(CLOCK_MONOTONIC, &ppsm); | ||
clock_gettime(CLOCK_REALTIME, &ppsr); | ||
ppsreal = ppsr.tv_sec + ppsr.tv_nsec / 1.0e9; | ||
ppsmono = ppsm.tv_sec + ppsm.tv_nsec / 1.0e9; | ||
lseek(pollFDs[1].fd, 0, SEEK_SET); | ||
read(pollFDs[1].fd, &buf, 1); | ||
printf("Got PPS and read of %c\n", buf); | ||
}; | ||
if (pollFDs[0].revents & POLLIN) { | ||
clock_gettime(CLOCK_MONOTONIC, &tmm); | ||
clock_gettime(CLOCK_REALTIME, &tmr); | ||
real = tmr.tv_sec + tmr.tv_nsec / 1.0e9; | ||
mono = tmm.tv_sec + tmm.tv_nsec / 1.0e9; | ||
} | ||
if (numFD > 1) { | ||
printf("{\"real\":%.6lf, \"mono\":%.6lf, \"ppsreal:\":%.6lf, \"ppsmono\":%.6lf}\n", real, mono, ppsreal, ppsmono); | ||
} else { | ||
printf("{\"real\":%.6lf, \"mono\":%.6lf}\n", real, mono); | ||
} | ||
fflush(stdout); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.