mirror of
https://agent.ghink.cloud/wb2osz/direwolf
synced 2025-04-08 15:48:35 +00:00
Changes to be committed: modified: .gitattributes modified: CHANGES.md modified: Makefile modified: Makefile.linux new file: Makefile.macosx modified: Makefile.win modified: aclients.c modified: aprs_tt.c modified: aprs_tt.h modified: atest.c modified: audio.c modified: audio.h new file: audio_portaudio.c new file: audio_stats.c new file: audio_stats.h modified: audio_win.c modified: ax25_pad.c modified: ax25_pad.h modified: beacon.c modified: config.c modified: config.h modified: decode_aprs.c modified: decode_aprs.h modified: demod.c modified: digipeater.c modified: direwolf.c modified: direwolf.h modified: dlq.c modified: doc/README.md modified: doc/Raspberry-Pi-APRS.pdf modified: doc/User-Guide.pdf new file: doc/WA8LMF-TNC-Test-CD-Results.pdf modified: dtime_now.c modified: dtmf.c modified: dw-start.sh modified: encode_aprs.c modified: encode_aprs.h modified: gen_packets.c modified: gen_tone.c modified: gen_tone.h new file: generic.conf modified: grm_sym.h modified: hdlc_rec.c modified: hdlc_rec.h modified: igate.c modified: kiss.c modified: kiss_frame.c modified: kissnet.c modified: latlong.c modified: man1/direwolf.1 modified: mgn_icon.h modified: misc/README-dire-wolf.txt new file: misc/strlcat.c new file: misc/strlcpy.c modified: morse.c new file: morse.h modified: nmea.c modified: pfilter.c modified: ptt.c new file: serial_port.c new file: serial_port.h modified: server.c modified: symbols.c modified: symbols.h new file: telemetry-toolkit/telem-balloon.conf new file: telemetry-toolkit/telem-balloon.pl new file: telemetry-toolkit/telem-bits.pl new file: telemetry-toolkit/telem-data.pl new file: telemetry-toolkit/telem-data91.pl new file: telemetry-toolkit/telem-eqns.pl new file: telemetry-toolkit/telem-m0xer-3.txt new file: telemetry-toolkit/telem-parm.pl new file: telemetry-toolkit/telem-unit.pl new file: telemetry-toolkit/telem-volts.conf new file: telemetry-toolkit/telem-volts.py modified: telemetry.c modified: textcolor.c modified: tq.c modified: tt_text.c modified: tt_text.h modified: tt_user.c modified: tt_user.h modified: utm2ll.c modified: version.h new file: walk96.c modified: xmit.c
181 lines
4.1 KiB
C
181 lines
4.1 KiB
C
//
|
|
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
|
//
|
|
// Copyright (C) 2015 John Langner, WB2OSZ
|
|
//
|
|
// This program 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 2 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
//
|
|
|
|
|
|
//#define DEBUG 1
|
|
|
|
/*------------------------------------------------------------------
|
|
*
|
|
* Module: walk96.c
|
|
*
|
|
* Purpose: Quick hack to read GPS location and send very frequent
|
|
* position reports frames to a KISS TNC.
|
|
*
|
|
*
|
|
*---------------------------------------------------------------*/
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
#if __WIN32__
|
|
#include <stdlib.h>
|
|
#include <windows.h>
|
|
#else
|
|
#define __USE_XOPEN2KXSI 1
|
|
#define __USE_XOPEN 1
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <fcntl.h>
|
|
#include <termios.h>
|
|
#include <sys/types.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/errno.h>
|
|
#endif
|
|
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
|
|
#include "direwolf.h"
|
|
#include "config.h"
|
|
#include "ax25_pad.h"
|
|
#include "textcolor.h"
|
|
#include "latlong.h"
|
|
#include "nmea.h"
|
|
#include "encode_aprs.h"
|
|
#include "serial_port.h"
|
|
|
|
|
|
#define MYCALL "WB2OSZ" /************ Change this if you use it!!! ***************/
|
|
|
|
static MYFDTYPE tnc;
|
|
|
|
|
|
main (int argc, char *argv[])
|
|
{
|
|
struct misc_config_s config;
|
|
char cmd[100];
|
|
|
|
|
|
// Look for Silicon Labs CP210x
|
|
// Just happens to be same on desktop & laptop.
|
|
|
|
tnc = serial_port_open ("COM5", 9600);
|
|
if (tnc == MYFDERROR) {
|
|
text_color_set (DW_COLOR_ERROR);
|
|
dw_printf ("Can't open serial port to KISS TNC.\n");
|
|
exit (EXIT_FAILURE); // defined in stdlib.h
|
|
}
|
|
|
|
strcpy (cmd, "\r\rhbaud 9600\rkiss on\rrestart\r");
|
|
|
|
serial_port_write (tnc, cmd, strlen(cmd));
|
|
SLEEP_MS(500);
|
|
|
|
memset (&config, 0, sizeof(config));
|
|
strcpy (config.nmea_port, "COM1");
|
|
nmea_init (&config);
|
|
|
|
SLEEP_SEC(20);
|
|
|
|
// Exit out of KISS mode.
|
|
|
|
serial_port_write (tnc, "\xc0\xff\c0", 3);
|
|
|
|
SLEEP_MS(100);
|
|
|
|
}
|
|
|
|
|
|
/* Should be called once per second. */
|
|
|
|
void walk96 (int fix, double lat, double lon, float knots, float course, float alt)
|
|
{
|
|
static int sequence = 0;
|
|
char comment[50];
|
|
|
|
sequence++;
|
|
sprintf (comment, "Sequence number %04d", sequence);
|
|
|
|
|
|
/*
|
|
* Construct the packet in normal monitoring format.
|
|
*/
|
|
|
|
int messaging = 0;
|
|
int compressed = 0;
|
|
|
|
char info[AX25_MAX_INFO_LEN];
|
|
int info_len;
|
|
|
|
char position_report[AX25_MAX_PACKET_LEN];
|
|
|
|
info_len = encode_position (messaging, compressed,
|
|
lat, lon, (int)(DW_METERS_TO_FEET(alt)),
|
|
'/', '?', // TODO: look up code for person.
|
|
G_UNKNOWN, G_UNKNOWN, G_UNKNOWN, "", // PHG
|
|
(int)course, (int)knots,
|
|
445.925, 0, 0,
|
|
comment,
|
|
info, sizeof(info));
|
|
|
|
sprintf (position_report, "%s>WALK96:%s", MYCALL, info);
|
|
|
|
text_color_set (DW_COLOR_XMIT);
|
|
dw_printf ("%s\n", position_report);
|
|
|
|
/*
|
|
* Convert it into AX.25 frame.
|
|
*/
|
|
packet_t pp;
|
|
unsigned char ax25_frame[AX25_MAX_PACKET_LEN];
|
|
int frame_len;
|
|
|
|
pp = ax25_from_text (position_report, 1);
|
|
|
|
if (pp == NULL) {
|
|
text_color_set (DW_COLOR_ERROR);
|
|
dw_printf ("Unexpected error in ax25_from_text. Quitting.\n");
|
|
exit (EXIT_FAILURE); // defined in stdlib.h
|
|
}
|
|
|
|
ax25_frame[0] = 0; // Insert channel before KISS encapsulation.
|
|
|
|
frame_len = ax25_pack (pp, ax25_frame+1);
|
|
ax25_delete (pp);
|
|
|
|
/*
|
|
* Encapsulate as KISS and send to TNC.
|
|
*/
|
|
|
|
unsigned char kiss_frame[AX25_MAX_PACKET_LEN*2];
|
|
int kiss_len;
|
|
|
|
kiss_len = kiss_encapsulate (ax25_frame, frame_len+1, (unsigned char *)kiss_frame);
|
|
|
|
//text_color_set (DW_COLOR_DEBUG);
|
|
//dw_printf ("AX.25 frame length = %d, KISS frame length = %d\n", frame_len, kiss_len);
|
|
|
|
//kiss_debug_print (1, NULL, kiss_frame, kiss_len);
|
|
|
|
serial_port_write (tnc, kiss_frame, kiss_len);
|
|
|
|
}
|
|
|
|
/* end walk96.c */
|