replaced nanosleep with std::this_thread::sleep_for

pull/1/head
Tom Early 8 years ago
parent 32afce0de3
commit ae312549ab

@ -1,5 +1,5 @@
/*
* Copyright 2017 by Thomas Early, N7TAE
* Copyright 2017-2018 by Thomas Early, N7TAE
*
* 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
@ -24,6 +24,8 @@
#include <termios.h>
#include <time.h>
#include <sys/file.h>
#include <sys/select.h>
#include "DVAPDongle.h"
extern void traceit(const char *fmt,...);

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Thomas A. Early N7TAE
* Copyright (C) 2016-2018 by Thomas A. Early N7TAE
*
* 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
@ -24,6 +24,9 @@
#include <netdb.h>
#include <netinet/tcp.h>
#include <thread>
#include <chrono>
#include "aprs.h"
// This is called when header comes in from repeater
@ -253,8 +256,6 @@ unsigned int CAPRS::GetData(short int rptr_idx, unsigned char *data, unsigned in
void CAPRS::Open(const std::string OWNER)
{
struct timespec req;
fd_set fdset;
struct timeval tv;
short int MAX_WAIT = 15; /* 15 seconds wait time MAX */
@ -356,9 +357,7 @@ void CAPRS::Open(const std::string OWNER)
if (rc < 0) {
if (errno == EWOULDBLOCK) {
recv(aprs_sock, rcv_buf, sizeof(rcv_buf), 0);
req.tv_sec = 0;
req.tv_nsec = 100000000; // 100 milli
nanosleep(&req, NULL);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
} else {
traceit("APRS login command failed, error=%d\n", errno);
break;

@ -32,7 +32,6 @@
#include <fcntl.h>
#include <arpa/inet.h>
#include <signal.h>
#include <time.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/ioctl.h>
@ -43,6 +42,8 @@
#include <atomic>
#include <future>
#include <exception>
#include <thread>
#include <chrono>
#include <string>
#include <libconfig.h++>
using namespace libconfig;
@ -759,7 +760,6 @@ static void RptrAckThread(SDVAP_ACK_ARG *parg)
time_t tnow = 0;
unsigned char silence[12] = { 0x4e,0x8d,0x32,0x88,0x26,0x1a,0x3f,0x61,0xe8,0x70,0x4f,0x93 };
unsigned int aseed_ack = 0;
struct timespec nanos;
act.sa_handler = sig_catch;
sigemptyset(&act.sa_mask);
@ -800,9 +800,7 @@ static void RptrAckThread(SDVAP_ACK_ARG *parg)
memcpy(dr.frame.hdr.sfx, (unsigned char *)" ", 4);
calcPFCS(dr.frame.hdr.flag, dr.frame.hdr.pfcs);
dongle.SendRegister(dr);
nanos.tv_sec = 0;
nanos.tv_nsec = DELAY_BETWEEN * 1000000;
nanosleep(&nanos,0);
std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_BETWEEN));
// SYNC
dr.header = 0xc012u;
@ -869,11 +867,8 @@ static void RptrAckThread(SDVAP_ACK_ARG *parg)
}
memcpy(&dr.frame.vad.voice, silence, 12);
dongle.SendRegister(dr);
if (i < 9) {
nanos.tv_sec = 0;
nanos.tv_nsec = DELAY_BETWEEN * 1000000;
nanosleep(&nanos,0);
}
if (i < 9)
std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_BETWEEN));
}
return;
}

@ -36,7 +36,6 @@
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <math.h>
#include <sys/time.h>
#include <sys/stat.h>
@ -53,6 +52,8 @@
#include <future>
#include <exception>
#include <string>
#include <thread>
#include <chrono>
#include <map>
#include <libconfig.h++>
using namespace libconfig;
@ -526,8 +527,6 @@ static int open_port(const SPORTIP &pip)
/* receive data from the irc server and save it */
static void GetIRCDataThread()
{
struct timespec req;
std::string user, rptr, gateway, ipaddr;
DSTAR_PROTOCOL proto;
IRCDDB_RESPONSE_TYPE type;
@ -632,9 +631,7 @@ static void GetIRCDataThread()
}
}
}
req.tv_sec = 0;
req.tv_nsec = 500000000; // 500 milli
nanosleep(&req, NULL);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
traceit("GetIRCDataThread exiting...\n");
return;
@ -2234,8 +2231,6 @@ static void compute_aprs_hash()
void APRSBeaconThread()
{
struct timespec req;
char snd_buf[512];
char rcv_buf[512];
time_t tnow = 0;
@ -2350,9 +2345,7 @@ void APRSBeaconThread()
close(aprs->GetSock());
aprs->SetSock( -1 );
} else if (errno == EWOULDBLOCK) {
req.tv_sec = 0;
req.tv_nsec = 100000000; // 100 milli
nanosleep(&req, NULL);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
} else {
/* Cant do nothing about it */
traceit("send_aprs_beacon failed, error=%d\n", errno);
@ -2401,9 +2394,7 @@ void APRSBeaconThread()
} else
THRESHOLD_COUNTDOWN = 15;
req.tv_sec = 0;
req.tv_nsec = 100000000; // 100 milli
nanosleep(&req, NULL);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
/* 20 seconds passed already ? */
time(&tnow);
@ -2429,8 +2420,6 @@ void APRSBeaconThread()
static void PlayFileThread(char *file)
{
struct timespec req;
unsigned short rlen = 0;
unsigned char dstar_buf[56];
unsigned char rptr_buf[58];
@ -2533,9 +2522,7 @@ static void PlayFileThread(char *file)
toRptr[i].G2_COUNTER ++;
req.tv_sec = 0;
req.tv_nsec = play_delay * 1000000;
nanosleep(&req, NULL);
std::this_thread::sleep_for(std::chrono::milliseconds(play_delay));
}
}
fclose(fp);

