diff --git a/hal/lib/athena/SerialHelper.h b/hal/include/HAL/cpp/SerialHelper.h similarity index 97% rename from hal/lib/athena/SerialHelper.h rename to hal/include/HAL/cpp/SerialHelper.h index 469e85cf15..95b9d48e5e 100644 --- a/hal/lib/athena/SerialHelper.h +++ b/hal/include/HAL/cpp/SerialHelper.h @@ -20,7 +20,7 @@ namespace hal { class SerialHelper { public: - explicit SerialHelper(int32_t resourceHandle); + SerialHelper(); std::string GetVISASerialPortName(HAL_SerialPort port, int32_t* status); std::string GetOSSerialPortName(HAL_SerialPort port, int32_t* status); diff --git a/hal/lib/athena/SerialPort.cpp b/hal/lib/athena/SerialPort.cpp index 42a18c677f..c6be57388a 100644 --- a/hal/lib/athena/SerialPort.cpp +++ b/hal/lib/athena/SerialPort.cpp @@ -9,7 +9,7 @@ #include -#include "SerialHelper.h" +#include "HAL/cpp/SerialHelper.h" #include "visa/visa.h" static int32_t resourceManagerHandle; @@ -23,7 +23,7 @@ void HAL_InitializeSerialPort(HAL_SerialPort port, int32_t* status) { if (resourceManagerHandle == 0) viOpenDefaultRM(reinterpret_cast(&resourceManagerHandle)); - hal::SerialHelper serialHelper(resourceManagerHandle); + hal::SerialHelper serialHelper; portName = serialHelper.GetVISASerialPortName(port, status); diff --git a/hal/lib/athena/SerialHelper.cpp b/hal/lib/athena/cpp/SerialHelper.cpp similarity index 96% rename from hal/lib/athena/SerialHelper.cpp rename to hal/lib/athena/cpp/SerialHelper.cpp index 34bcdc1a16..41676678af 100644 --- a/hal/lib/athena/SerialHelper.cpp +++ b/hal/lib/athena/cpp/SerialHelper.cpp @@ -5,29 +5,30 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#include "SerialHelper.h" +#include "HAL/cpp/SerialHelper.h" #include #include #include +#include "../visa/visa.h" #include "HAL/Errors.h" #include "llvm/StringRef.h" -#include "visa/visa.h" constexpr const char* OnboardResourceVISA = "ASRL1::INSTR"; constexpr const char* MxpResourceVISA = "ASRL2::INSTR"; -constexpr const char* OnboardResourceOS = "ttyS0"; -constexpr const char* MxpResourceOS = "ttyS1"; +constexpr const char* OnboardResourceOS = "/dev/ttyS0"; +constexpr const char* MxpResourceOS = "/dev/ttyS1"; namespace hal { std::string SerialHelper::m_usbNames[2]{"", ""}; priority_mutex SerialHelper::m_nameMutex; -SerialHelper::SerialHelper(int32_t resourceHandle) - : m_resourceHandle(resourceHandle) {} +SerialHelper::SerialHelper() { + viOpenDefaultRM(reinterpret_cast(&m_resourceHandle)); +} std::string SerialHelper::GetVISASerialPortName(HAL_SerialPort port, int32_t* status) { @@ -269,7 +270,8 @@ void SerialHelper::QueryHubPaths(int32_t* status) { m_unsortedHubPath.emplace_back( llvm::StringRef{pathSplitVec[hubIndex - 2]}); m_visaResource.emplace_back(desc); - m_osResource.emplace_back(matchString); + m_osResource.emplace_back( + llvm::StringRef{osName}.split("(").second.split(")").first); } }