1 // ----------------------------------------------------------------------------
2 // NULLMODEM.cxx  --  NULLMODEM modem
3 //
4 // Copyright (C) 2006
5 //		Dave Freese, W1HKJ
6 //
7 // This file is part of fldigi.  Adapted from code contained in gMFSK source code
8 // distribution.
9 //  gMFSK Copyright (C) 2001, 2002, 2003
10 //  Tomi Manninen (oh2bns@sral.fi)
11 //
12 // Fldigi is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // Fldigi is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with fldigi.  If not, see <http://www.gnu.org/licenses/>.
24 // ----------------------------------------------------------------------------
25 
26 #include <config.h>
27 
28 #include <stdlib.h>
29 #include <iostream>
30 
31 #include "nullmodem.h"
32 #include "fl_digi.h"
33 #include "ascii.h"
34 
35 #define null_bw 1
36 
37 // a NULLMODEM and will be instantiated before the dynamic member wf,
38 // digiscope, and fl_digi_main, the main dialog
39 
NULLMODEM()40 NULLMODEM:: NULLMODEM() : modem()
41 {
42 	mode = MODE_NULL;
43 	samplerate = 8000;
44 	restart();
45 }
46 
~NULLMODEM()47 NULLMODEM::~NULLMODEM() {};
48 
tx_init()49 void  NULLMODEM::tx_init()
50 {
51 }
52 
rx_init()53 void  NULLMODEM::rx_init()
54 {
55 	if (fl_digi_main)
56 		put_MODEstatus(mode);
57 }
58 
init()59 void NULLMODEM::init()
60 {
61 	modem::init();
62 	rx_init();
63 	if (digiscope)
64 		digiscope->mode(Digiscope::SCOPE);
65 }
66 
restart()67 void NULLMODEM::restart()
68 {
69 	if (wf) set_bandwidth(null_bw);
70 }
71 
72 
73 //=====================================================================
74 // receive processing
75 //=====================================================================
76 
rx_process(const double * buf,int len)77 int NULLMODEM::rx_process(const double *buf, int len)
78 {
79 	return 0;
80 }
81 
82 //=====================================================================
83 // transmit processing
84 //=====================================================================
85 
86 
tx_process()87 int NULLMODEM::tx_process()
88 {
89 	modem::tx_process();
90 
91 	MilliSleep(10);
92 	if (!fl_digi_main) {
93 		return 0;
94 	}
95 
96 	int c = get_tx_char();
97 	if (c == GET_TX_CHAR_ETX) {
98 		stopflag = false;
99 		return -1;
100 	}
101 	if ( stopflag ) {
102 		stopflag = false;
103 		return -1;
104 	}
105 	return 0;
106 }
107 
108