diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2020-01-09 12:10:01 -0600 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2020-01-09 12:10:01 -0600 |
commit | 8c7856e74ba7bc149180aa3ab9f820043260cdc8 (patch) | |
tree | 5b8d0f9a6ce3f78fc9caaa5afe107afb4c7d3e81 | |
parent | d32e7c87879f19951b707617cb7291339be86309 (diff) | |
download | mts-io-sysfs-8c7856e74ba7bc149180aa3ab9f820043260cdc8.tar.gz mts-io-sysfs-8c7856e74ba7bc149180aa3ab9f820043260cdc8.tar.bz2 mts-io-sysfs-8c7856e74ba7bc149180aa3ab9f820043260cdc8.zip |
Added spidev as to accessory card object, moved setting capabilities for lora accessory cards to a common base class function
-rw-r--r-- | build/MtsIoSysfs.d | 95 | ||||
-rw-r--r-- | include/AccessoryCards/AccessoryCardLora.h | 16 | ||||
-rw-r--r-- | include/AccessoryCards/AccessoryCardLora15.h | 18 | ||||
-rw-r--r-- | include/Device/Device.h | 11 | ||||
-rw-r--r-- | src/AccessoryCards/LoraCard.cpp | 5 | ||||
-rw-r--r-- | src/AccessoryCards/LoraCard15.cpp | 6 | ||||
-rw-r--r-- | src/AccessoryCards/LoraCard21.cpp | 5 | ||||
-rw-r--r-- | src/AccessoryCards/LoraCard21Ext.cpp | 5 | ||||
-rw-r--r-- | src/Version.cpp | 2 |
9 files changed, 19 insertions, 144 deletions
diff --git a/build/MtsIoSysfs.d b/build/MtsIoSysfs.d deleted file mode 100644 index 48ed255..0000000 --- a/build/MtsIoSysfs.d +++ /dev/null @@ -1,95 +0,0 @@ -build/MtsIoSysfs.d: src/MtsIoSysfs.cpp include/Device/Device.h \ - include/General.h include/rapidjson/document.h \ - include/rapidjson/reader.h include/rapidjson/allocators.h \ - include/rapidjson/rapidjson.h include/rapidjson/stream.h \ - include/rapidjson/encodings.h include/rapidjson/encodedstream.h \ - include/rapidjson/memorystream.h include/rapidjson/internal/meta.h \ - include/rapidjson/internal/../rapidjson.h \ - include/rapidjson/internal/stack.h \ - include/rapidjson/internal/../allocators.h \ - include/rapidjson/internal/swap.h include/rapidjson/internal/strtod.h \ - include/rapidjson/internal/ieee754.h \ - include/rapidjson/internal/biginteger.h \ - include/rapidjson/internal/diyfp.h include/rapidjson/internal/pow10.h \ - include/rapidjson/error/error.h include/rapidjson/error/../rapidjson.h \ - include/rapidjson/internal/strfunc.h \ - include/rapidjson/internal/../stream.h \ - include/rapidjson/internal/../rapidjson.h include/rapidjson/writer.h \ - include/rapidjson/internal/dtoa.h include/rapidjson/internal/itoa.h \ - include/rapidjson/internal/itoa.h include/rapidjson/stringbuffer.h \ - include/rapidjson/stringbuffer.h include/rapidjson/istreamwrapper.h \ - include/Utility/Utility.h include/Version.h \ - include/AccessoryCards/AccessoryCardLora15.h \ - include/AccessoryCards/AccessoryCardLora.h - -include/Device/Device.h: - -include/General.h: - -include/rapidjson/document.h: - -include/rapidjson/reader.h: - -include/rapidjson/allocators.h: - -include/rapidjson/rapidjson.h: - -include/rapidjson/stream.h: - -include/rapidjson/encodings.h: - -include/rapidjson/encodedstream.h: - -include/rapidjson/memorystream.h: - -include/rapidjson/internal/meta.h: - -include/rapidjson/internal/../rapidjson.h: - -include/rapidjson/internal/stack.h: - -include/rapidjson/internal/../allocators.h: - -include/rapidjson/internal/swap.h: - -include/rapidjson/internal/strtod.h: - -include/rapidjson/internal/ieee754.h: - -include/rapidjson/internal/biginteger.h: - -include/rapidjson/internal/diyfp.h: - -include/rapidjson/internal/pow10.h: - -include/rapidjson/error/error.h: - -include/rapidjson/error/../rapidjson.h: - -include/rapidjson/internal/strfunc.h: - -include/rapidjson/internal/../stream.h: - -include/rapidjson/internal/../rapidjson.h: - -include/rapidjson/writer.h: - -include/rapidjson/internal/dtoa.h: - -include/rapidjson/internal/itoa.h: - -include/rapidjson/internal/itoa.h: - -include/rapidjson/stringbuffer.h: - -include/rapidjson/stringbuffer.h: - -include/rapidjson/istreamwrapper.h: - -include/Utility/Utility.h: - -include/Version.h: - -include/AccessoryCards/AccessoryCardLora15.h: - -include/AccessoryCards/AccessoryCardLora.h: diff --git a/include/AccessoryCards/AccessoryCardLora.h b/include/AccessoryCards/AccessoryCardLora.h deleted file mode 100644 index 28f62ff..0000000 --- a/include/AccessoryCards/AccessoryCardLora.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ACCESSORYCARDLORA_H_ -#define ACCESSORYCARDLORA_H_ - -#include "General.h" - -class AccessoryCardLora { - private: - std::string spiPath; - std::string productId; - std::string port; - public: - AccessoryCardLora(std::string ProductId, std::string Port); - std::string getPath(); -}; - -#endif /* ACCESSORYCARDLORA_H_ */ diff --git a/include/AccessoryCards/AccessoryCardLora15.h b/include/AccessoryCards/AccessoryCardLora15.h deleted file mode 100644 index b1a9d64..0000000 --- a/include/AccessoryCards/AccessoryCardLora15.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ACCESSORYCARDLORA15_H_ -#define ACCESSORYCARDLORA15_H_ - -#include "General.h" -#include "AccessoryCardLora.h" - -class AccessoryCardLora15 : private AccessoryCardLora { - private: - void *spi_target_ptr = NULL; - public: - AccessoryCardLora15(std::string ProductId, std::string Port); - int spiOpen(const char *spidev); - int spiRead(uint8_t address, uint8_t *data); - int spiClose(); - uint8_t getFPGAVersion(); -}; - -#endif /* ACCESSORYCARDLORA15_H_ */ diff --git a/include/Device/Device.h b/include/Device/Device.h index aa1d32b..86e284f 100644 --- a/include/Device/Device.h +++ b/include/Device/Device.h @@ -4,7 +4,6 @@ #include "General.h" #include "Utility.h" #include "Version.h" -#include "AccessoryCardLora15.h" class Device { private: @@ -32,7 +31,6 @@ class Device { static const std::regex storeFilters; static const std::regex showFilters; - class AccessoryCard { protected: Device& device; @@ -43,14 +41,15 @@ class Device { class LoraCard : public AccessoryCard { protected: std::string spiPath; + uint8_t fpgaVersion = 255; public: - LoraCard(Device& d, const std::string productId, const std::string port); + LoraCard(Device& d, const std::string productId, const std::string port); + void setCapabilities(); }; class Lora15Card : public LoraCard { private: void *spi_target_ptr = NULL; - uint8_t fpgaVersion = 255; public: Lora15Card(Device& d, const std::string productId, const std::string port); int spiOpen(const char *spidev); @@ -60,14 +59,14 @@ class Device { class Lora21Card : public LoraCard { private: - std::string fpgaVersion; + std::string cmdFpgaVersion; public: Lora21Card(Device& d, const std::string productId, const std::string port); }; class Lora21ExtCard : public Lora21Card { private: - std::string fpgaVersion2; + std::string cmdFpgaVersion2; public: Lora21ExtCard(Device& d, const std::string productId, const std::string port); }; diff --git a/src/AccessoryCards/LoraCard.cpp b/src/AccessoryCards/LoraCard.cpp index ba50aa7..66047f3 100644 --- a/src/AccessoryCards/LoraCard.cpp +++ b/src/AccessoryCards/LoraCard.cpp @@ -19,5 +19,10 @@ Device::LoraCard::LoraCard(Device& d, const std::string productId, const std::string port) : AccessoryCard(d) { spiPath = "/dev/spidev0.0"; +} + +void Device::LoraCard::setCapabilities() { device.capabilityList["lora"] = true; + device.accessoryCard.AddMember("spiPath", rapidjson::Value().SetString(spiPath.c_str(), device.accessoryCardsAlloc), device.accessoryCardsAlloc); + device.accessoryCard.AddMember("fpgaVersion", fpgaVersion, device.accessoryCardsAlloc); }
\ No newline at end of file diff --git a/src/AccessoryCards/LoraCard15.cpp b/src/AccessoryCards/LoraCard15.cpp index df5c969..7d2140b 100644 --- a/src/AccessoryCards/LoraCard15.cpp +++ b/src/AccessoryCards/LoraCard15.cpp @@ -19,8 +19,8 @@ Device::Lora15Card::Lora15Card(Device& d, const std::string productId, const std::string port) : LoraCard(d, productId, port) { int ret; - fpgaVersion = 255; - if ((productId.find("MTCDT3-") == 0) && (port.back() == '2')) { + printf("PORT %s\n", port.c_str()); + if ((productId.rfind("MTCDT3-", 0) == 0 || productId.rfind("MTLGA-", 0) == 0) && (port.back() == '2')) { spiPath = "/dev/spidev1.0"; } else if (productId.find("MTAC-LORA-") == 0) { if (port.back() == '2') { @@ -42,7 +42,7 @@ Device::Lora15Card::Lora15Card(Device& d, const std::string productId, const std spiClose(); spi_target_ptr = NULL; - device.accessoryCard.AddMember("fpgaVersion", fpgaVersion, device.accessoryCardsAlloc); + setCapabilities(); } int Device::Lora15Card::spiOpen(const char *spidev) { diff --git a/src/AccessoryCards/LoraCard21.cpp b/src/AccessoryCards/LoraCard21.cpp index 70bec11..99f76d6 100644 --- a/src/AccessoryCards/LoraCard21.cpp +++ b/src/AccessoryCards/LoraCard21.cpp @@ -19,6 +19,7 @@ Device::Lora21Card::Lora21Card(Device& d, const std::string productId, const std::string port): LoraCard(d, productId, port) { spiPath = "/dev/spidev32766.2"; - MTS::System::cmd(LORA_2_1_FPGA_VERSION, fpgaVersion); - device.accessoryCard.AddMember("fpgaVersion", std::stoi(fpgaVersion), device.accessoryCardsAlloc); + MTS::System::cmd(LORA_2_1_FPGA_VERSION, cmdFpgaVersion); + fpgaVersion = std::stoi(cmdFpgaVersion); + setCapabilities(); }
\ No newline at end of file diff --git a/src/AccessoryCards/LoraCard21Ext.cpp b/src/AccessoryCards/LoraCard21Ext.cpp index b7531c7..51b43f7 100644 --- a/src/AccessoryCards/LoraCard21Ext.cpp +++ b/src/AccessoryCards/LoraCard21Ext.cpp @@ -18,7 +18,6 @@ #include "Device.h" Device::Lora21ExtCard::Lora21ExtCard(Device& d, const std::string productId, const std::string port): Lora21Card(d, productId, port) { - MTS::System::cmd(LORA_2_1_EXT_FPGA_VERSION, fpgaVersion2); - device.accessoryCard.AddMember("fpgaVersion2", std::stoi(fpgaVersion2), device.accessoryCardsAlloc); - + MTS::System::cmd(LORA_2_1_EXT_FPGA_VERSION, cmdFpgaVersion2); + device.accessoryCard.AddMember("fpgaVersion2", std::stoi(cmdFpgaVersion2), device.accessoryCardsAlloc); }
\ No newline at end of file diff --git a/src/Version.cpp b/src/Version.cpp index 5513345..365abbb 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -1,4 +1,4 @@ //Pre-Build Auto-Generated Source #include "Version.h" -const std::string Version::version("v1.0.0-6-gc4811dd"); +const std::string Version::version("v1.0.0-8-gd32e7c8"); |