diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 15 | ||||
| -rw-r--r-- | include/Device/Device.h | 254 | ||||
| -rw-r--r-- | include/Fpga/Fpga.h | 74 | ||||
| -rw-r--r-- | include/General.h | 87 | ||||
| -rw-r--r-- | include/Utility/Utility.h | 43 | ||||
| -rw-r--r-- | src/AccessoryCards/AccessoryCard.cpp | 26 | ||||
| -rw-r--r-- | src/AccessoryCards/AcessoryCard.cpp | 21 | ||||
| -rw-r--r-- | src/AccessoryCards/Gpiob.cpp | 36 | ||||
| -rw-r--r-- | src/AccessoryCards/LoraCard.cpp | 38 | ||||
| -rw-r--r-- | src/AccessoryCards/LoraCard03.cpp | 53 | ||||
| -rw-r--r-- | src/AccessoryCards/LoraCard10.cpp | 38 | ||||
| -rw-r--r-- | src/AccessoryCards/LoraCard15.cpp | 195 | ||||
| -rw-r--r-- | src/AccessoryCards/LoraCard21.cpp | 48 | ||||
| -rw-r--r-- | src/AccessoryCards/LoraCard21Ext.cpp | 42 | ||||
| -rw-r--r-- | src/AccessoryCards/LoraCard2G4.cpp | 32 | ||||
| -rw-r--r-- | src/AccessoryCards/Mfser.cpp | 47 | ||||
| -rw-r--r-- | src/AccessoryCards/Mtac15Fpga.cpp | 803 | ||||
| -rw-r--r-- | src/Device/Device.cpp | 434 | ||||
| -rw-r--r-- | src/MtsIoSysfs.cpp | 261 | ||||
| -rw-r--r-- | src/Version.cpp | 4 |
21 files changed, 1893 insertions, 660 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c84646 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +src/Version.cpp @@ -33,11 +33,11 @@ SOURCEDIR=src CFLAGS += -Werror -Wno-unused-function -CXXFLAGS += -std=c++11 -Wno-unused-function +CXXFLAGS += -std=c++14 -Wno-unused-function -LIBS := -lmts -lrt +LIBS := -lmts -lrt -lssl -lcrypto -INC=-Iinclude -Iinclude/Utility -Iinclude/AccessoryCards -Iinclude/Device +INC=-Iinclude -Iinclude/Utility -Iinclude/AccessoryCards -Iinclude/Device -Iinclude/Fpga INCLUDES = $(wildcard include/*.h) SOURCES = $(wildcard $(SOURCEDIR)/**/*.cpp) SOURCES += $(SOURCEDIR)/Version.cpp @@ -46,7 +46,7 @@ OBJS = $(patsubst $(SOURCEDIR)/%.c,$(BUILDDIR)/%.o,$(OBJS1)) CPP_DEPPS = $(patsubst $(SOURCEDIR)/%.cpp,$(BUILDDIR)/**/%.d,$(SOURCES)) CPP_DEPPS += $(BUILDDIR)/*.o $(BUILDDIR)/*.d $(BUILDDIR)/**/*.o $(BUILDDIR)/**/*.d JS_OBJS = $(BUILDDIR)/Version.o -OUT_DIRS=build/AccessoryCards build/Device +OUT_DIRS=build/AccessoryCards build/Device build/Fpga MKDIR_P = mkdir -p ifndef MTS_CHECK @@ -85,7 +85,7 @@ mts-io-sysfs: $(OBJS) $(BUILDDIR)/MtsIoSysfs.o $(BUILDDIR)/%.o: $(SOURCEDIR)/%.cpp @echo 'Building file: $<' - $(CXX) $(CFLAGS) $(INC) -Wall -std=c++11 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" + $(CXX) $(CFLAGS) $(INC) -Wall -std=c++14 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' @@ -103,13 +103,10 @@ $(SOURCEDIR)/Version.cpp: $(BUILDDIR)/MtsIo.o: $(SOURCEDIR)/MtsIo.cpp @echo 'Building file: $<' - $(CXX) $(CFLAGS) $(INC) -Wall -std=c++11 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" -DENABLE_MTS_CHECK=${MTS_CHECK} + $(CXX) $(CFLAGS) $(INC) -Wall -std=c++14 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" -DENABLE_MTS_CHECK=${MTS_CHECK} @echo 'Finished building: $<' @echo ' ' -install: - mkdir -p $(DESTDIR)/opt/lora - strip: $(STRIP) -S --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag $(BUILDDIR)/mts-io-sysfs diff --git a/include/Device/Device.h b/include/Device/Device.h index 198cc67..5f2bf12 100644 --- a/include/Device/Device.h +++ b/include/Device/Device.h @@ -1,113 +1,163 @@ #ifndef DEVICE_H_ #define DEVICE_H_ +#include "Fpga.h" #include "General.h" #include "Utility.h" #include "Version.h" +#include <math.h> /* ceil */ + +class Mtac15Fpga; class Device { - private: - bool verbose ; - bool isRoot; - rapidjson::Document capabilities; - rapidjson::Document ethSwitch; - rapidjson::Document deviceInfo; - static const std::vector<std::string> apIdentifiers; - rapidjson::Document accessoryCards; - rapidjson::Value accessoryCard; - rapidjson::Document::AllocatorType& alloc = deviceInfo.GetAllocator(); - rapidjson::Document::AllocatorType& accessoryCardsAlloc = accessoryCards.GetAllocator(); - static std::map<std::string, bool> capabilityList; - static std::map<std::string, std::string> ethSwitchList; - static std::map<std::string, std::string> deviceInfoList; - - static const std::regex apFilters; - static const std::regex lora15Filters; - static const std::regex loraG16Filters; - static const std::regex loraG64Filters; - static const std::regex gpiobFilters; - static const std::regex mfserFilters; - static const std::regex serialModeFilter; - static const std::regex storeFilters; - static const std::regex showFilters; - - class AccessoryCard { - protected: - Device& device; - const std::string productId; - const std::string port; - public: - AccessoryCard(Device& d, const std::string ProductId, const std::string Port); - }; - - class LoraCard : public AccessoryCard { - protected: - std::string spiPath; - uint8_t fpgaVersion = 255; - public: - LoraCard(Device& d, const std::string ProductId, const std::string Port); - void setCapabilities(); - }; - - class Lora15Card : public LoraCard { - private: - void *spi_target_ptr = NULL; - public: - Lora15Card(Device& d, const std::string ProductId, const std::string Port); - int spiOpen(const char *spidev); - int spiRead(uint8_t address, uint8_t *data); - int spiClose(); - }; - - class Lora21Card : public LoraCard { - private: - std::string cmdFpgaVersion; - public: - Lora21Card(Device& d, const std::string ProductId, const std::string Port); - }; - - class Lora21ExtCard : public Lora21Card { - private: - std::string cmdFpgaVersion2; - public: - Lora21ExtCard(Device& d, const std::string ProductId, const std::string Port); - }; - - class Gpiob : public AccessoryCard { - public: - Gpiob(Device& d, const std::string ProductId, const std::string Port); - }; - - class Mfser : public AccessoryCard { - public: - Mfser(Device& d, const std::string ProductId, const std::string Port); - }; - - public: - Device(); - void getSystemTreeJson(const char * dir_name); - void init(); - bool isAccessoryCard(const char * d_name, const char * dir_name); - bool isValidDirectory(const struct dirent * entry, std::string fullPath, const char * d_name); - void load(); - void logInfo(std::string info); - void logError(std::string info); - void json(); - void mapFileToCapability(); - void mapFirmware(); - void mapMacAddress2(); - void printDir(const std::string dir_name, std::vector<std::string> &results); - void printJson(); - void printVersion (std::string name); - void printUsage(std::string program); - void show(std::string program); - void showTrigger(std::string name); - void sortAccessoryCards(); - void store(std::string name, std::string value); - void storeTrigger(std::string name, std::string value); - void Verbose(bool val); - bool Verbose(); - void writeJson(); + private: + bool isRoot; + rapidjson::Document capabilities; + rapidjson::Document ethSwitch; + rapidjson::Document deviceInfo; + static const std::vector<std::string> apIdentifiers; + rapidjson::Document accessoryCards; + rapidjson::Value accessoryCard; + rapidjson::Document::AllocatorType &alloc = deviceInfo.GetAllocator(); + rapidjson::Document::AllocatorType &acAlloc = accessoryCards.GetAllocator(); + static std::map<std::string, bool> capabilityList; + static std::map<std::string, std::string> ethSwitchList; + static std::map<std::string, std::string> deviceInfoList; + + static const std::regex apFilters; + static const std::regex serialModeFilter; + static const std::regex storeFilters; + static const std::regex showFilters; + static const std::regex mtcdt3Filters; + static const std::regex mtrFilters; + + const unsigned int accessoryCardsListSize = 7; + + class AccessoryCard { + protected: + Device &device; + std::regex name; + + public: + AccessoryCard(Device &d, const std::regex Name); + virtual void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + const std::regex GetName(); + }; + + class LoraCard : public AccessoryCard { + protected: + std::string spiPath; + uint8_t fpgaVersion; + + public: + LoraCard(Device &d, const std::regex Name); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Lora03Card : public LoraCard { + private: + std::string spiPath1261; + uint8_t tmp102; + + public: + Lora03Card(Device &d); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Lora10Card : public LoraCard { + public: + Lora10Card(Device &d); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Lora15Card : public LoraCard { + private: + Lora15Card(); + void *spi_target_ptr = NULL; + const char pin_high = '1'; + const char pin_low = '0'; + + public: + Lora15Card(Device &d); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Lora21Card : public LoraCard { + private: + std::string cmdFpgaVersion; + + public: + Lora21Card(Device &d); + Lora21Card(Device &d, const std::regex Name); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Lora21ExtCard : public Lora21Card { + private: + std::string cmdFpgaVersion2; + + public: + Lora21ExtCard(Device &d); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Lora2G4Card : public LoraCard { + public: + Lora2G4Card(Device &d); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Gpiob : public AccessoryCard { + public: + Gpiob(Device &d); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + class Mfser : public AccessoryCard { + public: + Mfser(Device &d); + void AddToDeviceInfo(const std::string Port, + const std::string ProductID); + }; + + std::vector<std::unique_ptr<AccessoryCard>> accessoryCardsList; + + public: + Device(); + void getSystemTreeJson(const char *dir_name); + void init(); + bool isAccessoryCard(const char *d_name, const char *dir_name); + bool isValidDirectory(const struct dirent *entry, std::string fullPath, + const char *d_name); + void load(); + void logInfo(std::string info); + void logError(std::string info); + void json(); + void mapFileToCapability(); + void mapFirmware(); + void mapMacAddress2(); + void printDir(const std::string dir_name, + std::vector<std::string> &results); + void printJson(); + void printVersion(std::string name); + void printUsage(std::string program); + void show(std::string program); + void showTrigger(std::string name); + void sortAccessoryCards(); + void store(std::string name, std::string value); + void storeTrigger(std::string name, std::string value); + void Verbose(bool val); + bool Verbose(); + void writeJson(); }; #endif /* DEVICE_H_ */ diff --git a/include/Fpga/Fpga.h b/include/Fpga/Fpga.h new file mode 100644 index 0000000..986a269 --- /dev/null +++ b/include/Fpga/Fpga.h @@ -0,0 +1,74 @@ +#ifndef FPGA_H_ +#define FPGA_H_ + +#include "General.h" +#include "Utility.h" +#include "Version.h" +#include <math.h> /* ceil */ +#include <openssl/sha.h> /* generate hash */ + +#define MTAC_SX1301 0x0 +#define MTAC_FPGA 0x1 + +#define MTAC_FPGA_ADDRESS 0x1 +#define READ_ACCESS 0x00 +#define WRITE_ACCESS 0x80 +#define SPI_SPEED 8000000 + +#define MTAC_PAGE_REG 0 +#define MTAC_SOFT_RESET 1 +#define MTAC_VERSION 2 + +#define MTCDT_DEFAULT_FILE "/usr/lib/mts-flash-binaries/mtcdt-fpga-v31.hex" +#define MTCAP_DEFAULT_FILE "/usr/lib/mts-flash-binaries/mtcap-fpga-v31.hex" + +struct mtac_reg_s { + int8_t page; /*!< page containing the register (-1 for all pages) */ + uint8_t addr; /*!< base address of the register (7 bit) */ + uint8_t offs; /*!< position of the register LSB (between 0 to 7) */ + bool sign; /*!< 1 indicates the register is signed (2 complem.) */ + uint8_t leng; /*!< number of bits in the register */ + bool rdon; /*!< 1 indicates a read-only register */ + int32_t dflt; /*!< register default value */ +}; + +class Mtac15Fpga { + private: + HardwareType hardwareType = HARDWARE_INVALID; + void *spi_target_ptr = NULL; + const char pin_high = '1'; + const char pin_low = '0'; + std::string port; + std::string spiPath; + std::string input_file; + uint8_t fpgaVersion; + rapidjson::Document deviceInfo; + rapidjson::Document::AllocatorType &alloc = deviceInfo.GetAllocator(); + + void sha256_hash_string(unsigned char hash[SHA256_DIGEST_LENGTH], + char outputBuffer[65]); + void sha256(char *string, char outputBuffer[65]); + int sha256_file(const char *path); + int spiOpen(); + int spiRead(uint8_t spi_mux_target, uint8_t address, uint8_t *data); + int spiWrite(uint8_t spi_mux_target, uint8_t address, uint8_t data); + int spiClose(); + int busContention(); + int cresetWrite(char num); + int releaseDevice(); + int writeEnable(); + int chipEraseVerify(); + int chipErase(); + int mtacErase(); + int pageProgram(uint8_t adr_lower, uint8_t adr_higher, uint32_t data[256]); + int mtacProgram(const char input_file[]); + + public: + Mtac15Fpga(std::string inputFile, std::string forcedPath); + Mtac15Fpga(std::string path); + int getFpgaVersion(); + int FpgaVersion(); + int upgradeFpga(); +}; + +#endif /* FPGA_H_ */ diff --git a/include/General.h b/include/General.h index c5be2ff..e45f06a 100644 --- a/include/General.h +++ b/include/General.h @@ -2,7 +2,7 @@ #define GENERAL_HPP #ifdef _MSC_VER -#pragma warning ( disable : 4514 4512 4710 4355) +#pragma warning(disable : 4514 4512 4710 4355) #endif typedef signed char sint8; @@ -13,71 +13,68 @@ typedef signed int sint32; typedef unsigned int uint32; typedef signed long long sint64; typedef unsigned long long uint64; -typedef signed int sint; //32 bit - even on 64 bit machines -typedef unsigned int uint; //32 bit - even on 64 bit machines +typedef signed int sint; // 32 bit - even on 64 bit machines +typedef unsigned int uint; // 32 bit - even on 64 bit machines -#define memzero(ptr) memset(ptr,0,sizeof(*(ptr))) -#define ArrayZero(ptr,elements) memset(ptr,0,sizeof(*(ptr)) * (elements)) +#define memzero(ptr) memset(ptr, 0, sizeof(*(ptr))) +#define ArrayZero(ptr, elements) memset(ptr, 0, sizeof(*(ptr)) * (elements)) +#include <mts/MTS_Logger.h> #include <mts/MTS_System.h> #include <mts/MTS_Text.h> +#include <dirent.h> +#include <fcntl.h> /* open */ #include <fstream> #include <iostream> -#include <stdlib.h> -#include <stdio.h> /* printf fprintf */ -#include <fcntl.h> /* open */ #include <linux/spi/spidev.h> -#include <sys/ioctl.h> -#include <unistd.h> /* lseek, close */ -#include <dirent.h> #include <regex> +#include <stdio.h> /* printf fprintf */ +#include <stdlib.h> +#include <sys/ioctl.h> #include <sys/stat.h> - +#include <unistd.h> /* lseek, close */ +#include <getopt.h> /* command line parser */ #include "rapidjson/document.h" -#include "rapidjson/writer.h" -#include "rapidjson/stringbuffer.h" +#include "rapidjson/filereadstream.h" #include "rapidjson/istreamwrapper.h" +#include "rapidjson/stringbuffer.h" +#include "rapidjson/writer.h" -#define MAX_ACC_CARDS 4 - -#define VERBOSE false -#define MTS_IO_CONTROLS_STATUS_LED false -#define MTS_IO_CONTROLS_LS_LED false - -#define FIRMWARE_VERSION "Version" -#define FIRMWARE_DATE "Date" - -#define SYSFS_PLATFORM "/sys/devices/platform/mts-io/" -#define HW_VERSION_PATH "/sys/devices/platform/mts-io/hw-version" -#define LEDS_GPIO_DIR "/sys/devices/platform/leds-gpio/leds/" -#define FIRMWARE_FILE "/etc/issue" - -#define LORA_1_5_AP1_FPGA_VERSION "mts-fpga-loader -p 1 -c | grep version | awk '{printf $4}'" -#define LORA_1_5_AP2_FPGA_VERSION "mts-fpga-loader -p 2 -c | grep version | awk '{printf $4}'" -#define LORA_2_1_FPGA_VERSION "mts-fpga-loader -g | grep version | awk '{printf $4}'" -#define LORA_2_1_EXT_FPGA_VERSION "mts-fpga-loader -b 1 -g | grep version | awk '{printf $4}'" +#define MAX_ACC_CARDS 4 +#define VERBOSE false +#define MTS_IO_CONTROLS_STATUS_LED false +#define MTS_IO_CONTROLS_LS_LED false -#define MTAC_SX1301 0x0 -#define MTAC_FPGA 0x1 +#define FIRMWARE_VERSION "Version" +#define FIRMWARE_DATE "Date" +#define FIRMWARE_RELEASE "Release" -#define MTAC_FPGA_ADDRESS 0x1 +#define SYSFS_PLATFORM "/sys/devices/platform/mts-io/" +#define HW_VERSION_PATH "/sys/devices/platform/mts-io/hw-version" +#define LEDS_GPIO_DIR "/sys/devices/platform/leds-gpio/leds/" +#define FIRMWARE_FILE "/etc/issue" +#define CRESET "/creset" -#define READ_ACCESS 0x00 -#define SPI_SPEED 8000000 +#define LORA_2_1_FPGA_VERSION \ + "mts-fpga-loader -g | grep version | awk '{printf $4}'" +#define LORA_2_1_EXT_FPGA_VERSION \ + "mts-fpga-loader -b 1 -g | grep version | awk '{printf $4}'" -#define DEVICE_INFO_FILE "/var/run/config/device_info.json" -#define RESET_SHORT_CMD "reset_short_handler" -#define RESET_LONG_CMD "reset_long_handler" -#define KILL_SIGNAL "kill -l " +#define DEVICE_INFO_FILE "/var/run/config/device_info.json" +#define RESET_SHORT_CMD "reset_short_handler" +#define RESET_LONG_CMD "reset_long_handler" +#define KILL_SIGNAL "kill -l " +enum HardwareType { + HARDWARE_MTCDT, + HARDWARE_MTCDT3, + HARDWARE_MTCAP, + HARDWARE_INVALID +}; #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - #endif - - - diff --git a/include/Utility/Utility.h b/include/Utility/Utility.h index 8d68baa..caf5661 100644 --- a/include/Utility/Utility.h +++ b/include/Utility/Utility.h @@ -6,34 +6,35 @@ #include <glob.h> /********************************************************************** -* COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. -* -* ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF -* MULTI-TECH SYSTEMS, INC. -* -* MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY -* INFORMATION AND/OR TRADE SECRET. -* -* NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, -* DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL -* INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. -* USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A -* WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. -* -***********************************************************************/ + * COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. + * + * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF + * MULTI-TECH SYSTEMS, INC. + * + * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY + * INFORMATION AND/OR TRADE SECRET. + * + * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, + * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL + * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. + * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A + * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. + * + ***********************************************************************/ inline bool fileExists(std::string file) { struct stat buffer = {}; - return (stat (file.c_str(), &buffer) == 0) ? true : false; + return (stat(file.c_str(), &buffer) == 0) ? true : false; } -inline std::string toCamelCase(const char * d_name) { +inline std::string toCamelCase(const char *d_name) { std::string camelString = strdup(d_name); std::string tempString = ""; - for (size_t x = 0; x < camelString.length(); x++){ - if (camelString[x] == '-' || camelString[x] == '_'){ + for (size_t x = 0; x < camelString.length(); x++) { + if (camelString[x] == '-' || camelString[x] == '_') { tempString = camelString.substr(x + 1, 1); - transform(tempString.begin(), tempString.end(), tempString.begin(), toupper); + transform(tempString.begin(), tempString.end(), tempString.begin(), + toupper); camelString.erase(x, 2); camelString.insert(x, tempString); } @@ -50,7 +51,7 @@ inline void exitHandler(int code) { inline mode_t fileType(std::string file) { struct stat buf = {}; - if (stat (file.c_str(), &buf) == 0) { + if (stat(file.c_str(), &buf) == 0) { return buf.st_mode & S_IFMT; } else { return -1; diff --git a/src/AccessoryCards/AccessoryCard.cpp b/src/AccessoryCards/AccessoryCard.cpp new file mode 100644 index 0000000..0c7c2a0 --- /dev/null +++ b/src/AccessoryCards/AccessoryCard.cpp @@ -0,0 +1,26 @@ +/********************************************************************** + * COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. + * + * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF + * MULTI-TECH SYSTEMS, INC. + * + * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY + * INFORMATION AND/OR TRADE SECRET. + * + * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, + * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL + * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. + * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A + * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. + * + ***********************************************************************/ + +#include "Device.h" + +Device::AccessoryCard::AccessoryCard(Device &d, const std::regex Name) + : device(d), name(Name) {} + +void Device::AccessoryCard::AddToDeviceInfo(const std::string Port, + const std::string ProductID) {} + +const std::regex Device::AccessoryCard::GetName() { return name; }
\ No newline at end of file diff --git a/src/AccessoryCards/AcessoryCard.cpp b/src/AccessoryCards/AcessoryCard.cpp deleted file mode 100644 index 6a7a0d8..0000000 --- a/src/AccessoryCards/AcessoryCard.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/********************************************************************** -* COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. -* -* ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF -* MULTI-TECH SYSTEMS, INC. -* -* MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY -* INFORMATION AND/OR TRADE SECRET. -* -* NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, -* DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL -* INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. -* USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A -* WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. -* -***********************************************************************/ - -#include "Device.h" - -Device::AccessoryCard::AccessoryCard(Device& d, const std::string ProductId, const std::string Port) : device(d), productId(ProductId), port(Port) { -} diff --git a/src/AccessoryCards/Gpiob.cpp b/src/AccessoryCards/Gpiob.cpp index 44728ae..c580aeb 100644 --- a/src/AccessoryCards/Gpiob.cpp +++ b/src/AccessoryCards/Gpiob.cpp @@ -1,23 +1,27 @@ /********************************************************************** -* COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. -* -* ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF -* MULTI-TECH SYSTEMS, INC. -* -* MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY -* INFORMATION AND/OR TRADE SECRET. -* -* NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, -* DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL -* INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. -* USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A -* WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. -* -***********************************************************************/ + * COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. + * + * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF + * MULTI-TECH SYSTEMS, INC. + * + * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY + * INFORMATION AND/OR TRADE SECRET. + * + * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, + * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL + * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. + * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A + * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. + * + ***********************************************************************/ #include "Device.h" -Device::Gpiob::Gpiob(Device& d, const std::string ProductId, const std::string Port) : AccessoryCard(d, ProductId, Port) { +Device::Gpiob::Gpiob(Device &d) + : AccessoryCard(d, std::regex("(MTAC-GPIOB)|(MMTAC-GPIOI)")) {} + +void Device::Gpiob::AddToDeviceInfo(const std::string Port, + const std::string ProductID) { capabilityList["adc"] = true; capabilityList["din"] = true; capabilityList["dout"] = true; diff --git a/src/AccessoryCards/LoraCard.cpp b/src/AccessoryCards/LoraCard.cpp index 7a248dc..fe2a8d2 100644 --- a/src/AccessoryCards/LoraCard.cpp +++ b/src/AccessoryCards/LoraCard.cpp @@ -1,26 +1,26 @@ /********************************************************************** -* COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. -* -* ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF -* MULTI-TECH SYSTEMS, INC. -* -* MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY -* INFORMATION AND/OR TRADE SECRET. -* -* NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, -* DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL -* INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. -* USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A -* WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. -* -***********************************************************************/ + * COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. + * + * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF + * MULTI-TECH SYSTEMS, INC. + * + * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY + * INFORMATION AND/OR TRADE SECRET. + * + * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, + * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL + * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. + * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A + * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. + * + ***********************************************************************/ #include "Device.h" -Device::LoraCard::LoraCard(Device& d, const std::string ProductId, const std::string Port) : AccessoryCard(d, ProductId, Port), spiPath("/dev/spidev0.0") {} +Device::LoraCard::LoraCard(Device &d, const std::regex Name) + : AccessoryCard(d, Name), spiPath("/dev/spidev0.0"), fpgaVersion(255) {} -void Device::LoraCard::setCapabilities() { +void Device::LoraCard::AddToDeviceInfo(const std::string Port, + const std::string ProductID) { device.capabilityList["lora"] = true; - device.accessoryCard.AddMember("fpgaVersion", fpgaVersion, device.accessoryCardsAlloc); - device.accessoryCard.AddMember("spiPath", rapidjson::Value().SetString(spiPath.c_str(), device.accessoryCardsAlloc), device.accessoryCardsAlloc); }
\ No newline at end of file diff --git a/src/AccessoryCards/LoraCard03.cpp b/src/AccessoryCards/LoraCard03.cpp new file mode 100644 index 0000000..7e9f9ae --- /dev/null +++ b/src/AccessoryCards/LoraCard03.cpp @@ -0,0 +1,53 @@ +/********************************************************************** + * COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. + * + * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF + * MULTI-TECH SYSTEMS, INC. + * + * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY + * INFORMATION AND/OR TRADE SECRET. + * + * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, + * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL + * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. + * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A + * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. + * + ***********************************************************************/ + +#include "Device.h" + +Device::Lora03Card::Lora03Card(Device &d) + : LoraCard(d, std::regex("(MTAC-003)(.*)|(MTCAP3-003)(.*)")) {} + +void Device::Lora03Card::AddToDeviceInfo(const std::string Port, + const std::string ProductID) { + + LoraCard::AddToDeviceInfo(Port, ProductID); + /* Map the spi path to the port/hw version */ + std::string deviceHwVersion = ""; + MTS::System::readFile(HW_VERSION_PATH, deviceHwVersion); + if (deviceHwVersion.find("MTCAP3") != std::string::npos) { + spiPath = "/dev/spidev1.0"; + spiPath1261 = "/dev/spidev1.1"; + tmp102 = 0x48; + } else if (Port.back() == '2') { + spiPath = "/dev/spidev1.0"; + spiPath1261 = "/dev/spidev1.1"; + tmp102 = 0x49; + } else { + spiPath = "/dev/spidev0.0"; + spiPath1261 = "/dev/spidev0.1"; + tmp102 = 0x48; + } + + device.accessoryCard.AddMember( + "spiPath", + rapidjson::Value().SetString(spiPath.c_str(), device.acAlloc), + device.acAlloc); + device.accessoryCard.AddMember( + "spiPath1261", + rapidjson::Value().SetString(spiPath1261.c_str(), device.acAlloc), + device.acAlloc); + device.accessoryCard.AddMember("tmp102", tmp102, device.acAlloc); +}
\ No newline at end of file diff --git a/src/AccessoryCards/LoraCard10.cpp b/src/AccessoryCards/LoraCard10.cpp new file mode 100644 index 0000000..e74b848 --- /dev/null +++ b/src/AccessoryCards/LoraCard10.cpp @@ -0,0 +1,38 @@ +/********************************************************************** + * COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. + * + * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF + * MULTI-TECH SYSTEMS, INC. + * + * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY + * INFORMATION AND/OR TRADE SECRET. + * + * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION, + * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL + * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC. + * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A + * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED. + * + ***********************************************************************/ + +#include "Device.h" + +Device::Lora10Card::Lora10Card(Device &d) + : LoraCard(d, std::regex("(MTAC-LORA-915)|(MTAC-LORA-868)")) {} + +void Device::Lora10Card::AddToDeviceInfo(const std::string Port, + const std::string ProductID) { + + LoraCard::AddToDeviceInfo(Port, ProductID); + + if (Port.back() == '2') { + spiPath = "/dev/spidev1.2"; + } else { + spiPath = "/dev/spidev0.2"; + } + + device.accessoryCard.AddMember( + "spiPath", + rapidjson::Value().SetString(spiPath.c_str(), device.acAlloc), + device.acAlloc); +}
\ No newline at end of file diff --git a/src/AccessoryCards/LoraCard15.cpp b/src/AccessoryCards/LoraCard15.cpp index a7a1dad..3ed0f31 100644 --- a/src/AccessoryCards/LoraCard15.cpp +++ b/src/AccessoryCards/LoraCard15.cpp @@ -1,172 +1,45 @@ /********************************************************************** -* COPYRIGHT 2020 MULTI-TECH SYSTEMS, INC. -* -* ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFI |
