summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/beacon/decode.pl48
-rw-r--r--tools/beacon/test.dat7
-rw-r--r--tools/dtmf/Makefile72
-rw-r--r--tools/dtmf/dtmftest.c212
-rwxr-xr-xtools/dtmf/soxdtmftest.sh64
5 files changed, 403 insertions, 0 deletions
diff --git a/tools/beacon/decode.pl b/tools/beacon/decode.pl
new file mode 100755
index 0000000..28bf82b
--- /dev/null
+++ b/tools/beacon/decode.pl
@@ -0,0 +1,48 @@
+#!/usr/bin/perl -w
+
+use strict;
+use MIME::Base32 qw( RFC );
+
+my @beacons;
+if(!$ARGV[0] || $ARGV[0] eq "-") {
+ @beacons = <STDIN>;
+} else {
+ open(my $fh, "<", $ARGV[0]) or die "Unable to open file " . $ARGV[0];
+ @beacons = <$fh>;
+ close($fh)
+}
+
+foreach(@beacons) {
+ my $beacon = $_;
+ $beacon =~ s/\s*$//g;
+ $beacon =~ s/^\s*//g;
+
+ if($beacon =~ /([^ ]+) ([A-Z2-7]{3}) ([A-Z2-7])/) {
+ my $preamble = $1;
+ my $cnt = $2;
+ my $checksum = $3;
+
+ my $cntval = unpack("n", MIME::Base32::decode($cnt . "=")) >> 1;
+ my $csval_recv = unpack("C", MIME::Base32::decode($checksum . "=")) >> 3;
+
+ my $csval_calc = ord('N') - ord(' ');
+ my @values = unpack("C*", $preamble);
+ @values = (@values, unpack("C*", $cnt));
+ foreach(@values) { $csval_calc ^= $_ - ord(' '); }
+ $csval_calc = ($csval_calc & 0x1F) ^ (($csval_calc & 0x20) >> 5);
+
+ print $beacon . " -> cnt: " . $cntval;
+ if($csval_calc != $csval_recv) {
+ print " checksom wrong! (" . sprintf("%02X", $csval_recv) . " vs. " . sprintf("%02X", $csval_calc) . ")\n";
+ } else {
+ print " checksom ok! (" . sprintf("%02X", $csval_recv) . ")\n";
+ }
+
+
+ } else {
+ print $beacon . " -> Beacon format error!\n";
+ }
+
+
+}
+
diff --git a/tools/beacon/test.dat b/tools/beacon/test.dat
new file mode 100644
index 0000000..3acc496
--- /dev/null
+++ b/tools/beacon/test.dat
@@ -0,0 +1,7 @@
+A OE6MUR FZO F
+A OE6MUR FZP 2
+A OE6MUR FZQ 3
+A OE6MUR FZR Y
+T OE6MUR FZK B
+A OE6MUR FZL G
+A OE6MUR FZM H \ No newline at end of file
diff --git a/tools/dtmf/Makefile b/tools/dtmf/Makefile
new file mode 100644
index 0000000..e3490d8
--- /dev/null
+++ b/tools/dtmf/Makefile
@@ -0,0 +1,72 @@
+##
+## mur.sat
+##
+## Somewhen in the year 2011, mur.at will have a nano satellite launched
+## into a low earth orbit (310 km above the surface of our planet). The
+## satellite itself is a TubeSat personal satellite kit, developed and
+## launched by interorbital systems. mur.sat is a joint venture of mur.at,
+## ESC im Labor and realraum.
+##
+## Please visit the project hompage at sat.mur.at for further information.
+##
+##
+## Copyright (C) 2011 Christian Pointner <equinox@mur.at>
+##
+## This file is part of mur.sat.
+##
+## mur.sat is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## any later version.
+##
+## mur.sat is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with mur.sat. If not, see <http://www.gnu.org/licenses/>.
+##
+
+GST_CFLAGS=$(shell pkg-config --cflags gstreamer-0.10)
+GST_LDFLAGS=$(shell pkg-config --libs gstreamer-0.10)
+
+CC := gcc
+CFLAGS := -g -O2 $(GST_CFLAGS)
+LDFLAGS := -g -Wall -O2 $(GST_LDFLAGS)
+STRIP := strip
+
+EXECUTABLE := dtmftest
+
+C_OBJS := dtmftest.o
+
+C_SRCS := $(C_OBJS:%.o=%.c)
+
+.PHONY: clean
+
+all: $(EXECUTABLE)
+
+%.d: %.c
+ @set -e; rm -f $@; \
+ $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$; echo '(re)building $@'
+
+ifneq ($(MAKECMDGOALS),distclean)
+-include $(C_SRCS:%.c=%.d)
+endif
+
+$(EXECUTABLE): $(C_OBJS)
+ $(CC) $(C_OBJS) -o $@ $(LDFLAGS)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<
+
+strip: $(EXECUTABLE)
+ $(STRIP) -s $(EXECUTABLE)
+
+clean:
+ rm -f *.o
+ rm -f *.d
+ rm -f *.d.*
+ rm -f $(EXECUTABLE)
diff --git a/tools/dtmf/dtmftest.c b/tools/dtmf/dtmftest.c
new file mode 100644
index 0000000..bc7adc1
--- /dev/null
+++ b/tools/dtmf/dtmftest.c
@@ -0,0 +1,212 @@
+/*
+ * mur.sat
+ *
+ * Somewhen in the year 2011, mur.at will have a nano satellite launched
+ * into a low earth orbit (310 km above the surface of our planet). The
+ * satellite itself is a TubeSat personal satellite kit, developed and
+ * launched by interorbital systems. mur.sat is a joint venture of mur.at,
+ * ESC im Labor and realraum.
+ *
+ * Please visit the project hompage at sat.mur.at for further information.
+ *
+ *
+ * Copyright (C) 2011 Christian Pointner <equinox@mur.at>
+ *
+ * This file is part of mur.sat.
+ *
+ * mur.sat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * mur.sat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with mur.sat. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <stdio.h>
+#include <gst/gst.h>
+#include <string.h>
+#include <errno.h>
+#include <termios.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
+{
+ GMainLoop *loop = (GMainLoop *) data;
+
+ switch (GST_MESSAGE_TYPE (msg)) {
+
+ case GST_MESSAGE_EOS:
+ g_print ("End of stream\n");
+ g_main_loop_quit (loop);
+ break;
+
+ case GST_MESSAGE_ERROR: {
+ gchar *debug;
+ GError *error;
+
+ gst_message_parse_error (msg, &error, &debug);
+ g_free (debug);
+
+ g_printerr ("Error: %s\n", error->message);
+ g_error_free (error);
+
+ g_main_loop_quit (loop);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+
+struct thread_param {
+ GstElement* element;
+ GMainLoop* loop;
+};
+
+static GThread *reader_thread;
+
+static gpointer reader_thread_func(gpointer data)
+{
+ struct thread_param* param = (struct thread_param *)data;
+
+ GMainLoop* loop = param->loop;
+ GstElement* element = param->element;
+ free(param);
+
+ printf("reader thread started\n");
+
+ struct termios tio;
+
+ tcgetattr(fileno(stdin), &tio);
+ tio.c_lflag &= ~ICANON;
+ tcsetattr(fileno(stdin), TCSANOW, &tio);
+
+ for(;;) {
+ char sign;
+
+ int ret = read(0, &sign, 1);
+ if(!ret) break;
+ if(ret < 0) {
+ printf("read error: %s", strerror(errno));
+ break;
+ }
+
+ int code = 0;
+ switch(sign) {
+ case '0': code = 0; break;
+ case '1': code = 1; break;
+ case '2': code = 2; break;
+ case '3': code = 3; break;
+ case '4': code = 4; break;
+ case '5': code = 5; break;
+ case '6': code = 6; break;
+ case '7': code = 7; break;
+ case '8': code = 8; break;
+ case '9': code = 9; break;
+ case '*': code = 10; break;
+ case '#': code = 11; break;
+ case 'a': code = 12; break;
+ case 'b': code = 13; break;
+ case 'c': code = 14; break;
+ case 'd': code = 15; break;
+ default: continue;
+ }
+
+ GstStructure* st = gst_structure_new ("dtmf-event", "type", G_TYPE_INT, 1, "number", G_TYPE_INT, code, "volume", G_TYPE_INT, 25, "start", G_TYPE_BOOLEAN, TRUE, NULL);
+ GstEvent* ev = gst_event_new_custom(GST_EVENT_CUSTOM_UPSTREAM, st);
+ gst_element_send_event(element, ev);
+
+ // sleep is useless
+ st = gst_structure_new ("dtmf-event", "type", G_TYPE_INT, 1, "number", G_TYPE_INT, code, "start", G_TYPE_BOOLEAN, FALSE, NULL);
+ ev = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, st);
+ gst_element_send_event(element, ev);
+ }
+
+ g_main_loop_quit(loop);
+ return NULL;
+}
+
+int init_code_reader(GMainLoop *loop, GstElement* element)
+{
+ g_assert(!reader_thread);
+
+ struct thread_param* p = malloc(sizeof(struct thread_param));
+ if(!p)
+ return -1;
+
+ p->element = element;
+ p->loop = loop;
+
+ reader_thread = g_thread_create(reader_thread_func, p, TRUE, NULL);
+ if(!reader_thread)
+ return -1;
+
+ return 0;
+}
+
+
+int main (int argc, char *argv[])
+{
+ GMainLoop *loop;
+
+ GstElement *pipeline, *source, *demuxer, *decoder, *conv, *sink;
+ GstBus *bus;
+
+ /* Initialisation */
+ gst_init (&argc, &argv);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ /* Create gstreamer elements */
+ pipeline = gst_pipeline_new ("dtmftest");
+ source = gst_element_factory_make ("dtmfsrc", "source");
+ sink = gst_element_factory_make ("autoaudiosink", "output");
+
+ if (!pipeline || !source || !sink) {
+ g_printerr ("One element could not be created. Exiting.\n");
+ return -1;
+ }
+
+ g_object_set(G_OBJECT (source), "interval", 10, NULL);
+
+ /* Set up the pipeline */
+
+ /* we add a message handler */
+ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+ gst_bus_add_watch (bus, bus_call, loop);
+ gst_object_unref (bus);
+
+ /* we add all elements into the pipeline */
+ /* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */
+ gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
+ gst_element_link_many (source, sink, NULL);
+
+ /* Set the pipeline to "playing" state*/
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+
+ init_code_reader(loop, pipeline);
+
+ /* Iterate */
+ g_print ("Running...\n");
+ g_main_loop_run (loop);
+
+
+ /* Out of the main loop, clean up nicely */
+ g_print ("Returned, stopping playback\n");
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+
+ g_print ("Deleting pipeline\n");
+ gst_object_unref (GST_OBJECT (pipeline));
+
+ return 0;
+}
diff --git a/tools/dtmf/soxdtmftest.sh b/tools/dtmf/soxdtmftest.sh
new file mode 100755
index 0000000..a67d97b
--- /dev/null
+++ b/tools/dtmf/soxdtmftest.sh
@@ -0,0 +1,64 @@
+#!/bin/zsh
+#
+# mur.sat
+#
+# Somewhen in the year 2011, mur.at will have a nano satellite launched
+# into a low earth orbit (310 km above the surface of our planet). The
+# satellite itself is a TubeSat personal satellite kit, developed and
+# launched by interorbital systems. mur.sat is a joint venture of mur.at,
+# ESC im Labor and realraum.
+#
+# Please visit the project hompage at sat.mur.at for further information.
+#
+#
+# Copyright (C) 2011 Bernhard Tittelbach <xro@realraum.at>
+#
+# This file is part of mur.sat.
+#
+# mur.sat is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# any later version.
+#
+# mur.sat is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with mur.sat. If not, see <http://www.gnu.org/licenses/>.
+#
+
+setopt extendedglob
+
+function killchilds
+{
+ for childspec (${jobstates}) print kill ${${childspec[(s/:/w)5]}%%\=*};
+}
+
+typeset -i DURATION=${1:-10}
+CMD="play -n synth $DURATION"
+while true; do
+ read -k 1 DIGIT
+ case $DIGIT in
+ 1) ${=CMD} sin 697 sin 1209 & ;;
+ 2) ${=CMD} sin 697 sin 1336 & ;;
+ 3) ${=CMD} sin 697 sin 1477 & ;;
+ 4) ${=CMD} sin 770 sin 1209 & ;;
+ 5) ${=CMD} sin 770 sin 1336 & ;;
+ 6) ${=CMD} sin 770 sin 1477 & ;;
+ 7) ${=CMD} sin 852 sin 1209 & ;;
+ 8) ${=CMD} sin 852 sin 1336 & ;;
+ 9) ${=CMD} sin 852 sin 1477 & ;;
+ 0) ${=CMD} sin 941 sin 1336 & ;;
+ '*') ${=CMD} sin 941 sin 1209 & ;;
+ '#') ${=CMD} sin 941 sin 1477 & ;;
+ a) ${=CMD} sin 697 sin 1633 & ;;
+ b) ${=CMD} sin 770 sin 1633 & ;;
+ c) ${=CMD} sin 852 sin 1633 & ;;
+ d) ${=CMD} sin 941 sin 1633 & ;;
+ s) killchilds ;;
+ ' ') killchilds ;;
+ q) killchilds; exit 0 ;;
+ esac
+done