feat(reformat): using Google c++ style everywhere

pull/47/head
Guenael 2021-12-04 15:19:06 -05:00
rodzic 2524ddb6f6
commit d140fd524f
14 zmienionych plików z 1272 dodań i 1294 usunięć

9
.clang-format 100644
Wyświetl plik

@ -0,0 +1,9 @@
---
BasedOnStyle: Google
ColumnLimit: 0
UseTab: Never
---
Language: Cpp
SortIncludes: false
IndentWidth: 4
---

Wyświetl plik

@ -34,7 +34,6 @@
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
@ -45,6 +44,7 @@
#include <curl/curl.h>
#include <rtl-sdr.h>
#include "./rtlsdr_wsprd.h"
#include "wsprd/wsprd.h"
@ -690,7 +690,6 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
fprintf(stderr, "Found %d device(s):\n", rtl_count);
for (uint32_t i = 0; i < rtl_count; i++) {
rtlsdr_get_device_usb_strings(i, rtl_vendor, rtl_product, rtl_serial);
@ -698,7 +697,6 @@ int main(int argc, char** argv) {
}
fprintf(stderr, "\nUsing device %d: %s\n", rx_options.device, rtlsdr_get_device_name(rx_options.device));
rtl_result = rtlsdr_open(&rtl_device, rx_options.device);
if (rtl_result < 0) {
fprintf(stderr, "ERROR: Failed to open rtlsdr device #%d.\n", rx_options.device);
@ -721,7 +719,6 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
rtl_result = rtlsdr_set_tuner_gain_mode(rtl_device, 1);
if (rtl_result < 0) {
fprintf(stderr, "ERROR: Failed to enable manual gain\n");
@ -729,7 +726,6 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
if (rx_options.autogain) {
rtl_result = rtlsdr_set_tuner_gain_mode(rtl_device, 0);
if (rtl_result != 0) {
@ -746,7 +742,6 @@ int main(int argc, char** argv) {
}
}
if (rx_options.ppm != 0) {
rtl_result = rtlsdr_set_freq_correction(rtl_device, rx_options.ppm);
if (rtl_result < 0) {
@ -756,7 +751,6 @@ int main(int argc, char** argv) {
}
}
rtl_result = rtlsdr_set_center_freq(rtl_device, rx_options.realfreq + FS4_RATE + 1500);
if (rtl_result < 0) {
fprintf(stderr, "ERROR: Failed to set frequency\n");
@ -764,7 +758,6 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
rtl_result = rtlsdr_reset_buffer(rtl_device);
if (rtl_result < 0) {
fprintf(stderr, "ERROR: Failed to reset buffers.\n");
@ -772,7 +765,6 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
/* Print used parameter */
time_t rawtime;
time(&rawtime);
@ -790,7 +782,6 @@ int main(int argc, char** argv) {
else
printf(" Gain : %d dB\n", rx_options.gain / 10);
/* Time alignment stuff */
struct timeval lTime;
gettimeofday(&lTime, NULL);
@ -817,7 +808,6 @@ int main(int argc, char** argv) {
pthread_create(&dongle.thread, NULL, rtlsdr_rx, NULL);
pthread_create(&dec.thread, &dec.tattr, wsprDecoder, NULL);
/* Main loop : Wait, read, decode */
while (!rx_state.exit_flag && !(rx_options.maxloop && (nLoop >= rx_options.maxloop))) {
/* Wait for time Sync on 2 mins */

Wyświetl plik

@ -25,13 +25,10 @@
*
*/
#pragma once
#include <unistd.h>
#ifndef bool
typedef uint32_t bool;
#define true 1
@ -69,6 +66,7 @@ struct receiver_options {
char uttime[5];
};
static void rtlsdr_callback(unsigned char *samples, uint32_t samples_count, void *ctx);
static void *rtlsdr_rx(void *arg);
void postSpots(uint32_t n_results);

Wyświetl plik

@ -32,7 +32,8 @@ extern unsigned char Partab[];
* POLY1 goes into the 2-bit of sym, and the symbol generated from POLY2
* goes into the 1-bit.
*/
#define ENCODE(sym, encstate) {\
#define ENCODE(sym, encstate) \
{ \
unsigned long _tmp; \
_tmp = (encstate)&POLY1; \
_tmp ^= _tmp >> 16; \

Wyświetl plik

@ -112,7 +112,6 @@ static const float metric_tables[4][256]= {
-13.3265, -13.1667, -13.4274, -13.6064, -13.5515, -13.9501, -13.9926, -14.4049, -14.1653, -14.4348,
-14.7983, -14.7807, -15.2349, -15.3536, -15.3026, -15.2739, -15.7170, -16.2161, -15.9185, -15.9490,
-16.6258, -16.5568, -16.4318, -16.7999, -16.4101, -17.6393, -17.7643, -17.2644, -17.5973, -17.0403,
-17.7039, -18.0073, -18.1840, -18.3848, -18.6286, -20.7063
};
-17.7039, -18.0073, -18.1840, -18.3848, -18.6286, -20.7063};
#pragma GCC diagnostic pop

Wyświetl plik

@ -44,7 +44,6 @@
#include "./wsprsim_utils.h"
#include "./metric_tables.h"
#define DF 375.0 / 256.0
#define DT 1.0 / 375.0
#define TWOPIDT 2.0 * M_PI *DT
@ -63,7 +62,6 @@ fftwf_plan PLAN1,
PLAN3;
int32_t printdata = 0;
uint8_t pr3[NSYM] = {
1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0,
0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1,
@ -73,8 +71,7 @@ uint8_t pr3[NSYM]= {
0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1,
0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0,
0,0
};
0, 0};
/***********************************************************************
* mode = 0: no frequency or drift search. find best time lag. *
@ -86,7 +83,6 @@ void sync_and_demodulate(float *id, float *qd, long np,
uint8_t *symbols, float *freq1, float fstep,
int32_t *shift1, int32_t lagmin, int32_t lagmax, int32_t lagstep,
float *drift1, int32_t symfac, float *sync, int32_t mode) {
float fbest = 0.0;
float f0 = 0.0, fp, ss;
int32_t lag;
@ -253,13 +249,11 @@ void sync_and_demodulate(float *id, float *qd, long np,
return;
}
/***************************************************************************
symbol-by-symbol signal subtraction
****************************************************************************/
void subtract_signal(float *id, float *qd, long np,
float f0, int32_t shift0, float drift0, uint8_t *channel_symbols) {
float i0, q0;
float c0[NSPERSYM], s0[NSPERSYM];
float dphi, cdphi, sdphi;
@ -305,13 +299,11 @@ void subtract_signal(float *id, float *qd, long np,
return;
}
/******************************************************************************
Fully coherent signal subtraction
*******************************************************************************/
void subtract_signal2(float *id, float *qd, long np,
float f0, int32_t shift0, float drift0, uint8_t *channel_symbols) {
float phi = 0, dphi, cs;
float refi[NIQ] = {0}, refq[NIQ] = {0},
ci[NIQ] = {0}, cq[NIQ] = {0},
@ -328,13 +320,11 @@ void subtract_signal2(float *id, float *qd, long np,
// create reference wspr signal vector, centered on f0.
//
for (int32_t i = 0; i < NSYM; i++) {
cs = (float)channel_symbols[i];
dphi = TWOPIDT * (f0 +
((float)drift0 / 2.0) * ((float)i - (float)NSYM / 2.0) / ((float)NSYM / 2.0) +
(cs-1.5)*DF
);
(cs - 1.5) * DF);
for (int32_t j = 0; j < NSPERSYM; j++) {
int32_t ii = NSPERSYM * i + j;
@ -402,11 +392,9 @@ void subtract_signal2(float *id, float *qd, long np,
return;
}
int32_t wspr_decode(float *idat, float *qdat, uint32_t npoints,
struct decoder_options options, struct decoder_results *decodes,
int32_t *n_results) {
int32_t i, j, k;
uint8_t symbols[NBITS * 2] = {0};
uint8_t decdata[(NBITS + 7) / 8] = {0};
@ -492,7 +480,6 @@ int32_t wspr_decode(float *idat, float *qdat, uint32_t npoints,
// Main loop starts here
for (int32_t ipass = 0; ipass < options.npasses; ipass++) {
if (ipass == 1 && uniques == 0)
break;
if (ipass == 1) // otherwise we bog down on the second pass
@ -780,7 +767,6 @@ int32_t wspr_decode(float *idat, float *qdat, uint32_t npoints,
dupe = 1;
}
if (!dupe) {
strcpy(allcalls[uniques], callsign);
allfreqs[uniques] = freq1;
@ -812,7 +798,8 @@ int32_t wspr_decode(float *idat, float *qdat, uint32_t npoints,
for (k = 0; k < uniques - j; k++) {
if (decodes[k].snr < decodes[k + 1].snr) {
temp = decodes[k];
decodes[k]=decodes[k+1];;
decodes[k] = decodes[k + 1];
;
decodes[k + 1] = temp;
}
}

Wyświetl plik

@ -46,7 +46,6 @@ struct decoder_options {
uint32_t subtraction; // ''
};
struct decoder_results {
double freq;
float sync;
@ -61,7 +60,6 @@ struct decoder_results {
uint32_t cycles;
};
void sync_and_demodulate(float *id, float *qd, long np,
uint8_t *symbols, float *freq1, float fstep,
int32_t *shift1, int32_t lagmin, int32_t lagmax, int32_t lagstep,

Wyświetl plik

@ -39,7 +39,6 @@
//#pragma GCC diagnostic ignored "-Wstringop-overflow"
//#pragma GCC diagnostic ignored "-Wstringop-truncation"
void unpack50(signed char *dat, int32_t *n1, int32_t *n2) {
int32_t i, i4;

Wyświetl plik

@ -12,7 +12,6 @@
#include "./nhash.h"
#include "./fano.h"
char get_locator_character_code(char ch) {
if (ch >= 48 && ch <= 57) { // 0-9
return ch - 48;
@ -181,8 +180,7 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym
0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1,
0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0,
0,0
};
0, 0};
int nu[10] = {0, -1, 1, 0, -1, 2, 1, 0, -1, 1};
char *callsign, *grid, *powstr;
char grid4[5], message[23];
@ -281,7 +279,6 @@ int get_wspr_channel_symbols(char* rawmessage, char* hashtab, unsigned char* sym
data[9] = 0;
data[10] = 0;
// make sure that the 11-byte data vector is unpackable
// unpack it with the routine that the decoder will use and display
// the result. let the operator decide whether it worked.