@ -1,8 +1,7 @@
/*
* Copyright (C) 2010 by Scott Lawson KI4LKF
* Additional:
* Copyright (C) 2015 by Thomas A. Early N7TAE
* Copyright (C) 2015,2018 by Thomas A. Early N7TAE
*
* 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
@ -31,8 +30,6 @@
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <time.h>
#include <regex.h>
#include <sys/stat.h>
@ -52,6 +49,8 @@
#include <set>
#include <map>
#include <utility>
#include <thread>
#include <chrono>
#include <libconfig.h++>
#include "versions.h"
using namespace libconfig;
@ -327,7 +326,6 @@ static void RptrAckThread(char *arg)
char RADIO_ID[21];
memcpy(RADIO_ID, arg + 1, 21);
unsigned char buf[56];
struct timespec nanos;
unsigned int aseed;
time_t tnow = 0;
unsigned char silence[12] = { 0x4e,0x8d,0x32,0x88,0x26,0x1a,0x3f,0x61,0xe8,0x70,0x4f,0x93 };
@ -386,9 +384,7 @@ static void RptrAckThread(char *arg)
memcpy(buf + 50, "RPTR", 4);
calcPFCS(buf,56);
sendto(rptr_sock, buf, 56, 0, (struct sockaddr *)&toLocalg2, sizeof(toLocalg2));
nanos.tv_sec = 0;
nanos.tv_nsec = delay_between * 1000000;
nanosleep(&nanos,0);
std::this_thread::sleep_for(std::chrono::milliseconds(delay_between));
buf[4] = 0x20;
memcpy(buf + 15, silence, 9);
@ -452,11 +448,8 @@ static void RptrAckThread(char *arg)
break;
}
sendto(rptr_sock, buf, 27, 0, (struct sockaddr *)&toLocalg2, sizeof(toLocalg2));
if (i < 9) {
nanos.tv_sec = 0;
nanos.tv_nsec = delay_between * 1000000;
nanosleep(&nanos,0);
}
if (i < 9)
std::this_thread::sleep_for(std::chrono::milliseconds(delay_between));
}
}
@ -3889,7 +3882,6 @@ static void AudioNotifyThread(char *arg)
char mod;
char *p = NULL;
u_int16_t streamid_raw = 0;
struct timespec nanos;
unsigned int aseed;
time_t tnow = 0;
struct sigaction act;
@ -4070,9 +4062,7 @@ static void AudioNotifyThread(char *arg)
}
sendto(rptr_sock, dstar_buf, rlen, 0, (struct sockaddr *)&toLocalg2,sizeof(struct sockaddr_in));
}
nanos.tv_sec = 0;
nanos.tv_nsec = delay_between * 1000000;
nanosleep(&nanos,0);
std::this_thread::sleep_for(std::chrono::milliseconds(delay_between));
}
fclose(fp);
return;

@ -1,6 +1,6 @@
// version strings must be 55 characters or less!
#define IRCDDB_VERSION "linux-g2_ircddb-5.1.0"
#define IRCDDB_VERSION "linux-g2_ircddb-5.1.1"
#define LINK_VERSION "5.10"
#define DVAP_VERSION "linux-dvap_rptr-5.1.0"
#define DVAP_VERSION "linux-dvap_rptr-5.1.1"
#define DVRPTR_VERSION "linux-dvrptr-5.1.0"
#define MMDVM_VERSION "mmdvm-dvmega-0.0.0"

Loading…
Cancel
Save

Powered by TurnKey Linux.