grub2/0127-Improve-spkmomdem-reliability-by-adding-a-separator-.patch
2013-05-02 16:54:52 -04:00

77 lines
1.9 KiB
Diff

From 966ef4a54d21d846304a7eafa125574a28f68caf Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Mon, 21 Jan 2013 14:55:30 +0100
Subject: [PATCH 127/364] Improve spkmomdem reliability by adding a
separator between bytes.
---
ChangeLog | 4 ++++
util/spkmodem-recv.c | 11 ++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ff29177..3c7552b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-21 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Improve spkmomdem reliability by adding a separator between bytes.
+
2013-01-21 Colin Watson <cjwatson@ubuntu.com>
* grub-core/partmap/msdos.c (embed_signatures): Add the signature of
diff --git a/util/spkmodem-recv.c b/util/spkmodem-recv.c
index 9075f9a..9083c1a 100644
--- a/util/spkmodem-recv.c
+++ b/util/spkmodem-recv.c
@@ -24,7 +24,7 @@
/* Usage: parecord --channels=1 --rate=48000 --format=s16le | ./spkmodem-recv */
#define SAMPLES_PER_TRAME 240
-#define FREQ_SEP_MIN 6
+#define FREQ_SEP_MIN 5
#define FREQ_SEP_MAX 15
#define FREQ_DATA_MIN 15
#define FREQ_DATA_THRESHOLD 25
@@ -32,6 +32,7 @@
#define THRESHOLD 500
#define DEBUG 0
+#define FLUSH_TIMEOUT 1
static signed short trame[2 * SAMPLES_PER_TRAME];
static signed short pulse[2 * SAMPLES_PER_TRAME];
@@ -70,15 +71,18 @@ main ()
int bitn = 7;
char c = 0;
int i;
+ int llp = 0;
while (!feof (stdin))
{
- if (lp > 20000)
+ if (lp > 3 * SAMPLES_PER_TRAME)
{
- fflush (stdout);
bitn = 7;
c = 0;
lp = 0;
+ llp++;
}
+ if (llp == FLUSH_TIMEOUT)
+ fflush (stdout);
if (f2 > FREQ_SEP_MIN && f2 < FREQ_SEP_MAX
&& f1 > FREQ_DATA_MIN && f1 < FREQ_DATA_MAX)
{
@@ -100,6 +104,7 @@ main ()
c = 0;
}
lp = 0;
+ llp = 0;
for (i = 0; i < SAMPLES_PER_TRAME; i++)
read_sample ();
continue;
--
1.8.1.4