Allow version and supported devices to be printed at runtime
parent
2ade9116eb
commit
8a4e33c8df
|
|
@ -84,6 +84,7 @@ execute_process(
|
|||
COMMAND git describe --abbrev=6 --dirty --always --tags
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE
|
||||
ERROR_VARIABLE GIT_DESCRIBE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
configure_file(api/icsneocpp/buildinfo.h.template ${CMAKE_CURRENT_BINARY_DIR}/generated/buildinfo.h)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ std::vector<std::shared_ptr<Device>> icsneo::FindAllDevices() {
|
|||
return DeviceFinder::FindAll();
|
||||
}
|
||||
|
||||
std::vector<DeviceType> icsneo::GetSupportedDevices() {
|
||||
return DeviceFinder::GetSupportedDevices();
|
||||
}
|
||||
|
||||
size_t icsneo::ErrorCount(ErrorFilter filter) {
|
||||
return ErrorManager::GetInstance().count(filter);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,4 +12,15 @@ neoversion_t icsneo::GetVersion(void) {
|
|||
version.buildBranch = GIT_BRANCH;
|
||||
version.buildTag = GIT_DESCRIBE;
|
||||
return version;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const neoversion_t& version) {
|
||||
os << 'v' << version.major << '.' << version.minor << '.' << version.patch;
|
||||
if(version.metadata[0] != '\0')
|
||||
os << '+' << version.metadata;
|
||||
if(std::string(version.buildBranch) != "master")
|
||||
os << ' ' << version.buildBranch << " @";
|
||||
if(version.buildTag[0] != 'v')
|
||||
os << ' ' << version.buildTag;
|
||||
return os;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using namespace icsneo;
|
||||
|
||||
static bool supportedDevicesCached = false;
|
||||
static std::vector<DeviceType> supportedDevices = {
|
||||
|
||||
#ifdef __NEOOBD2PRO_H_
|
||||
|
|
@ -156,5 +157,9 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||
}
|
||||
|
||||
const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
||||
if(!supportedDevicesCached) {
|
||||
supportedDevices.erase(std::unique(supportedDevices.begin(), supportedDevices.end()), supportedDevices.end());
|
||||
supportedDevicesCached = true;
|
||||
}
|
||||
return supportedDevices;
|
||||
}
|
||||
|
|
@ -3,7 +3,14 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
#ifdef __cplusplus
|
||||
#include <ostream>
|
||||
#define NEOVERSION_DEFINE_BEGIN struct neoversion_t {
|
||||
#else
|
||||
#define NEOVERSION_DEFINE_BEGIN typedef struct {
|
||||
#endif
|
||||
|
||||
NEOVERSION_DEFINE_BEGIN
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
uint16_t patch;
|
||||
|
|
@ -11,7 +18,12 @@ typedef struct {
|
|||
const char* buildBranch;
|
||||
const char* buildTag;
|
||||
char reserved[32];
|
||||
#ifdef __cplusplus
|
||||
friend std::ostream& operator<<(std::ostream& os, const neoversion_t& version);
|
||||
};
|
||||
#else
|
||||
} neoversion_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace icsneo {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public:
|
|||
case VividCAN:
|
||||
return "VividCAN";
|
||||
case OBD2_SIM:
|
||||
return "neoOBD2-SIM";
|
||||
return "neoOBD2 SIM";
|
||||
case DONT_REUSE0:
|
||||
case DONT_REUSE1:
|
||||
case DONT_REUSE2:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
namespace icsneo {
|
||||
|
||||
std::vector<std::shared_ptr<Device>> FindAllDevices();
|
||||
std::vector<DeviceType> GetSupportedDevices();
|
||||
|
||||
size_t ErrorCount(ErrorFilter filter = ErrorFilter());
|
||||
std::vector<APIError> GetErrors(ErrorFilter filter, size_t max = 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue