mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-07-20 19:02:55 +00:00
Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into common_solver
This commit is contained in:
commit
ab75381e33
@ -49,7 +49,7 @@ message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.")
|
||||
|
||||
set(VERSION_INFO_MAJOR_VERSION 0)
|
||||
set(VERSION_INFO_MINOR_VERSION 0)
|
||||
set(VERSION_INFO_MAINT_VERSION 9)
|
||||
set(VERSION_INFO_MAINT_VERSION 9.git)
|
||||
include(VolkVersion) #setup version info
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ This figure shows the role of some VOLK_GNSSSDR kernels in the context of a GNSS
|
||||
|
||||
If you use VOLK_GNSSSDR in your research and/or software, please cite the following paper:
|
||||
|
||||
* C. Fernández-Prades, J. Arribas, P. Closas, [*Accelerating GNSS Software Receivers*](https://zenodo.org/record/266493#.WJR8j7bhB89), in Proc. of the ION GNSS+ 2016 Conference, pp. 44-61, Portland, Oregon, Sept. 12-16, 2016.
|
||||
* C. Fernández-Prades, J. Arribas, P. Closas, [*Accelerating GNSS Software Receivers*](https://zenodo.org/record/266493), in Proc. of the ION GNSS+ 2016 Conference, pp. 44-61, Portland, Oregon, Sept. 12-16, 2016.
|
||||
|
||||
Citations are useful for the continued development and maintenance of the library.
|
||||
|
||||
|
@ -102,6 +102,9 @@ class volk_gnsssdr_modtool:
|
||||
os.makedirs(os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], 'kernels/volk_gnsssdr_' + self.my_dict['name']))
|
||||
|
||||
current_kernel_names = self.get_current_kernels();
|
||||
need_ifdef_updates = ["constant.h", "volk_complex.h", "volk_malloc.h", "volk_prefs.h",
|
||||
"volk_common.h", "volk_cpu.tmpl.h", "volk_config_fixed.tmpl.h",
|
||||
"volk_typedefs.h", "volk.tmpl.h"]
|
||||
|
||||
for root, dirnames, filenames in os.walk(self.my_dict['base']):
|
||||
for name in filenames:
|
||||
@ -111,8 +114,14 @@ class volk_gnsssdr_modtool:
|
||||
infile = os.path.join(root, name);
|
||||
instring = open(infile, 'r').read();
|
||||
outstring = re.sub(self.volk_gnsssdr, 'volk_gnsssdr_' + self.my_dict['name'], instring);
|
||||
if name in need_ifdef_updates:
|
||||
outstring = re.sub(self.volk_included, 'INCLUDED_VOLK_' + self.my_dict['name'].upper(), outstring)
|
||||
newname = re.sub(self.volk_gnsssdr, 'volk_gnsssdr_' + self.my_dict['name'], name);
|
||||
relpath = os.path.relpath(infile, self.my_dict['base']);
|
||||
if name == 'VolkConfig.cmake.in':
|
||||
outstring = re.sub("VOLK", 'VOLK_' + self.my_dict['name'].upper(), outstring)
|
||||
newname = "Volk%sConfig.cmake.in" % self.my_dict['name']
|
||||
|
||||
newrelpath = re.sub(self.volk_gnsssdr, 'volk_gnsssdr_' + self.my_dict['name'], relpath);
|
||||
dest = os.path.join(self.my_dict['destination'], 'volk_gnsssdr_' + self.my_dict['name'], os.path.dirname(newrelpath), newname);
|
||||
|
||||
|
@ -1,13 +1,32 @@
|
||||
/*
|
||||
/*!
|
||||
* \file bits.c
|
||||
* \author Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2013, 2016 Swift Navigation Inc.
|
||||
* Contact: Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* This source is subject to the license found in the file 'LICENSE' which must
|
||||
* be be distributed together with this source. All other rights reserved.
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "bits.h"
|
||||
@ -53,8 +72,9 @@ u8 parity(u32 x)
|
||||
u32 getbitu(const u8 *buff, u32 pos, u8 len)
|
||||
{
|
||||
u32 bits = 0;
|
||||
|
||||
for (u32 i = pos; i < pos + len; i++) {
|
||||
u32 i=0;
|
||||
for (i = pos; i < pos + len; i++)
|
||||
{
|
||||
bits = (bits << 1) +
|
||||
((buff[i/8] >> (7 - i%8)) & 1u);
|
||||
}
|
||||
@ -99,8 +119,9 @@ void setbitu(u8 *buff, u32 pos, u32 len, u32 data)
|
||||
|
||||
if (len <= 0 || 32 < len)
|
||||
return;
|
||||
|
||||
for (u32 i = pos; i < pos + len; i++, mask >>= 1) {
|
||||
u32 i = 0;
|
||||
for (i = pos; i < pos + len; i++, mask >>= 1)
|
||||
{
|
||||
if (data & mask)
|
||||
buff[i/8] |= 1u << (7 - i % 8);
|
||||
else
|
||||
@ -134,34 +155,40 @@ void setbits(u8 *buff, u32 pos, u32 len, s32 data)
|
||||
*/
|
||||
void bitshl(void *buf, u32 size, u32 shift)
|
||||
{
|
||||
if (shift > size * CHAR_BIT) {
|
||||
if (shift > size * CHAR_BIT)
|
||||
{
|
||||
/* Quick check: if the shift is larger, than the buffer, zero the data */
|
||||
memset(buf, 0, size);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char *dst = buf; /* Destination byte. */
|
||||
const unsigned char *src = dst + shift / CHAR_BIT; /* First source byte,
|
||||
* possibly incomplete. */
|
||||
const unsigned char *src = dst + shift / CHAR_BIT; /* First source byte, possibly incomplete. */
|
||||
|
||||
u32 copy_bits = size * CHAR_BIT - shift; /* Number of bits to move */
|
||||
u32 byte_shift = copy_bits % CHAR_BIT; /* Shift of data */
|
||||
u32 full_bytes = copy_bits / CHAR_BIT; /* Number of bytes to move */
|
||||
|
||||
if (0 == byte_shift) {
|
||||
if (0 == byte_shift)
|
||||
{
|
||||
/* When moving data in character boundaries, use built-in functions: move
|
||||
* data, and then zero the tail. */
|
||||
memmove(dst, src, full_bytes);
|
||||
memset(dst + full_bytes, 0, size - full_bytes);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Create an accumulator: it will hold a value of two consecutive bytes */
|
||||
u32 acc = *src++;
|
||||
for (u32 i = 0; i < full_bytes; ++i) {
|
||||
u32 i = 0;
|
||||
for (i = 0; i < full_bytes; ++i)
|
||||
{
|
||||
acc = (acc << CHAR_BIT) | *src++;
|
||||
*dst++ = acc >> byte_shift;
|
||||
}
|
||||
*dst++ = acc << CHAR_BIT >> byte_shift;
|
||||
if (full_bytes + 1 < size) {
|
||||
if (full_bytes + 1 < size)
|
||||
{
|
||||
memset(dst, 0, size - full_bytes - 1);
|
||||
}
|
||||
}
|
||||
@ -188,14 +215,16 @@ void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index,
|
||||
{
|
||||
u32 limit1 = count / 32;
|
||||
u32 limit2 = count % 32;
|
||||
|
||||
for (u32 idx = 0; idx < limit1; ++idx) {
|
||||
u32 idx = 0;
|
||||
for (idx = 0; idx < limit1; ++idx)
|
||||
{
|
||||
u32 tmp = getbitu(src, src_index, 32);
|
||||
setbitu(dst, dst_index, 32, tmp);
|
||||
src_index += 32;
|
||||
dst_index += 32;
|
||||
}
|
||||
if (0 != limit2) {
|
||||
if (0 != limit2)
|
||||
{
|
||||
u32 tmp = getbitu(src, src_index, limit2);
|
||||
setbitu(dst, dst_index, limit2, tmp);
|
||||
}
|
||||
@ -212,7 +241,8 @@ void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index,
|
||||
u8 count_bits_u64(u64 v, u8 bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
int i = 0;
|
||||
for (i = 0; i < 16; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
return bv == 1 ? r : 64 - r;
|
||||
}
|
||||
@ -228,7 +258,8 @@ u8 count_bits_u64(u64 v, u8 bv)
|
||||
u8 count_bits_u32(u32 v, u8 bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
int i = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
return bv == 1 ? r : 32 - r;
|
||||
}
|
||||
@ -244,7 +275,8 @@ u8 count_bits_u32(u32 v, u8 bv)
|
||||
u8 count_bits_u16(u16 v, u8 bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
int i = 0;
|
||||
for (i= 0; i < 4; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
return bv == 1 ? r : 16 - r;
|
||||
}
|
||||
@ -260,7 +292,8 @@ u8 count_bits_u16(u16 v, u8 bv)
|
||||
u8 count_bits_u8(u8 v, u8 bv)
|
||||
{
|
||||
u8 r = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
int i = 0;
|
||||
for (i = 0; i < 2; i++)
|
||||
r += bitn[(v >> (i*4)) & 0xf];
|
||||
return bv == 1 ? r : 8 - r;
|
||||
}
|
||||
|
@ -1,13 +1,32 @@
|
||||
/*
|
||||
/*!
|
||||
* \file bits.h
|
||||
* \author Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2013, 2016 Swift Navigation Inc.
|
||||
* Contact: Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* This source is subject to the license found in the file 'LICENSE' which must
|
||||
* be be distributed together with this source. All other rights reserved.
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LIBSWIFTNAV_BITS_H
|
||||
|
@ -1,15 +1,36 @@
|
||||
/*
|
||||
/*!
|
||||
* \file cnav_msg.c
|
||||
* \author Valeri Atamaniouk <valeri@swift-nav.com>
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2016 Swift Navigation Inc.
|
||||
* Contact: Valeri Atamaniouk <valeri@swift-nav.com>
|
||||
*
|
||||
* This source is subject to the license found in the file 'LICENSE' which must
|
||||
* be be distributed together with this source. All other rights reserved.
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "edc.h"
|
||||
#include "bits.h"
|
||||
#include "cnav_msg.h"
|
||||
@ -69,6 +90,7 @@ static u32 _cnav_compute_crc(cnav_v27_part_t *part)
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extracts CRC-24Q from a CNAV message buffer.
|
||||
* CRC-24Q value is the last 24 bits from 300 bits message buffer.
|
||||
@ -83,12 +105,14 @@ static u32 _cnav_extract_crc(const cnav_v27_part_t *part)
|
||||
{
|
||||
u32 crc = getbitu(part->decoded, GPS_CNAV_MSG_DATA_LENGTH,
|
||||
GPS_CNAV_MSG_CRC_LENGTH);
|
||||
if (part->invert) {
|
||||
if (part->invert)
|
||||
{
|
||||
crc ^= 0xFFFFFF;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper to rescan for preamble in the received buffer.
|
||||
* Occasionally there could be a false lock on message contents if it the
|
||||
@ -107,11 +131,15 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part)
|
||||
{
|
||||
part->preamble_seen = false;
|
||||
|
||||
if (part->n_decoded > GPS_CNAV_PREAMBLE_LENGTH + 1) {
|
||||
for (size_t i = 1, j = part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH;
|
||||
i < j; ++i) {
|
||||
if (part->n_decoded > GPS_CNAV_PREAMBLE_LENGTH + 1)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
for (i = 1, j = part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH; i < j; ++i)
|
||||
{
|
||||
u32 c = getbitu(part->decoded, i, GPS_CNAV_PREAMBLE_LENGTH);
|
||||
if (GPS_CNAV_PREAMBLE1 == c || GPS_CNAV_PREAMBLE2 == c) {
|
||||
if (GPS_CNAV_PREAMBLE1 == c || GPS_CNAV_PREAMBLE2 == c)
|
||||
{
|
||||
part->preamble_seen = true;
|
||||
part->invert = (GPS_CNAV_PREAMBLE2 == c);
|
||||
/* We shift the accumulated bits to the beginning of the buffer */
|
||||
@ -121,13 +149,15 @@ static void _cnav_rescan_preamble(cnav_v27_part_t *part)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!part->preamble_seen && part->n_decoded >= GPS_CNAV_PREAMBLE_LENGTH) {
|
||||
if (!part->preamble_seen && part->n_decoded >= GPS_CNAV_PREAMBLE_LENGTH)
|
||||
{
|
||||
bitshl(part->decoded, sizeof(part->decoded),
|
||||
part->n_decoded - GPS_CNAV_PREAMBLE_LENGTH + 1);
|
||||
part->n_decoded = GPS_CNAV_PREAMBLE_LENGTH - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Feed a symbol into Viterbi decoder instance.
|
||||
*
|
||||
@ -146,14 +176,17 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
||||
{
|
||||
part->symbols[part->n_symbols++] = ch;
|
||||
|
||||
if (part->init) {
|
||||
if (part->init)
|
||||
{
|
||||
/* Initial step - load more symbols without decoding. */
|
||||
if (part->n_symbols < (GPS_L2C_V27_INIT_BITS + GPS_L2C_V27_DECODE_BITS) * 2) {
|
||||
if (part->n_symbols < (GPS_L2C_V27_INIT_BITS + GPS_L2C_V27_DECODE_BITS) * 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
part->init = false;
|
||||
}
|
||||
else if (part->n_symbols < GPS_L2C_V27_DECODE_BITS * 2) {
|
||||
else if (part->n_symbols < GPS_L2C_V27_DECODE_BITS * 2)
|
||||
{
|
||||
/* Wait until decoding block is accumulated */
|
||||
return;
|
||||
}
|
||||
@ -194,30 +227,38 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
||||
*/
|
||||
|
||||
bool retry = true;
|
||||
while (retry) {
|
||||
while (retry)
|
||||
{
|
||||
retry = false;
|
||||
|
||||
if (!part->preamble_seen) {
|
||||
if (!part->preamble_seen)
|
||||
{
|
||||
/* Rescan for preamble if possible. The first bit is ignored. */
|
||||
_cnav_rescan_preamble(part);
|
||||
}
|
||||
if (part->preamble_seen && GPS_CNAV_MSG_LENGTH <= part->n_decoded) {
|
||||
if (part->preamble_seen && GPS_CNAV_MSG_LENGTH <= part->n_decoded)
|
||||
{
|
||||
|
||||
/* We have collected 300 bits starting from message preamble. Now try
|
||||
* to compute CRC-24Q */
|
||||
u32 crc = _cnav_compute_crc(part);
|
||||
u32 crc2 = _cnav_extract_crc(part);
|
||||
|
||||
if (part->message_lock) {
|
||||
if (part->message_lock)
|
||||
{
|
||||
/* We have message lock */
|
||||
part->crc_ok = (crc == crc2);
|
||||
if (part->crc_ok) {
|
||||
if (part->crc_ok)
|
||||
{
|
||||
/* Reset message lock counter */
|
||||
part->n_crc_fail = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Increment message lock counter */
|
||||
part->n_crc_fail++;
|
||||
if (part->n_crc_fail > GPS_CNAV_LOCK_MAX_CRC_FAILS) {
|
||||
if (part->n_crc_fail > GPS_CNAV_LOCK_MAX_CRC_FAILS)
|
||||
{
|
||||
/* CRC has failed too many times - drop the lock. */
|
||||
part->n_crc_fail = 0;
|
||||
part->message_lock = false;
|
||||
@ -226,12 +267,16 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
||||
retry = true;
|
||||
}
|
||||
}
|
||||
} else if (crc == crc2) {
|
||||
}
|
||||
else if (crc == crc2)
|
||||
{
|
||||
/* CRC match - message can be decoded */
|
||||
part->message_lock = true;
|
||||
part->crc_ok = true;
|
||||
part->n_crc_fail = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There is no message lock and the CRC check fails. Assume there is
|
||||
* false positive lock - rescan for preamble. */
|
||||
part->crc_ok = false;
|
||||
@ -248,6 +293,7 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Invert message bits in the buffer.
|
||||
*
|
||||
@ -259,11 +305,14 @@ static void _cnav_add_symbol(cnav_v27_part_t *part, u8 ch)
|
||||
*/
|
||||
static void _cnav_msg_invert(cnav_v27_part_t *part)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(part->decoded); i++) {
|
||||
size_t i = 0;
|
||||
for (i = 0; i < sizeof(part->decoded); i++)
|
||||
{
|
||||
part->decoded[i] ^= 0xFFu;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs CNAV message decoding.
|
||||
*
|
||||
@ -287,10 +336,13 @@ static void _cnav_msg_invert(cnav_v27_part_t *part)
|
||||
static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, u32 *delay)
|
||||
{
|
||||
bool res = false;
|
||||
if (GPS_CNAV_MSG_LENGTH <= part->n_decoded) {
|
||||
if (part->crc_ok) {
|
||||
if (GPS_CNAV_MSG_LENGTH <= part->n_decoded)
|
||||
{
|
||||
if (part->crc_ok)
|
||||
{
|
||||
/* CRC is OK */
|
||||
if (part->invert) {
|
||||
if (part->invert)
|
||||
{
|
||||
_cnav_msg_invert(part);
|
||||
}
|
||||
|
||||
@ -302,14 +354,16 @@ static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, u32 *delay)
|
||||
/* copy RAW message for GNSS-SDR */
|
||||
memcpy(msg->raw_msg,part->decoded,GPS_L2C_V27_DECODE_BITS + GPS_L2C_V27_DELAY_BITS);
|
||||
|
||||
*delay = (part->n_decoded - GPS_CNAV_MSG_LENGTH + GPS_L2C_V27_DELAY_BITS)
|
||||
* 2 + part->n_symbols;
|
||||
*delay = (part->n_decoded - GPS_CNAV_MSG_LENGTH + GPS_L2C_V27_DELAY_BITS) * 2 + part->n_symbols;
|
||||
|
||||
if (part->invert) {
|
||||
if (part->invert)
|
||||
{
|
||||
_cnav_msg_invert(part);
|
||||
}
|
||||
res = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* CRC mismatch - no decoding */
|
||||
}
|
||||
bitshl(part->decoded, sizeof(part->decoded), GPS_CNAV_MSG_LENGTH);
|
||||
@ -319,6 +373,7 @@ static bool _cnav_msg_decode(cnav_v27_part_t *part, cnav_msg_t *msg, u32 *delay)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize CNAV decoder.
|
||||
*
|
||||
@ -377,13 +432,15 @@ bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec,
|
||||
_cnav_add_symbol(&dec->part1, symbol);
|
||||
_cnav_add_symbol(&dec->part2, symbol);
|
||||
|
||||
if (dec->part1.message_lock) {
|
||||
if (dec->part1.message_lock)
|
||||
{
|
||||
/* Flush data in decoder. */
|
||||
dec->part2.n_decoded = 0;
|
||||
dec->part2.n_symbols = 0;
|
||||
return _cnav_msg_decode(&dec->part1, msg, pdelay);
|
||||
}
|
||||
if (dec->part2.message_lock) {
|
||||
if (dec->part2.message_lock)
|
||||
{
|
||||
/* Flush data in decoder. */
|
||||
dec->part1.n_decoded = 0;
|
||||
dec->part1.n_symbols = 0;
|
||||
@ -393,6 +450,7 @@ bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Provides a singleton polynomial object.
|
||||
*
|
||||
@ -408,7 +466,8 @@ const v27_poly_t *cnav_msg_decoder_get_poly(void)
|
||||
static v27_poly_t instance;
|
||||
static bool initialized = false;
|
||||
|
||||
if (!initialized) {
|
||||
if (!initialized)
|
||||
{
|
||||
/* Coefficients for polynomial object */
|
||||
const signed char coeffs[2] = { GPS_L2C_V27_POLY_A, GPS_L2C_V27_POLY_B };
|
||||
|
||||
|
@ -1,15 +1,35 @@
|
||||
/*
|
||||
/*!
|
||||
* \file cnav_msg.h
|
||||
* \author Valeri Atamaniouk <valeri@swift-nav.com>
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2016 Swift Navigation Inc.
|
||||
* Contact: Valeri Atamaniouk <valeri@swift-nav.com>
|
||||
*
|
||||
* This source is subject to the license found in the file 'LICENSE' which must
|
||||
* be be distributed together with this source. All other rights reserved.
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LIBSWIFTNAV_CNAV_MSG_H
|
||||
#define LIBSWIFTNAV_CNAV_MSG_H
|
||||
|
||||
|
@ -1,13 +1,32 @@
|
||||
/*
|
||||
/*!
|
||||
* \file edc.c
|
||||
* \author Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2010 Swift Navigation Inc.
|
||||
* Contact: Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* This source is subject to the license found in the file 'LICENSE' which must
|
||||
* be be distributed together with this source. All other rights reserved.
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "edc.h"
|
||||
@ -72,7 +91,8 @@ static const u32 crc24qtab[256] = {
|
||||
*/
|
||||
u32 crc24q(const u8 *buf, u32 len, u32 crc)
|
||||
{
|
||||
for (u32 i = 0; i < len; i++)
|
||||
u32 i = 0;
|
||||
for (i = 0; i < len; i++)
|
||||
crc = ((crc << 8) & 0xFFFFFF) ^ crc24qtab[((crc >> 16) ^ buf[i]) & 0xff];
|
||||
return crc;
|
||||
}
|
||||
@ -98,16 +118,20 @@ u32 crc24q_bits(u32 crc, const u8 *buf, u32 n_bits, bool invert)
|
||||
u8 b = 0;
|
||||
u32 shift = 8 - n_bits % 8;
|
||||
|
||||
for (u32 i = 0; i < n_bits / 8; ++i) {
|
||||
u32 i = 0;
|
||||
for (i = 0; i < n_bits / 8; ++i)
|
||||
{
|
||||
acc = (acc << 8) | *buf++;
|
||||
if (invert) {
|
||||
if (invert)
|
||||
{
|
||||
acc ^= 0xFFu;
|
||||
}
|
||||
b = (acc >> shift) & 0xFFu;
|
||||
crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu];
|
||||
}
|
||||
acc = (acc << 8) | *buf;
|
||||
if (invert) {
|
||||
if (invert)
|
||||
{
|
||||
acc ^= 0xFFu;
|
||||
}
|
||||
b = (acc >> shift) & 0xFFu;
|
||||
|
@ -1,15 +1,35 @@
|
||||
/*
|
||||
/*!
|
||||
* \file edc.h
|
||||
* \author Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2010 Swift Navigation Inc.
|
||||
* Contact: Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* This source is subject to the license found in the file 'LICENSE' which must
|
||||
* be be distributed together with this source. All other rights reserved.
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LIBSWIFTNAV_EDC_H
|
||||
#define LIBSWIFTNAV_EDC_H
|
||||
|
||||
|
@ -1,10 +1,36 @@
|
||||
/* User include file for libfec
|
||||
* Copyright 2004, Phil Karn, KA9Q
|
||||
* May be used under the terms of the GNU Lesser General Public License (LGPL)
|
||||
/*!
|
||||
* \file fec.h
|
||||
* \author Phil Karn, KA9Q
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2004, Phil Karn, KA9Q
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _FEC_H_
|
||||
#define _FEC_H_
|
||||
|
||||
#ifndef LIBSWIFTNAV_FEC_H_
|
||||
#define LIBSWIFTNAV_FEC_H_
|
||||
|
||||
/* r=1/2 k=7 convolutional encoder polynomials
|
||||
* The NASA-DSN convention is to use V27POLYA inverted, then V27POLYB
|
||||
|
@ -1,16 +1,37 @@
|
||||
/*
|
||||
/*!
|
||||
* \file swift_common.h
|
||||
* \author Henry Hallam <henry@swift-nav.com>
|
||||
* Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2012 Swift Navigation Inc.
|
||||
* Contact: Henry Hallam <henry@swift-nav.com>
|
||||
* Fergus Noble <fergus@swift-nav.com>
|
||||
*
|
||||
* This source is subject to the license found in the file 'LICENSE' which must
|
||||
* be be distributed together with this source. All other rights reserved.
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LIBSWIFTNAV_COMMON_H
|
||||
#define LIBSWIFTNAV_COMMON_H
|
||||
|
||||
|
@ -1,10 +1,36 @@
|
||||
/* K=7 r=1/2 Viterbi decoder in portable C
|
||||
* Copyright Feb 2004, Phil Karn, KA9Q
|
||||
* May be used under the terms of the GNU Lesser General Public License (LGPL)
|
||||
/*!
|
||||
* \file viterbi27.c
|
||||
* \author Phil Karn, KA9Q
|
||||
* \brief K=7 r=1/2 Viterbi decoder in portable C
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
* This file was originally borrowed from libswiftnav
|
||||
* <https://github.com/swift-nav/libswiftnav>,
|
||||
* a portable C library implementing GNSS related functions and algorithms,
|
||||
* and then modified by J. Arribas and C. Fernandez
|
||||
*
|
||||
* Copyright (C) 2004, Phil Karn, KA9Q
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* This file is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, version 3.
|
||||
*
|
||||
* 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
|
||||
* Lesser General Lesser Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "fec.h"
|
||||
|
||||
static inline int parity(int x)
|
||||
@ -16,6 +42,7 @@ static inline int parity(int x)
|
||||
return (0x6996 >> x) & 1;
|
||||
}
|
||||
|
||||
|
||||
/** Initialize a v27_poly_t struct for use with a v27_t decoder.
|
||||
*
|
||||
* \param poly Structure to initialize.
|
||||
@ -25,12 +52,14 @@ void v27_poly_init(v27_poly_t *poly, const signed char polynomial[2])
|
||||
{
|
||||
int state;
|
||||
|
||||
for(state = 0; state < 32; state++) {
|
||||
for(state = 0; state < 32; state++)
|
||||
{
|
||||
poly->c0[state] = (polynomial[0] < 0) ^ parity((2*state) & abs(polynomial[0])) ? 255 : 0;
|
||||
poly->c1[state] = (polynomial[1] < 0) ^ parity((2*state) & abs(polynomial[1])) ? 255 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Initialize a v27_t struct for Viterbi decoding.
|
||||
*
|
||||
* \param v Structure to initialize
|
||||
@ -60,6 +89,7 @@ void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count,
|
||||
v->old_metrics[initial_state & 63] = 0; /* Bias known start state */
|
||||
}
|
||||
|
||||
|
||||
/* C-language butterfly */
|
||||
#define BFLY(i) {\
|
||||
unsigned int metric,m0,m1,decision;\
|
||||
@ -89,7 +119,8 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
|
||||
unsigned int *tmp;
|
||||
int normalize = 0;
|
||||
|
||||
while(nbits--) {
|
||||
while(nbits--)
|
||||
{
|
||||
v27_decision_t *d = &v->decisions[v->decisions_index];
|
||||
|
||||
d->w[0] = d->w[1] = 0;
|
||||
@ -130,11 +161,13 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
|
||||
BFLY(31);
|
||||
|
||||
/* Normalize metrics if they are nearing overflow */
|
||||
if(v->new_metrics[0] > (1<<30)) {
|
||||
if(v->new_metrics[0] > (1 << 30))
|
||||
{
|
||||
int i;
|
||||
unsigned int minmetric = 1 << 31;
|
||||
|
||||
for(i=0; i<64; i++) {
|
||||
for(i = 0; i < 64; i++)
|
||||
{
|
||||
if(v->new_metrics[i] < minmetric)
|
||||
minmetric = v->new_metrics[i];
|
||||
}
|
||||
@ -156,6 +189,7 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Retrieve the most likely output bit sequence with known final state from
|
||||
* a v27_t decoder.
|
||||
*
|
||||
@ -173,7 +207,8 @@ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits,
|
||||
final_state %= 64;
|
||||
final_state <<= 2;
|
||||
|
||||
while(nbits-- != 0) {
|
||||
while(nbits-- != 0)
|
||||
{
|
||||
|
||||
/* Decrement decision index */
|
||||
decisions_index = (decisions_index == 0) ?
|
||||
@ -189,6 +224,7 @@ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Retrieve the most likely output bit sequence with unknown final state from
|
||||
* a v27_t decoder.
|
||||
*
|
||||
|
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "gps_cnav_utc_model.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
Gps_CNAV_Utc_Model::Gps_CNAV_Utc_Model()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user