mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Drivers: Decouple from devices
This allows us to better implement alternative drivers for devices, such as for device sharing servers or talking to CoreMini processors within the same device.
This commit is contained in:
@@ -5,23 +5,14 @@
|
||||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class NeoOBD2SIM : public Device {
|
||||
public:
|
||||
// Serial numbers are OS****
|
||||
static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::OBD2_SIM;
|
||||
static constexpr const uint16_t PRODUCT_ID = 0x1100;
|
||||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
|
||||
found.emplace_back(new NeoOBD2SIM(neodevice));
|
||||
|
||||
return found;
|
||||
}
|
||||
// Serial numbers start with OS
|
||||
// USB PID is 0x1100, standard driver is CDCACM
|
||||
ICSNEO_FINDABLE_DEVICE(NeoOBD2SIM, DeviceType::OBD2_SIM, "OS");
|
||||
|
||||
static const std::vector<Network>& GetSupportedNetworks() {
|
||||
static std::vector<Network> supportedNetworks = {
|
||||
@@ -32,19 +23,17 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
NeoOBD2SIM(neodevice_t neodevice) : Device(neodevice) {
|
||||
initialize<CDCACM>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
NeoOBD2SIM(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize(makeDriver);
|
||||
}
|
||||
|
||||
virtual void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||
for(auto& netid : GetSupportedNetworks())
|
||||
rxNetworks.emplace_back(netid);
|
||||
}
|
||||
|
||||
// The supported TX networks are the same as the supported RX networks for this device
|
||||
virtual void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||
|
||||
bool requiresVehiclePower() const override { return false; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user