Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TX power > 23dbm, lgw_get_instcnt will appear to slip away #131

Open
guo652917087 opened this issue Sep 29, 2024 · 1 comment
Open

TX power > 23dbm, lgw_get_instcnt will appear to slip away #131

guo652917087 opened this issue Sep 29, 2024 · 1 comment

Comments

@guo652917087
Copy link

guo652917087 commented Sep 29, 2024

The hardware uses the 470 full-duplex reference design provided by Semtech: SX1302CFD490GW1_e537v03a_490MHz_prod_folder
During the test, it was found that when the transmission power is greater than 23dbm (radiation measured by the spectrum analyzer), the time obtained by the lgw_get_instcnt interface and the time count value will jump.
I provide a test code.


/* fix an issue between POSIX and C99 */
#if __STDC_VERSION__ >= 199901L
#define _XOPEN_SOURCE 600
#else
#define _XOPEN_SOURCE 500
#endif

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <signal.h>     /* sigaction */
#include <pthread.h>
#include <inttypes.h>

#include "loragw_hal.h"
#include "loragw_reg.h"
#include "loragw_aux.h"

static int exit_sig = 0; /* 1 -> application terminates cleanly (shut down hardware, close open files, etc) */
static int quit_sig = 0; /* 1 -> application terminates without shutting down the hardware */
static pthread_mutex_t mx_concent = PTHREAD_MUTEX_INITIALIZER; /* control access to timer sync offsets */

/* handle signals */
static void sig_handler ( int sigio )
{
    if ( sigio == SIGQUIT )
    {
        quit_sig = 1;
    }
    else if ( ( sigio == SIGINT ) || ( sigio == SIGTERM ) )
    {
        exit_sig = 1;
    }
}

void thread_check_time_counter_slip ( void )
{
    uint32_t before_inst_tstamp = 0;
    uint32_t trig_tstamp = 0;
    uint32_t inst_tstamp = 0;

    lgw_get_instcnt ( &before_inst_tstamp );

    int diff_us = 0;
    int system_delay = 500000; //The sleep time error will never exceed
    int count = 0;
    time_t cur_time;
    struct tm tm_time;
    int x;

    while ( !exit_sig && !quit_sig )
    {
        pthread_mutex_lock ( &mx_concent );
        x  = lgw_get_instcnt ( &inst_tstamp );
        x |= lgw_get_trigcnt ( &trig_tstamp );
        pthread_mutex_unlock ( &mx_concent );

        if ( x != 0 )
        {
            printf ( "get SX1302 counter err\n" );
            exit ( EXIT_FAILURE );
        }

        diff_us = inst_tstamp - before_inst_tstamp;

        //## print timestamp
        cur_time = time ( NULL );
        localtime_r ( &cur_time, &tm_time );
        printf ( "INFO: %d-%02d-%02d %02d:%02d:%02d		SX1302 counter (INST): %u	,SX1302 counter (PPS):  %u\r\n",
                 1900 + tm_time.tm_year, 1 + tm_time.tm_mon,
                 tm_time.tm_mday, tm_time.tm_hour,
                 tm_time.tm_min, tm_time.tm_sec , inst_tstamp, trig_tstamp );

        if ( diff_us > ( 1000000 + system_delay ) )
        {
            printf ( "######Loki says:SX1302 time slips!!!!Time jumped %d seconds#####\r\n", diff_us / 1000000 );
            count++;
        }

        if ( count > 5 )
        {
            printf ( "######Loki says:check time slips too much!!!!#####\r\n" );
            exit ( EXIT_FAILURE );
        }

        before_inst_tstamp = inst_tstamp;

        // sleep 1 s
        wait_ms ( 1000 );
    }
}

void thread_sx1302_rx ( void )
{
    uint8_t max_rx_pkt = 16;

    /* set the buffer size to hold received packets */
    struct lgw_pkt_rx_s rxpkt[max_rx_pkt];
    int nb_pkt = 0;
    int i, j;

    while ( !exit_sig && !quit_sig )
    {
        pthread_mutex_lock ( &mx_concent );
        nb_pkt = lgw_receive ( max_rx_pkt, rxpkt );
        pthread_mutex_unlock ( &mx_concent );

        if ( nb_pkt > 0 )
        {
            for ( i = 0; i < nb_pkt; i++ )
            {
                printf ( "\n----- %s packet -----\n", ( rxpkt[i].modulation == MOD_LORA ) ? "LoRa" : "FSK" );
                printf ( "  count_us: %u\n", rxpkt[i].count_us );
                printf ( "  size:     %u\n", rxpkt[i].size );
                printf ( "  chan:     %u\n", rxpkt[i].if_chain );
                printf ( "  status:   0x%02X\n", rxpkt[i].status );
                printf ( "  datr:     %u\n", rxpkt[i].datarate );
                printf ( "  codr:     %u\n", rxpkt[i].coderate );
                printf ( "  rf_chain  %u\n", rxpkt[i].rf_chain );
                printf ( "  freq_hz   %u\n", rxpkt[i].freq_hz );
                printf ( "  snr_avg:  %.1f\n", rxpkt[i].snr );
                printf ( "  rssi_chan:%.1f\n", rxpkt[i].rssic );
                printf ( "  rssi_sig :%.1f\n", rxpkt[i].rssis );
                printf ( "  crc:      0x%04X\n", rxpkt[i].crc );

                for ( j = 0; j < rxpkt[i].size; j++ )
                {
                    printf ( "%02X ", rxpkt[i].payload[j] );
                }

                printf ( "\n" );
            }
        }

        wait_ms ( 5 );
    }
}
/* -------------------------------------------------------------------------- */
/* --- MAIN FUNCTION -------------------------------------------------------- */

