|
2 | 2 | //
|
3 | 3 | // This file is part of Dire Wolf, an amateur radio packet TNC.
|
4 | 4 | //
|
5 |
| -// Copyright (C) 2011, 2013, 2014, 2015, 2016 John Langner, WB2OSZ |
| 5 | +// Copyright (C) 2011, 2013, 2014, 2015, 2016, 2017 John Langner, WB2OSZ |
6 | 6 | //
|
7 | 7 | // This program is free software: you can redistribute it and/or modify
|
8 | 8 | // it under the terms of the GNU General Public License as published by
|
@@ -101,6 +101,8 @@ static int xmit_txtail[MAX_CHANS]; /* Amount of time to keep transmitting after
|
101 | 101 | /* dropping PTT too soon and chopping off the end */
|
102 | 102 | /* of the frame. Again 10 mS units. */
|
103 | 103 |
|
| 104 | +static int xmit_fulldup[MAX_CHANS]; /* Full duplex if non-zero. */ |
| 105 | + |
104 | 106 | static int xmit_bits_per_sec[MAX_CHANS]; /* Data transmission rate. */
|
105 | 107 | /* Often called baud rate which is equivalent in */
|
106 | 108 | /* this case but could be different with other */
|
@@ -137,7 +139,7 @@ static dw_mutex_t audio_out_dev_mutex[MAX_ADEVS];
|
137 | 139 |
|
138 | 140 |
|
139 | 141 |
|
140 |
| -static int wait_for_clear_channel (int channel, int slotttime, int persist); |
| 142 | +static int wait_for_clear_channel (int channel, int slotttime, int persist, int fulldup); |
141 | 143 | static void xmit_ax25_frames (int c, int p, packet_t pp, int max_bundle);
|
142 | 144 | static int send_one_frame (int c, int p, packet_t pp);
|
143 | 145 | static void xmit_speech (int c, packet_t pp);
|
@@ -218,6 +220,7 @@ void xmit_init (struct audio_s *p_modem, int debug_xmit_packet)
|
218 | 220 | xmit_persist[j] = p_modem->achan[j].persist;
|
219 | 221 | xmit_txdelay[j] = p_modem->achan[j].txdelay;
|
220 | 222 | xmit_txtail[j] = p_modem->achan[j].txtail;
|
| 223 | + xmit_fulldup[j] = p_modem->achan[j].fulldup; |
221 | 224 | }
|
222 | 225 |
|
223 | 226 | #if DEBUG
|
@@ -306,6 +309,7 @@ void xmit_init (struct audio_s *p_modem, int debug_xmit_packet)
|
306 | 309 | * xmit_set_persist
|
307 | 310 | * xmit_set_slottime
|
308 | 311 | * xmit_set_txtail
|
| 312 | + * xmit_set_fulldup |
309 | 313 | *
|
310 | 314 | *
|
311 | 315 | * Purpose: The KISS protocol, and maybe others, can specify
|
@@ -355,6 +359,13 @@ void xmit_set_txtail (int channel, int value)
|
355 | 359 | }
|
356 | 360 | }
|
357 | 361 |
|
| 362 | +void xmit_set_fulldup (int channel, int value) |
| 363 | +{ |
| 364 | + if (channel >= 0 && channel < MAX_CHANS) { |
| 365 | + xmit_fulldup[channel] = value; |
| 366 | + } |
| 367 | +} |
| 368 | + |
358 | 369 |
|
359 | 370 | /*-------------------------------------------------------------------
|
360 | 371 | *
|
@@ -490,7 +501,7 @@ static void * xmit_thread (void *arg)
|
490 | 501 | * If there is something in the high priority queue, begin transmitting immediately.
|
491 | 502 | * Otherwise, wait a random amount of time, in hopes of minimizing collisions.
|
492 | 503 | */
|
493 |
| - ok = wait_for_clear_channel (chan, xmit_slottime[chan], xmit_persist[chan]); |
| 504 | + ok = wait_for_clear_channel (chan, xmit_slottime[chan], xmit_persist[chan], xmit_fulldup[chan]); |
494 | 505 |
|
495 | 506 | prio = TQ_PRIO_1_LO;
|
496 | 507 | pp = tq_remove (chan, TQ_PRIO_0_HI);
|
@@ -670,6 +681,8 @@ static void * xmit_thread (void *arg)
|
670 | 681 | * Once we have control of the channel, we might as well keep going.
|
671 | 682 | * [High] Priority frames will always go to head of the line,
|
672 | 683 | *
|
| 684 | + * Version 1.5: Add full duplex option. |
| 685 | + * |
673 | 686 | *--------------------------------------------------------------------*/
|
674 | 687 |
|
675 | 688 |
|
@@ -1231,12 +1244,19 @@ static void xmit_dtmf (int c, packet_t pp, int speed)
|
1231 | 1244 | * slottime - Amount of time to wait for each iteration
|
1232 | 1245 | * of the waiting algorithm. 10 mSec units.
|
1233 | 1246 | *
|
1234 |
| - * persist - Probability of transmitting |
| 1247 | + * persist - Probability of transmitting. |
| 1248 | + * |
| 1249 | + * fulldup - Full duplex. Just start sending immediately. |
1235 | 1250 | *
|
1236 | 1251 | * Returns: 1 for OK. 0 for timeout.
|
1237 | 1252 | *
|
1238 | 1253 | * Description: New in version 1.2: also obtain a lock on audio out device.
|
1239 | 1254 | *
|
| 1255 | + * New in version 1.5: full duplex. |
| 1256 | + * Just start transmitting rather than waiting for clear channel. |
| 1257 | + * This would only be appropriate when transmit and receive are |
| 1258 | + * using different radio freqencies. e.g. VHF up, UHF down satellite. |
| 1259 | + * |
1240 | 1260 | * Transmit delay algorithm:
|
1241 | 1261 | *
|
1242 | 1262 | * Wait for channel to be clear.
|
@@ -1271,10 +1291,17 @@ static void xmit_dtmf (int c, packet_t pp, int speed)
|
1271 | 1291 | #define WAIT_TIMEOUT_MS (60 * 1000)
|
1272 | 1292 | #define WAIT_CHECK_EVERY_MS 10
|
1273 | 1293 |
|
1274 |
| -static int wait_for_clear_channel (int chan, int slottime, int persist) |
| 1294 | +static int wait_for_clear_channel (int chan, int slottime, int persist, int fulldup) |
1275 | 1295 | {
|
1276 | 1296 | int n = 0;
|
1277 | 1297 |
|
| 1298 | +/* |
| 1299 | + * For dull duplex we skip the channel busy check and random wait. |
| 1300 | + * We still need to wait if operating in stereo and the other audio |
| 1301 | + * half is busy. |
| 1302 | + */ |
| 1303 | + if ( ! fulldup) { |
| 1304 | + |
1278 | 1305 | start_over_again:
|
1279 | 1306 |
|
1280 | 1307 | while (hdlc_rec_data_detect_any(chan)) {
|
@@ -1318,6 +1345,7 @@ static int wait_for_clear_channel (int chan, int slottime, int persist)
|
1318 | 1345 | break;
|
1319 | 1346 | }
|
1320 | 1347 | }
|
| 1348 | + } |
1321 | 1349 |
|
1322 | 1350 | /*
|
1323 | 1351 | * This is to prevent two channels from transmitting at the same time
|
|
0 commit comments