summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/General.h1
-rw-r--r--src/AccessoryCards/LoraCard15.cpp12
-rw-r--r--src/Device/Device.cpp16
3 files changed, 19 insertions, 10 deletions
diff --git a/include/General.h b/include/General.h
index 81f5a3d..c5be2ff 100644
--- a/include/General.h
+++ b/include/General.h
@@ -50,6 +50,7 @@ typedef unsigned int uint; //32 bit - even on 64 bit machines
#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"
diff --git a/src/AccessoryCards/LoraCard15.cpp b/src/AccessoryCards/LoraCard15.cpp
index 69efb6b..a7a1dad 100644
--- a/src/AccessoryCards/LoraCard15.cpp
+++ b/src/AccessoryCards/LoraCard15.cpp
@@ -19,8 +19,15 @@
Device::Lora15Card::Lora15Card(Device& d, const std::string ProductId, const std::string Port) : LoraCard(d, ProductId, Port) {
int ret;
- if ((productId.rfind("MTCDT3-", 0) == 0 || productId.rfind("MTLGA-", 0) == 0) && (port.back() == '2')) {
- spiPath = "/dev/spidev1.0";
+ std::string deviceHwVersion = "";
+ /* Map the spi path to the device hw version/mtac product id, with the default being spidev0.0 */
+ MTS::System::readFile(HW_VERSION_PATH, deviceHwVersion);
+ if (deviceHwVersion.find("MTCDT3-") != std::string::npos) {
+ if (port.back() == '2') {
+ spiPath = "/dev/spidev1.2";
+ } else {
+ spiPath = "/dev/spidev0.2";
+ }
} else if (productId.find("MTAC-LORA-") == 0) {
if (port.back() == '2') {
spiPath = "/dev/spidev32765.2";
@@ -37,6 +44,7 @@ Device::Lora15Card::Lora15Card(Device& d, const std::string ProductId, const std
ret = spiRead(MTAC_FPGA_ADDRESS, &fpgaVersion);
if (ret != 0) {
printf("Could not read FPGA version");
+ fpgaVersion = 255;
}
spiClose();
diff --git a/src/Device/Device.cpp b/src/Device/Device.cpp
index 558f947..ee8ba83 100644
--- a/src/Device/Device.cpp
+++ b/src/Device/Device.cpp
@@ -74,11 +74,11 @@ void Device::getSystemTreeJson(const char * dir_name) {
exitHandler(99);
}
while (1) {
- struct dirent * entry = readdir (d); // Gets subsequent entries from "d"
- if (!entry) { // If there are no more entries, exit
+ struct dirent * entry = readdir (d); /* Gets subsequent entries from "d" */
+ if (!entry) { /* If there are no more entries, exit */
break;
}
- const char * d_name = entry->d_name; // Get file name
+ const char * d_name = entry->d_name; /* Get file name */
std::string fileData;
if (!(entry->d_type & DT_DIR) && (MTS::System::readFile(fullPath + "/" + std::string(d_name), fileData) == 0)) {
fileData = MTS::Text::trim(fileData);
@@ -92,7 +92,7 @@ void Device::getSystemTreeJson(const char * dir_name) {
accessoryCard.SetObject();
accessoryCard.AddMember("port", rapidjson::Value().SetString(dir_name, accessoryCardsAlloc), accessoryCardsAlloc);
}
- if (strcmp(d_name, "product-id") == 0) { // Map additional details based on product id not found in mts-io dir
+ if (strcmp(d_name, "product-id") == 0) { /* Map card specific details based on the product id */
if (regex_match(fileData, loraG16Filters)) {
Lora21Card lora21(*this, fileData, dir_name);
} else if (regex_match(fileData, loraG64Filters)) {
@@ -123,11 +123,11 @@ void Device::getSystemTreeJson(const char * dir_name) {
}
}
}
- if (isValidDirectory(entry, fullPath, d_name)) { // Check that the directory is not "d" or d's parent.
- getSystemTreeJson(d_name); // Recursively call with the new path
+ if (isValidDirectory(entry, fullPath, d_name)) { /* Check that the directory is not "d" or d's parent */
+ getSystemTreeJson(d_name); /* Recursively call with the new path */
}
}
- if (closedir (d)) { // After going through all the entries, close the directory.
+ if (closedir (d)) { /* After going through all the entries, close the directory */
logError("Could not close " + std::string(fullPath));
exitHandler(errno);
}
@@ -307,7 +307,7 @@ void Device::printJson() {
}
void Device::printVersion (std::string name) {
- printf("%s %s\nCopyright (C) 2019 by Multi-Tech Systems\nThis program is free software; you may redistribute it under the terms of\nthe GNU General Public License version 2 or (at your option) any later version.\nThis program has absolutely no warranty.\n",name.c_str(), Version::version.c_str());
+ printf("%s %s\nCopyright (C) 2020 by Multi-Tech Systems\nThis program is free software; you may redistribute it under the terms of\nthe GNU General Public License version 2 or (at your option) any later version.\nThis program has absolutely no warranty.\n",name.c_str(), Version::version.c_str());
}
void Device::printUsage(std::string program) {