From 6de119daaed517a0916ef889505bc6ccdaa372be Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Wed, 25 Sep 2019 10:21:05 -0500 Subject: Fix loragw reg and spi --- libloragw/src/loragw_reg.c | 2 +- libloragw/src/loragw_spi.native.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libloragw/src/loragw_reg.c b/libloragw/src/loragw_reg.c index 4d689da..e707838 100644 --- a/libloragw/src/loragw_reg.c +++ b/libloragw/src/loragw_reg.c @@ -48,7 +48,7 @@ Maintainer: Sylvain Miermont #define PAGE_ADDR 0x00 #define PAGE_MASK 0x03 -const uint8_t FPGA_VERSION[] = { 28, 31, 32, 33 , 34}; /* several versions could be supported */ +const uint8_t FPGA_VERSION[] = { 28, 31, 32, 33 , 34, 35, 37 }; /* several versions could be supported */ /* auto generated register mapping for C code : 11-Jul-2013 13:20:40 diff --git a/libloragw/src/loragw_spi.native.c b/libloragw/src/loragw_spi.native.c index 4720603..2380ecb 100644 --- a/libloragw/src/loragw_spi.native.c +++ b/libloragw/src/loragw_spi.native.c @@ -56,7 +56,8 @@ Maintainer: Sylvain Miermont #define SPI_SPEED 8000000 #define SPI_DEV_PATH "/dev/spidev0.0" //#define SPI_DEV_PATH "/dev/spidev32766.0" -char spi_dev_path[60] = SPI_DEV_PATH; +//char* spi_dev_path = SPI_DEV_PATH; +static char spi_dev_path[64] = {0}; /* custom SPI device path */ /* -------------------------------------------------------------------------- */ /* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */ @@ -92,9 +93,14 @@ int lgw_spi_open(void **spi_target_ptr) { } /* open SPI device */ + + if (spi_dev_path[0] == '\0'){ + strncpy(spi_dev_path, SPI_DEV_PATH, sizeof(spi_dev_path)-1); //sets default path if none defined + } + dev = open(spi_dev_path, O_RDWR); if (dev < 0) { - DEBUG_PRINTF("ERROR: failed to open SPI device %s\n", SPI_DEV_PATH); + DEBUG_PRINTF("ERROR: failed to open SPI device %s\n", spi_dev_path); return LGW_SPI_ERROR; } -- cgit v1.2.3