Splits out SerialHelper to allow using OS or VISA resources (#365)

Also removes regex and uses simple splits instead
This commit is contained in:
Thad House
2016-11-24 21:53:04 -08:00
committed by Peter Johnson
parent 4bbb7c0bcc
commit 57ef5cfd07
3 changed files with 209 additions and 126 deletions

View File

@@ -10,6 +10,7 @@
#include <stdint.h>
#include <string>
#include <vector>
#include "HAL/SerialPort.h"
#include "HAL/cpp/priority_mutex.h"
@@ -21,13 +22,19 @@ class SerialHelper {
public:
explicit SerialHelper(int32_t resourceHandle);
std::string GetSerialPortName(HAL_SerialPort port, int32_t* status);
std::string GetVISASerialPortName(HAL_SerialPort port, int32_t* status);
std::string GetOSSerialPortName(HAL_SerialPort port, int32_t* status);
std::vector<std::string> GetVISASerialPortList(int32_t* status);
std::vector<std::string> GetOSSerialPortList(int32_t* status);
private:
void SortHubPathVector();
void CoiteratedSort(llvm::SmallVectorImpl<llvm::SmallString<16>>& vec);
void QueryHubPaths(int32_t* status);
int32_t GetIndexForPort(HAL_SerialPort port, int32_t* status);
// Vectors to hold data before sorting.
// Note we will most likely have at max 2 instances, and the longest string
// is around 12, so these should never touch the heap;