File: tolerant_ack

package info (click to toggle)
owx 0~20110415-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch, wheezy
  • size: 300 kB
  • ctags: 208
  • sloc: cpp: 1,253; sh: 111; makefile: 53
file content (43 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Description: be more tolerant when opening the radio
 I had to apply this patch to restore access to my radio when it was
 refusing to open with errors like:
 .
 owx: Invalid ACK char received: 0x4B
 .
 I had other errors codes like 0x36, 0x39, 0x47, 0x56, and the patch
 that made me recover wasn't *exactly* this patch (it wasn't using
 exceptions) but this should work.
Origin: debian
Forwarded: no
Reviewed-By: Antoine Beaupré <anarcat@koumbit.org>
Last-Update: 2011-11-27

diff --git a/src/wouxun.cc b/src/wouxun.cc
index e4ecee0..c7260c7 100644
--- a/src/wouxun.cc
+++ b/src/wouxun.cc
@@ -1,5 +1,6 @@
 /* $Id$ */
 
+#include <stdexcept>
 #include <cstring>
 #include <cstdio>
 #include "owxendian.h"
@@ -33,7 +34,16 @@ void CWouxun::Open()
 	RecvAck(true);
 
 	m_comm.SendChar(0x02);
-	RecvAck();
+	try
+	{
+		RecvAck();
+	}
+	catch (const std::logic_error &e)
+	{
+		// this can return the wrong error codes in some weird
+		// situations but it will still work so just print a warning
+		fprintf(stderr, "Warning: %s\n", e.what());
+	};
 
 	char buf[7];
 	m_comm.Recv(buf, sizeof(buf));