int main ( void )
{
    int i, x;
    struct lgw_conf_board_s boardconf;
    struct lgw_pkt_tx_s pkt;
    struct lgw_tx_gain_lut_s txlut; /* TX gain table */
    uint8_t tx_status;
    static struct sigaction sigact; /* SIGQUIT&SIGINT&SIGTERM signal handling */

    /* Initialize TX gain LUT */
    txlut.size = 0;
    memset ( txlut.lut, 0, sizeof txlut.lut );
    txlut.size = 4;
    txlut.lut[0].rf_power = 20;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[0].pa_gain = 1;
    txlut.lut[0].dac_gain = 0;
    txlut.lut[0].mix_gain = 10;
    txlut.lut[0].dig_gain = 0;
    txlut.lut[1].rf_power = 23;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[1].pa_gain = 1;
    txlut.lut[1].dac_gain = 0;
    txlut.lut[1].mix_gain = 11;
    txlut.lut[1].dig_gain = 1;

    txlut.lut[2].rf_power = 27;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[2].pa_gain = 1;
    txlut.lut[2].dac_gain = 0;
    txlut.lut[2].mix_gain = 12;
    txlut.lut[2].dig_gain = 0;

    txlut.lut[3].rf_power = 30;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[3].pa_gain = 1;
    txlut.lut[3].dac_gain = 3;
    txlut.lut[3].mix_gain = 15;
    txlut.lut[3].dig_gain = 0;

    const int32_t channel_if_mode0[9] =
    {
        -300000,
        -100000,
        100000,
        300000,
        -300000,
        -100000,
        100000,
        300000,
        -200000 /* lora service */
    };

    const uint8_t channel_rfchain_mode0[9] = { 0, 0, 0, 0, 1, 1, 1, 1, 1 };

    /* Configure signal handling */
    sigemptyset ( &sigact.sa_mask );
    sigact.sa_flags = 0;
    sigact.sa_handler = sig_handler;
    sigaction ( SIGQUIT, &sigact, NULL );
    sigaction ( SIGINT, &sigact, NULL );
    sigaction ( SIGTERM, &sigact, NULL );

    struct lgw_conf_rxrf_s rfconf;
    struct lgw_conf_rxif_s ifconf;

    /* Configure the gateway */
    memset ( &boardconf, 0, sizeof boardconf );
    boardconf.lorawan_public = true;
    boardconf.clksrc = 0;
    boardconf.full_duplex = 1;
    boardconf.com_type = LGW_COM_SPI;
    strncpy ( boardconf.com_path, "/dev/spidev0.0", sizeof boardconf.com_path );

    boardconf.com_path[sizeof boardconf.com_path - 1] = '\0'; /* ensure string termination */

    if ( lgw_board_setconf ( &boardconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure board\n" );
        return EXIT_FAILURE;
    }


    /* set configuration for RF chains */
    memset ( &rfconf, 0, sizeof rfconf );
    rfconf.enable = true;
    rfconf.freq_hz = 488200000;
    rfconf.type = LGW_RADIO_TYPE_SX1255;
    rfconf.tx_enable = true;
    rfconf.single_input_mode = 0;
    rfconf.rssi_offset = -203.0;
    rfconf.rssi_tcomp.coeff_a = 0;
    rfconf.rssi_tcomp.coeff_b = 0;
    rfconf.rssi_tcomp.coeff_c = -39.78;
    rfconf.rssi_tcomp.coeff_d = 1349.50;
    rfconf.rssi_tcomp.coeff_e = 0;

    rfconf.tx_enable = true;

    if ( lgw_rxrf_setconf ( 0, &rfconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure rxrf 0\n" );
        return EXIT_FAILURE;
    }

    memset ( &rfconf, 0, sizeof rfconf );
    rfconf.enable = true;
    rfconf.freq_hz = 489000000;
    rfconf.type = LGW_RADIO_TYPE_SX1255;
    rfconf.tx_enable = false;
    rfconf.single_input_mode = 0;
    rfconf.rssi_offset = -205.5;
    rfconf.rssi_tcomp.coeff_a = 0;
    rfconf.rssi_tcomp.coeff_b = 0;
    rfconf.rssi_tcomp.coeff_c = 9.97;
    rfconf.rssi_tcomp.coeff_d = -2748.33;
    rfconf.rssi_tcomp.coeff_e = 0;

    if ( lgw_rxrf_setconf ( 1, &rfconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure rxrf 1\n" );
        return EXIT_FAILURE;
    }

    /* set configuration for LoRa multi-SF channels (bandwidth cannot be set) */
    memset ( &ifconf, 0, sizeof ( ifconf ) );

    for ( i = 0; i < 8; i++ )
    {
        ifconf.enable = true;
        ifconf.rf_chain = channel_rfchain_mode0[i];
        ifconf.freq_hz = channel_if_mode0[i];

        if ( lgw_rxif_setconf ( i, &ifconf ) != LGW_HAL_SUCCESS )
        {
            printf ( "ERROR: failed to configure rxif %d\n", i );
            return EXIT_FAILURE;
        }
		else
		{
			printf ( "INFO: configure rxif %d\n", i );
		}
    }

    ifconf.datarate = DR_LORA_SF7;

    /* set configuration for LoRa Service channel */
    memset ( &ifconf, 0, sizeof ( ifconf ) );
    ifconf.rf_chain = channel_rfchain_mode0[i];
    ifconf.freq_hz = channel_if_mode0[i];
    ifconf.datarate = DR_LORA_SF7;
    ifconf.bandwidth = BW_250KHZ;

    if ( lgw_rxif_setconf ( 8, &ifconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure rxif for LoRa service channel\n" );
        return EXIT_FAILURE;
    }

    if ( txlut.size > 0 )
    {
        if ( lgw_txgain_setconf ( 0, &txlut ) != LGW_HAL_SUCCESS )
        {
            printf ( "ERROR: failed to configure txgain lut\n" );
            return EXIT_FAILURE;
        }
    }

    /* Send packets */
    memset ( &pkt, 0, sizeof pkt );
    pkt.rf_chain = 0;
    pkt.freq_hz = 501300000;
    pkt.rf_power = 30; // 20/23 time no slip,but 27/30 sx1302 time slip
    pkt.tx_mode = IMMEDIATE;//TIMESTAMPED
    pkt.modulation = MOD_LORA;
    pkt.coderate = CR_LORA_4_5;
    pkt.no_crc = true;

    pkt.invert_pol = 1;
    pkt.preamble = 8;
    pkt.no_header = 0;
    pkt.payload[0] = 0x40; /* Confirmed Data Up */
    pkt.payload[1] = 0xAB;
    pkt.payload[2] = 0xAB;
    pkt.payload[3] = 0xAB;
    pkt.payload[4] = 0xAB;
    pkt.payload[5] = 0x00; /* FCTrl */
    pkt.payload[6] = 0; /* FCnt */
    pkt.payload[7] = 0; /* FCnt */
    pkt.payload[8] = 0x02; /* FPort */

    for ( i = 9; i < 255; i++ )
    {
        pkt.payload[i] = i;
    }

    pkt.datarate = 7;
    pkt.bandwidth = BW_125KHZ;
    pkt.size = 220;

    pkt.payload[6] = 0; /* FCnt */
    pkt.payload[7] = 0; /* FCnt */

    x = lgw_start();

    if ( x != 0 )
    {
        printf ( "ERROR: failed to start the gateway\n" );
        return EXIT_FAILURE;
    }

    uint64_t eui;

    x = lgw_get_eui ( &eui );

    if ( x != 0 )
    {
        printf ( "ERROR: failed to get concentrator EUI\n" );
    }
    else
    {
        printf ( "INFO: concentrator EUI: 0x%016" PRIx64 "\n", eui );
    }

    pthread_t thrid_time_slip;
    pthread_t thrid_rx;

    i = pthread_create ( &thrid_time_slip, NULL, ( void * ( * ) ( void * ) ) thread_check_time_counter_slip, NULL );

    if ( i != 0 )
    {
        printf ( "ERROR: [main] impossible to create time counter slip thread\n" );
        exit ( EXIT_FAILURE );
    }

    i = pthread_create ( &thrid_rx, NULL, ( void * ( * ) ( void * ) ) thread_sx1302_rx, NULL );

    if ( i != 0 )
    {
        printf ( "ERROR: [main] impossible to create sx1302 rx thread\n" );
        exit ( EXIT_FAILURE );
    }

    unsigned long send_pkt_cnt = 0;

    while ( ( quit_sig != 1 ) && ( exit_sig != 1 ) )
    {
        pthread_mutex_lock ( &mx_concent );
        lgw_status ( 0, TX_STATUS, &tx_status ); /* get TX status */
        pthread_mutex_unlock ( &mx_concent );

        if ( tx_status == TX_FREE )
        {

            pkt.payload[6] = ( uint8_t ) ( send_pkt_cnt >> 0 ); /* FCnt */
            pkt.payload[7] = ( uint8_t ) ( send_pkt_cnt >> 8 ); /* FCnt */

            x = lgw_send ( &pkt );

            if ( x == 0 )
            {
                send_pkt_cnt += 1;
                printf ( "INFO: sx1302 tx cnt:%lu,rf_power:%d\n", send_pkt_cnt , pkt.rf_power );
            }

        }

        wait_ms ( 20 );
    }

    /* Stop the gateway */
    x = lgw_stop();

    if ( x != 0 )
    {
        printf ( "ERROR: failed to stop the gateway\n" );
        return EXIT_FAILURE;
    }

    printf ( "=========== Test End ===========\n" );

    return 0;
}


/* --- EOF ------------------------------------------------------------------ */

Case 1. In the test code, modify line 286 pkt.rf_power = 30; // 20/23 time no slip,but 27/30 sx1302 time slip

【An error will occur if a LoRa antenna is connected. If a LoRa antenna is not connected, or a non-LoRa antenna is connected, such as a 2.4G WiFi antenna (make sure 30dbm is radiated, if the antenna is not connected, the PA may burn out), the time will not slip away.】

sx1302 internal time jump occurs, test output results

Console Messages------>


root@Gateway:~# /tmp/sx1302_full_test 
Opening SPI communication interface
Note: chip version is 0x10 (v1.0)
CAL FW VERSION: 1
CAL: started

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:-8 phi:6

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:-4 phi:10

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:3 phi:12

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:0 phi:5

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:0 phi:5

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:1 phi:5

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:8 phi:3

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:9 phi:4

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:8 phi:4

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-46 offset_q:67 rej:49

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-46 offset_q:69 rej:44

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-47 offset_q:67 rej:48

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-36 offset_q:53 rej:53

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-37 offset_q:53 rej:57

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-36 offset_q:53 rej:49

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-29 offset_q:42 rej:59

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-29 offset_q:42 rej:60

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-29 offset_q:42 rej:54

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-6 offset_q:8 rej:47

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-6 offset_q:8 rej:47

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-6 offset_q:8 rej:47
-------------------------------------------------------------------
Radio calibration completed:
  RadioA: amp:0 phi:5
  RadioB: amp:8 phi:3
  TX calibration params for rf_chain 0:
  -- power:20	dac:0	mix:10	offset_i:-46	offset_q:67
  -- power:23	dac:0	mix:11	offset_i:-37	offset_q:53
  -- power:27	dac:0	mix:12	offset_i:-29	offset_q:42
  -- power:30	dac:3	mix:15	offset_i:-6	offset_q:8
  TX calibration params for rf_chain 1:
  -- power:14	dac:3	mix:10	offset_i:-98	offset_q:35
-------------------------------------------------------------------
INFO: using legacy timestamp
AGC: setting fdd_mode to 1
ARB: dual demodulation disabled for all SF
INFO: found temperature sensor on port 0x40
INFO: AD5338R is configured
sx1302 tx cnt:1
sx1302 tx cnt:2
######Loki says:SX1302 time slips!!!!Time jumped 255 seconds#####
sx1302 tx cnt:3
sx1302 tx cnt:4
######Loki says:SX1302 time slips!!!!Time jumped 283 seconds#####
sx1302 tx cnt:5
sx1302 tx cnt:6
sx1302 tx cnt:7
######Loki says:SX1302 time slips!!!!Time jumped 403 seconds#####
sx1302 tx cnt:8
sx1302 tx cnt:9
sx1302 tx cnt:10
rx_buffer_fetch: nb_bytes to be fetched: 8192 (0 0)
WARNING: no syncword found, discard rx_buffer
######Loki says:SX1302 time slips!!!!Time jumped 403 seconds#####
sx1302 tx cnt:11
rx_buffer_fetch: nb_bytes to be fetched: 57328 (240 223)
WARNING: no syncword found, discard rx_buffer
sx1302 tx cnt:12
sx1302 tx cnt:13
######Loki says:SX1302 time slips!!!!Time jumped 537 seconds#####
sx1302 tx cnt:14
sx1302 tx cnt:15
sx1302 tx cnt:16
######Loki says:SX1302 time slips!!!!Time jumped 384 seconds#####
######Loki says:check time slips too much!!!!#####

Case 2. In the test code, modify line 286 pkt.rf_power = 20; // 20/23 time no slip,but 27/30 sx1302 time slip

No time jump printing

root@Gateway:~# /tmp/sx1302_full_test 
Opening SPI communication interface
Note: chip version is 0x10 (v1.0)
CAL FW VERSION: 1
CAL: started

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:0 phi:5

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:0 phi:11

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:2 phi:6

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:1 phi:5

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:0 phi:5

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:0 phi:5

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:9 phi:3

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:9 phi:4

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:6 phi:2

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-47 offset_q:67 rej:59

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-47 offset_q:67 rej:46

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-47 offset_q:67 rej:46

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-38 offset_q:53 rej:54

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-37 offset_q:53 rej:54

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-37 offset_q:54 rej:49

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-29 offset_q:42 rej:50

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-29 offset_q:42 rej:56

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-30 offset_q:42 rej:49

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-6 offset_q:8 rej:47

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-6 offset_q:8 rej:49

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:-6 offset_q:8 rej:49
-------------------------------------------------------------------
Radio calibration completed:
  RadioA: amp:1 phi:5
  RadioB: amp:9 phi:4
  TX calibration params for rf_chain 0:
  -- power:20	dac:0	mix:10	offset_i:-47	offset_q:67
  -- power:23	dac:0	mix:11	offset_i:-38	offset_q:53
  -- power:27	dac:0	mix:12	offset_i:-29	offset_q:42
  -- power:30	dac:3	mix:15	offset_i:-6	offset_q:8
  TX calibration params for rf_chain 1:
  -- power:14	dac:3	mix:10	offset_i:-98	offset_q:35
-------------------------------------------------------------------
INFO: using legacy timestamp
AGC: setting fdd_mode to 1
ARB: dual demodulation disabled for all SF
INFO: found temperature sensor on port 0x40
INFO: AD5338R is configured
sx1302 tx cnt:1
sx1302 tx cnt:2
sx1302 tx cnt:3
sx1302 tx cnt:4
sx1302 tx cnt:5
sx1302 tx cnt:6
sx1302 tx cnt:7
sx1302 tx cnt:8
sx1302 tx cnt:9
sx1302 tx cnt:10
sx1302 tx cnt:11
sx1302 tx cnt:12
sx1302 tx cnt:13
sx1302 tx cnt:14
sx1302 tx cnt:15
sx1302 tx cnt:16
sx1302 tx cnt:17
sx1302 tx cnt:18
sx1302 tx cnt:19
sx1302 tx cnt:20
sx1302 tx cnt:21
sx1302 tx cnt:22
sx1302 tx cnt:23
sx1302 tx cnt:24
sx1302 tx cnt:25
sx1302 tx cnt:26
sx1302 tx cnt:27
sx1302 tx cnt:28
sx1302 tx cnt:29
sx1302 tx cnt:30
sx1302 tx cnt:31
sx1302 tx cnt:32
sx1302 tx cnt:33
sx1302 tx cnt:34
sx1302 tx cnt:35
sx1302 tx cnt:36
sx1302 tx cnt:37
sx1302 tx cnt:38
sx1302 tx cnt:39
sx1302 tx cnt:40
sx1302 tx cnt:41
sx1302 tx cnt:42
sx1302 tx cnt:43
sx1302 tx cnt:44
sx1302 tx cnt:45
sx1302 tx cnt:46
sx1302 tx cnt:47
sx1302 tx cnt:48
sx1302 tx cnt:49
sx1302 tx cnt:50
sx1302 tx cnt:51
sx1302 tx cnt:52
sx1302 tx cnt:53
sx1302 tx cnt:54

@guo652917087
Copy link
Author

guo652917087 commented Nov 18, 2024

Updated test program, at 30dbm, using 2dBi antenna, there is 100% probability of error.


/* fix an issue between POSIX and C99 */
#if __STDC_VERSION__ >= 199901L
#define _XOPEN_SOURCE 600
#else
#define _XOPEN_SOURCE 500
#endif

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <signal.h>     /* sigaction */
#include <pthread.h>
#include <inttypes.h>

#include "loragw_hal.h"
#include "loragw_reg.h"
#include "loragw_aux.h"

static int exit_sig = 0; /* 1 -> application terminates cleanly (shut down hardware, close open files, etc) */
static int quit_sig = 0; /* 1 -> application terminates without shutting down the hardware */
static pthread_mutex_t mx_concent = PTHREAD_MUTEX_INITIALIZER; /* control access to timer sync offsets */

/* handle signals */
static void sig_handler ( int sigio )
{
    if ( sigio == SIGQUIT )
    {
        quit_sig = 1;
    }
    else if ( ( sigio == SIGINT ) || ( sigio == SIGTERM ) )
    {
        exit_sig = 1;
    }
}

void thread_check_time_counter_slip ( void )
{
    uint32_t before_inst_tstamp = 0;
    uint32_t trig_tstamp = 0;
    uint32_t inst_tstamp = 0;

    lgw_get_instcnt ( &before_inst_tstamp );

    int diff_us = 0;
    int system_delay = 500000; //The sleep time error will never exceed
    int count = 0;
    time_t cur_time;
    struct tm tm_time;
    int x;

    while ( !exit_sig && !quit_sig )
    {
        pthread_mutex_lock ( &mx_concent );
        x  = lgw_get_instcnt ( &inst_tstamp );
        x |= lgw_get_trigcnt ( &trig_tstamp );
        pthread_mutex_unlock ( &mx_concent );

        if ( x != 0 )
        {
            printf ( "get SX1302 counter err\n" );
            exit ( EXIT_FAILURE );
        }

        diff_us = inst_tstamp - before_inst_tstamp;

        //## print timestamp
        cur_time = time ( NULL );
        localtime_r ( &cur_time, &tm_time );
        printf ( "INFO: %d-%02d-%02d %02d:%02d:%02d		SX1302 counter (INST): %u	,SX1302 counter (PPS):  %u\r\n",
                 1900 + tm_time.tm_year, 1 + tm_time.tm_mon,
                 tm_time.tm_mday, tm_time.tm_hour,
                 tm_time.tm_min, tm_time.tm_sec , inst_tstamp, trig_tstamp );

        if ( diff_us > ( 1000000 + system_delay ) )
        {
            printf ( "######Loki says:SX1302 time slips!!!!Time jumped %d seconds#####\r\n", diff_us / 1000000 );
            count++;
        }

        if ( count > 5 )
        {
            printf ( "######Loki says:check time slips too much!!!!#####\r\n" );
            exit ( EXIT_FAILURE );
        }

        before_inst_tstamp = inst_tstamp;

        // sleep 1 s
        wait_ms ( 1000 );
    }
}

void thread_sx1302_rx ( void )
{
    uint8_t max_rx_pkt = 16;

    /* set the buffer size to hold received packets */
    struct lgw_pkt_rx_s rxpkt[max_rx_pkt];
    int nb_pkt = 0;
    int i, j;

    while ( !exit_sig && !quit_sig )
    {
        pthread_mutex_lock ( &mx_concent );
        nb_pkt = lgw_receive ( max_rx_pkt, rxpkt );
        pthread_mutex_unlock ( &mx_concent );

        if ( nb_pkt > 0 )
        {
            for ( i = 0; i < nb_pkt; i++ )
            {
                printf ( "\n----- %s packet -----\n", ( rxpkt[i].modulation == MOD_LORA ) ? "LoRa" : "FSK" );
                printf ( "  count_us: %u\n", rxpkt[i].count_us );
                printf ( "  size:     %u\n", rxpkt[i].size );
                printf ( "  chan:     %u\n", rxpkt[i].if_chain );
                printf ( "  status:   0x%02X\n", rxpkt[i].status );
                printf ( "  datr:     %u\n", rxpkt[i].datarate );
                printf ( "  codr:     %u\n", rxpkt[i].coderate );
                printf ( "  rf_chain  %u\n", rxpkt[i].rf_chain );
                printf ( "  freq_hz   %u\n", rxpkt[i].freq_hz );
                printf ( "  snr_avg:  %.1f\n", rxpkt[i].snr );
                printf ( "  rssi_chan:%.1f\n", rxpkt[i].rssic );
                printf ( "  rssi_sig :%.1f\n", rxpkt[i].rssis );
                printf ( "  crc:      0x%04X\n", rxpkt[i].crc );

                for ( j = 0; j < rxpkt[i].size; j++ )
                {
                    printf ( "%02X ", rxpkt[i].payload[j] );
                }

                printf ( "\n" );
            }
        }

        wait_ms ( 5 );
    }
}
/* -------------------------------------------------------------------------- */
/* --- MAIN FUNCTION -------------------------------------------------------- */

int main ( void )
{
    int i, x;
    struct lgw_conf_board_s boardconf;
    struct lgw_pkt_tx_s pkt;
    struct lgw_tx_gain_lut_s txlut; /* TX gain table */
    uint8_t tx_status;
    static struct sigaction sigact; /* SIGQUIT&SIGINT&SIGTERM signal handling */

    /* Initialize TX gain LUT */
    txlut.size = 0;
    memset ( txlut.lut, 0, sizeof txlut.lut );
    txlut.size = 4;
    txlut.lut[0].rf_power = 20;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[0].pa_gain = 1;
    txlut.lut[0].dac_gain = 0;
    txlut.lut[0].mix_gain = 10;
    txlut.lut[0].dig_gain = 0;
    txlut.lut[1].rf_power = 23;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[1].pa_gain = 1;
    txlut.lut[1].dac_gain = 0;
    txlut.lut[1].mix_gain = 11;
    txlut.lut[1].dig_gain = 1;

    txlut.lut[2].rf_power = 27;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[2].pa_gain = 1;
    txlut.lut[2].dac_gain = 0;
    txlut.lut[2].mix_gain = 12;
    txlut.lut[2].dig_gain = 0;

    txlut.lut[3].rf_power = 30;// Use spectrum analyzer to test the actual output radiation power
    txlut.lut[3].pa_gain = 1;
    txlut.lut[3].dac_gain = 3;
    txlut.lut[3].mix_gain = 15;
    txlut.lut[3].dig_gain = 0;

    const int32_t channel_if_mode0[9] =
    {
        -300000,
        -100000,
        100000,
        300000,
        -300000,
        -100000,
        100000,
        300000,
        -200000 /* lora service */
    };

    const uint8_t channel_rfchain_mode0[9] = { 0, 0, 0, 0, 1, 1, 1, 1, 1 };

    /* Configure signal handling */
    sigemptyset ( &sigact.sa_mask );
    sigact.sa_flags = 0;
    sigact.sa_handler = sig_handler;
    sigaction ( SIGQUIT, &sigact, NULL );
    sigaction ( SIGINT, &sigact, NULL );
    sigaction ( SIGTERM, &sigact, NULL );

    struct lgw_conf_rxrf_s rfconf;
    struct lgw_conf_rxif_s ifconf;

    /* Configure the gateway */
    memset ( &boardconf, 0, sizeof boardconf );
    boardconf.lorawan_public = true;
    boardconf.clksrc = 0;
    boardconf.full_duplex = 1;
    boardconf.com_type = LGW_COM_SPI;
    strncpy ( boardconf.com_path, "/dev/spidev0.0", sizeof boardconf.com_path );

    boardconf.com_path[sizeof boardconf.com_path - 1] = '\0'; /* ensure string termination */

    if ( lgw_board_setconf ( &boardconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure board\n" );
        return EXIT_FAILURE;
    }


    /* set configuration for RF chains */
    memset ( &rfconf, 0, sizeof rfconf );
    rfconf.enable = true;
    rfconf.freq_hz = 488200000;
    rfconf.type = LGW_RADIO_TYPE_SX1255;
    rfconf.tx_enable = true;
    rfconf.single_input_mode = 0;
    rfconf.rssi_offset = -203.0;
    rfconf.rssi_tcomp.coeff_a = 0;
    rfconf.rssi_tcomp.coeff_b = 0;
    rfconf.rssi_tcomp.coeff_c = -39.78;
    rfconf.rssi_tcomp.coeff_d = 1349.50;
    rfconf.rssi_tcomp.coeff_e = 0;

    rfconf.tx_enable = true;

    if ( lgw_rxrf_setconf ( 0, &rfconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure rxrf 0\n" );
        return EXIT_FAILURE;
    }

    memset ( &rfconf, 0, sizeof rfconf );
    rfconf.enable = true;
    rfconf.freq_hz = 489000000;
    rfconf.type = LGW_RADIO_TYPE_SX1255;
    rfconf.tx_enable = false;
    rfconf.single_input_mode = 0;
    rfconf.rssi_offset = -205.5;
    rfconf.rssi_tcomp.coeff_a = 0;
    rfconf.rssi_tcomp.coeff_b = 0;
    rfconf.rssi_tcomp.coeff_c = 9.97;
    rfconf.rssi_tcomp.coeff_d = -2748.33;
    rfconf.rssi_tcomp.coeff_e = 0;

    if ( lgw_rxrf_setconf ( 1, &rfconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure rxrf 1\n" );
        return EXIT_FAILURE;
    }

    /* set configuration for LoRa multi-SF channels (bandwidth cannot be set) */
    memset ( &ifconf, 0, sizeof ( ifconf ) );

    for ( i = 0; i < 8; i++ )
    {
        ifconf.enable = true;
        ifconf.rf_chain = channel_rfchain_mode0[i];
        ifconf.freq_hz = channel_if_mode0[i];

        if ( lgw_rxif_setconf ( i, &ifconf ) != LGW_HAL_SUCCESS )
        {
            printf ( "ERROR: failed to configure rxif %d\n", i );
            return EXIT_FAILURE;
        }
		else
		{
			printf ( "INFO: configure rxif %d\n", i );
		}
    }

    ifconf.datarate = DR_LORA_SF7;

    /* set configuration for LoRa Service channel */
    memset ( &ifconf, 0, sizeof ( ifconf ) );
    ifconf.rf_chain = channel_rfchain_mode0[i];
    ifconf.freq_hz = channel_if_mode0[i];
    ifconf.datarate = DR_LORA_SF7;
    ifconf.bandwidth = BW_250KHZ;

    if ( lgw_rxif_setconf ( 8, &ifconf ) != LGW_HAL_SUCCESS )
    {
        printf ( "ERROR: failed to configure rxif for LoRa service channel\n" );
        return EXIT_FAILURE;
    }

    if ( txlut.size > 0 )
    {
        if ( lgw_txgain_setconf ( 0, &txlut ) != LGW_HAL_SUCCESS )
        {
            printf ( "ERROR: failed to configure txgain lut\n" );
            return EXIT_FAILURE;
        }
    }

    /* Send packets */
    memset ( &pkt, 0, sizeof pkt );
    pkt.rf_chain = 0;
    pkt.freq_hz = 501300000;
    pkt.rf_power = 30; // 20/23 time no slip,but 27/30 sx1302 time slip
    pkt.tx_mode = IMMEDIATE;//TIMESTAMPED
    pkt.modulation = MOD_LORA;
    pkt.coderate = CR_LORA_4_5;
    pkt.no_crc = true;

    pkt.invert_pol = 1;
    pkt.preamble = 8;
    pkt.no_header = 0;
    pkt.payload[0] = 0x40; /* Confirmed Data Up */
    pkt.payload[1] = 0xAB;
    pkt.payload[2] = 0xAB;
    pkt.payload[3] = 0xAB;
    pkt.payload[4] = 0xAB;
    pkt.payload[5] = 0x00; /* FCTrl */
    pkt.payload[6] = 0; /* FCnt */
    pkt.payload[7] = 0; /* FCnt */
    pkt.payload[8] = 0x02; /* FPort */

    for ( i = 9; i < 255; i++ )
    {
        pkt.payload[i] = i;
    }

    pkt.datarate = 7;
    pkt.bandwidth = BW_125KHZ;
    pkt.size = 220;

    pkt.payload[6] = 0; /* FCnt */
    pkt.payload[7] = 0; /* FCnt */

    x = lgw_start();

    if ( x != 0 )
    {
        printf ( "ERROR: failed to start the gateway\n" );
        return EXIT_FAILURE;
    }

    uint64_t eui;

    x = lgw_get_eui ( &eui );

    if ( x != 0 )
    {
        printf ( "ERROR: failed to get concentrator EUI\n" );
    }
    else
    {
        printf ( "INFO: concentrator EUI: 0x%016" PRIx64 "\n", eui );
    }

    pthread_t thrid_time_slip;
    pthread_t thrid_rx;

    i = pthread_create ( &thrid_time_slip, NULL, ( void * ( * ) ( void * ) ) thread_check_time_counter_slip, NULL );

    if ( i != 0 )
    {
        printf ( "ERROR: [main] impossible to create time counter slip thread\n" );
        exit ( EXIT_FAILURE );
    }

    i = pthread_create ( &thrid_rx, NULL, ( void * ( * ) ( void * ) ) thread_sx1302_rx, NULL );

    if ( i != 0 )
    {
        printf ( "ERROR: [main] impossible to create sx1302 rx thread\n" );
        exit ( EXIT_FAILURE );
    }

    unsigned long send_pkt_cnt = 0;

    while ( ( quit_sig != 1 ) && ( exit_sig != 1 ) )
    {
        pthread_mutex_lock ( &mx_concent );
        lgw_status ( 0, TX_STATUS, &tx_status ); /* get TX status */
        pthread_mutex_unlock ( &mx_concent );

        if ( tx_status == TX_FREE )
        {

            pkt.payload[6] = ( uint8_t ) ( send_pkt_cnt >> 0 ); /* FCnt */
            pkt.payload[7] = ( uint8_t ) ( send_pkt_cnt >> 8 ); /* FCnt */

            x = lgw_send ( &pkt );

            if ( x == 0 )
            {
                send_pkt_cnt += 1;
                printf ( "INFO: sx1302 tx cnt:%lu,rf_power:%d\n", send_pkt_cnt , pkt.rf_power );
            }

        }

        wait_ms ( 20 );
    }

    /* Stop the gateway */
    x = lgw_stop();

    if ( x != 0 )
    {
        printf ( "ERROR: failed to stop the gateway\n" );
        return EXIT_FAILURE;
    }

    printf ( "=========== Test End ===========\n" );

    return 0;
}

/* --- EOF ------------------------------------------------------------------ */

console log:

root@Gateway:~# reset_lgw.sh start 1
root@Gateway:~# /tmp/sx1302_full_test 
Opening SPI communication interface
Note: chip version is 0x10 (v1.0)
CAL FW VERSION: 1
CAL: started

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:7 phi:13

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:18 phi:-2

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:16 phi:10

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:10 phi:2

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:9 phi:3

sx125x_cal_rx_image: rf_chain:0, freq_hz:488200000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:0 amp:10 phi:2

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:3 phi:11

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:-1 phi:7

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:0, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:2 phi:4

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:4 phi:0

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:4 phi:0

sx125x_cal_rx_image: rf_chain:1, freq_hz:489000000, loopback:1, radio_type:1
sx125x_cal_rx_image, RESULT: rf_chain:1 amp:4 phi:1

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:86 offset_q:74 rej:50

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:87 offset_q:73 rej:52

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:10, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:87 offset_q:73 rej:50

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:69 offset_q:58 rej:50

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:68 offset_q:57 rej:44

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:11, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:69 offset_q:58 rej:50

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:54 offset_q:46 rej:66

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:54 offset_q:46 rej:54

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:0, mix_gain:12, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:54 offset_q:46 rej:60

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:10 offset_q:9 rej:48

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:10 offset_q:9 rej:47

sx125x_cal_tx_dc_offset: rf_chain:0, freq_hz:488200000, dac_gain:3, mix_gain:15, radio_type:1
sx125x_cal_tx_dc_offset: RESULT: offset_i:10 offset_q:9 rej:48
-------------------------------------------------------------------
Radio calibration completed:
  RadioA: amp:10 phi:2
  RadioB: amp:4 phi:0
  TX calibration params for rf_chain 0:
  -- power:20   dac:0   mix:10  offset_i:87     offset_q:73
  -- power:23   dac:0   mix:11  offset_i:69     offset_q:58
  -- power:27   dac:0   mix:12  offset_i:54     offset_q:46
  -- power:30   dac:3   mix:15  offset_i:10     offset_q:9
  TX calibration params for rf_chain 1:
  -- power:14   dac:3   mix:10  offset_i:-95    offset_q:8
-------------------------------------------------------------------
INFO: using legacy timestamp
AGC: setting fdd_mode to 1
ARB: dual demodulation disabled for all SF
INFO: found temperature sensor on port 0x40
INFO: AD5338R is configured
INFO: AD5338R: Set DAC output to 0x00 0x00
INFO: concentrator EUI: 0x0016c001f119282a
INFO: AD5338R: Set DAC output to 0x80 0x80
INFO: 2024-11-18 15:18:32               SX1302 counter (INST): 136798998        ,SX1302 counter (PPS):  0
######Loki says:SX1302 time slips!!!!Time jumped 134 seconds#####
INFO: sx1302 tx cnt:1,rf_power:30
INFO: syncword not found at idx 0
INFO: syncword not found at idx 1
INFO: syncword not found at idx 2
INFO: syncword not found at idx 3
INFO: syncword not found at idx 4
INFO: syncword not found at idx 5
INFO: syncword not found at idx 6
INFO: syncword not found at idx 7
INFO: syncword not found at idx 8
INFO: syncword not found at idx 9
INFO: syncword not found at idx 10
INFO: syncword not found at idx 11
INFO: syncword not found at idx 12
INFO: syncword not found at idx 13
INFO: syncword not found at idx 14
INFO: syncword not found at idx 15
INFO: syncword not found at idx 16
INFO: syncword not found at idx 17
INFO: syncword not found at idx 18
INFO: syncword not found at idx 19
INFO: syncword not found at idx 20
INFO: syncword not found at idx 21
INFO: syncword not found at idx 22
INFO: syncword not found at idx 23
INFO: syncword not found at idx 24
INFO: syncword not found at idx 25
INFO: syncword not found at idx 26
....
ERROR: Failed to read RX buffer, SPI error
ERROR: Failed to fetch RX buffer
ERROR: failed to fetch packets from SX1302
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
ERROR: failed to read I2C device 0x40 (err=-1)
ERROR: failed to get current temperature
Note: remaining 165 packets in RX buffer, do not fetch sx1302 yet...
ERROR: Failed to get timestamp counter value
WARNING: not enough space allocated, fetched 165 packet(s), 149 will be left in RX buffer
Segmentation fault

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant