Drivers: Rename STM32 to CDC ACM
This is much more descriptive of what the driver actually ispull/35/head
parent
6d22b1e001
commit
78e3eb18df
|
|
@ -95,15 +95,15 @@ else() # Darwin or Linux
|
|||
set(PLATFORM_SRC
|
||||
platform/posix/ftdi.cpp
|
||||
platform/posix/pcap.cpp
|
||||
platform/posix/stm32.cpp
|
||||
platform/posix/cdcacm.cpp
|
||||
)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
list(APPEND PLATFORM_SRC
|
||||
platform/posix/darwin/stm32darwin.cpp
|
||||
platform/posix/darwin/cdcacmdarwin.cpp
|
||||
)
|
||||
else() # Linux or other
|
||||
list(APPEND PLATFORM_SRC
|
||||
platform/posix/linux/stm32linux.cpp
|
||||
platform/posix/linux/cdcacmlinux.cpp
|
||||
)
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
message(WARNING
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/communication/packetizer.h"
|
||||
#include "icsneo/communication/decoder.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include "icsneo/device/tree/etherbadge/etherbadgesettings.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
|
@ -22,7 +22,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
|
||||
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
|
||||
found.emplace_back(new EtherBADGE(neodevice));
|
||||
|
||||
return found;
|
||||
|
|
@ -42,7 +42,7 @@ public:
|
|||
EtherBADGE(neodevice_t neodevice) : Device(neodevice) {
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
initialize<STM32, EtherBADGESettings>();
|
||||
initialize<CDCACM, EtherBADGESettings>();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
|
||||
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
|
||||
found.emplace_back(new NeoOBD2PRO(neodevice));
|
||||
|
||||
return found;
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
private:
|
||||
NeoOBD2PRO(neodevice_t neodevice) : Device(neodevice) {
|
||||
initialize<STM32>();
|
||||
initialize<CDCACM>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
|
||||
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
|
||||
found.emplace_back(new NeoOBD2SIM(neodevice));
|
||||
|
||||
return found;
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
private:
|
||||
NeoOBD2SIM(neodevice_t neodevice) : Device(neodevice) {
|
||||
initialize<STM32>();
|
||||
initialize<CDCACM>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/device/tree/radmoonduo/radmoonduosettings.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
|
||||
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
|
||||
found.emplace_back(new RADMoonDuo(neodevice));
|
||||
|
||||
return found;
|
||||
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
protected:
|
||||
RADMoonDuo(neodevice_t neodevice) : Device(neodevice) {
|
||||
initialize<STM32, RADMoonDuoSettings>();
|
||||
initialize<CDCACM, RADMoonDuoSettings>();
|
||||
productId = PRODUCT_ID;
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/device/tree/radpluto/radpluto.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
|
||||
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
|
||||
found.emplace_back(new RADPlutoUSB(neodevice));
|
||||
|
||||
return found;
|
||||
|
|
@ -22,7 +22,7 @@ public:
|
|||
|
||||
private:
|
||||
RADPlutoUSB(neodevice_t neodevice) : RADPluto(neodevice) {
|
||||
initialize<STM32, RADPlutoSettings>();
|
||||
initialize<CDCACM, RADPlutoSettings>();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||
#include "icsneo/device/tree/valuecan4/settings/valuecan4-1settings.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <string>
|
||||
|
||||
namespace icsneo {
|
||||
|
|
@ -19,7 +19,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
|
||||
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||
found.emplace_back(new ValueCAN4_1(neodevice));
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ protected:
|
|||
|
||||
private:
|
||||
ValueCAN4_1(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||
initialize<STM32, ValueCAN4_1Settings>();
|
||||
initialize<CDCACM, ValueCAN4_1Settings>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = USB_PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||
#include "icsneo/device/tree/valuecan4/settings/valuecan4-2settings.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <string>
|
||||
|
||||
namespace icsneo {
|
||||
|
|
@ -24,7 +24,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
|
||||
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||
found.emplace_back(new ValueCAN4_2(neodevice));
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ protected:
|
|||
|
||||
private:
|
||||
ValueCAN4_2(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||
initialize<STM32, ValueCAN4_2Settings>();
|
||||
initialize<CDCACM, ValueCAN4_2Settings>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = USB_PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ protected:
|
|||
|
||||
private:
|
||||
ValueCAN4_2EL_ETH(neodevice_t neodevice) : ValueCAN4_2EL(neodevice) {
|
||||
initialize<STM32, ValueCAN4_2ELSettings>();
|
||||
initialize<CDCACM, ValueCAN4_2ELSettings>();
|
||||
productId = ETH_PRODUCT_ID;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/device/tree/valuecan4/valuecan4-2el.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <string>
|
||||
|
||||
namespace icsneo {
|
||||
|
|
@ -14,7 +14,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
|
||||
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||
found.emplace_back(new ValueCAN4_2EL_USB(neodevice));
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ protected:
|
|||
|
||||
private:
|
||||
ValueCAN4_2EL_USB(neodevice_t neodevice) : ValueCAN4_2EL(neodevice) {
|
||||
initialize<STM32, ValueCAN4_2ELSettings>();
|
||||
initialize<CDCACM, ValueCAN4_2ELSettings>();
|
||||
productId = USB_PRODUCT_ID;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "icsneo/device/tree/valuecan4/valuecan4.h"
|
||||
#include "icsneo/device/tree/valuecan4/settings/valuecan4-4settings.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <string>
|
||||
|
||||
namespace icsneo {
|
||||
|
|
@ -26,7 +26,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
|
||||
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||
found.emplace_back(new ValueCAN4_4(neodevice));
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ protected:
|
|||
|
||||
private:
|
||||
ValueCAN4_4(neodevice_t neodevice) : ValueCAN4(neodevice) {
|
||||
initialize<STM32, ValueCAN4_4Settings>();
|
||||
initialize<CDCACM, ValueCAN4_4Settings>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = USB_PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/device/tree/valuecan4/valuecan4industrial.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <string>
|
||||
|
||||
namespace icsneo {
|
||||
|
|
@ -14,7 +14,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(USB_PRODUCT_ID)) {
|
||||
for(auto neodevice : CDCACM::FindByProduct(USB_PRODUCT_ID)) {
|
||||
if(std::string(neodevice.serial).substr(0, 2) == SERIAL_START)
|
||||
found.emplace_back(new ValueCAN4IndustrialUSB(neodevice));
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ protected:
|
|||
|
||||
private:
|
||||
ValueCAN4IndustrialUSB(neodevice_t neodevice) : ValueCAN4Industrial(neodevice) {
|
||||
initialize<STM32, ValueCAN4IndustrialSettings>();
|
||||
initialize<CDCACM, ValueCAN4IndustrialSettings>();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include "icsneo/device/tree/vividcan/vividcansettings.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
|
@ -18,7 +18,7 @@ public:
|
|||
static std::vector<std::shared_ptr<Device>> Find() {
|
||||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto neodevice : STM32::FindByProduct(PRODUCT_ID))
|
||||
for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID))
|
||||
found.emplace_back(new VividCAN(neodevice));
|
||||
|
||||
return found;
|
||||
|
|
@ -40,7 +40,7 @@ protected:
|
|||
|
||||
private:
|
||||
VividCAN(neodevice_t neodevice) : Device(neodevice) {
|
||||
initialize<STM32, VividCANSettings>();
|
||||
initialize<CDCACM, VividCANSettings>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef __CDCACM_H_
|
||||
#define __CDCACM_H_
|
||||
|
||||
#define INTREPID_USB_VENDOR_ID (0x093c)
|
||||
|
||||
#if defined _WIN32
|
||||
#include "icsneo/platform/windows/cdcacm.h"
|
||||
#elif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
|
||||
#include "icsneo/platform/posix/cdcacm.h"
|
||||
#else
|
||||
#warning "This platform is not supported by the CDC ACM driver"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __STM32_POSIX_H_
|
||||
#define __STM32_POSIX_H_
|
||||
#ifndef __CDCACM_POSIX_H_
|
||||
#define __CDCACM_POSIX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
|
@ -13,20 +13,20 @@
|
|||
|
||||
namespace icsneo {
|
||||
|
||||
class STM32 : public Driver {
|
||||
class CDCACM : public Driver {
|
||||
public:
|
||||
/*
|
||||
/**
|
||||
* Note: This is a driver for all devices which use CDC_ACM
|
||||
* Once we find the TTY we want it's a pretty generic POSIX TTY driver, but
|
||||
* the method for finding the TTY we want varies by OS.
|
||||
* On Linux, we read sysfs to find users of the CDC_ACM driver
|
||||
* On macOS, we use IOKit to find the USB device we're looking for
|
||||
* As such platform specific FindByProduct & HandleToTTY code can be found
|
||||
* in stm32linux.cpp and stm32darwin.cpp respectively
|
||||
* in cdcacmlinux.cpp and cdcacmdarwin.cpp respectively
|
||||
* Other POSIX systems (BSDs, QNX, etc) will need bespoke code written in the future
|
||||
*/
|
||||
STM32(const device_eventhandler_t& err, neodevice_t& forDevice) : Driver(err), device(forDevice) {}
|
||||
~STM32();
|
||||
CDCACM(const device_eventhandler_t& err, neodevice_t& forDevice) : Driver(err), device(forDevice) {}
|
||||
~CDCACM();
|
||||
static std::vector<neodevice_t> FindByProduct(int product);
|
||||
|
||||
bool open() override;
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef __STM32_H_
|
||||
#define __STM32_H_
|
||||
|
||||
#define INTREPID_USB_VENDOR_ID (0x093c)
|
||||
|
||||
#if defined _WIN32
|
||||
#include "icsneo/platform/windows/stm32.h"
|
||||
#elif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
|
||||
#include "icsneo/platform/posix/stm32.h"
|
||||
#else
|
||||
#warning "This platform is not supported by the STM32 driver"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __STM32_WINDOWS_H_
|
||||
#define __STM32_WINDOWS_H_
|
||||
#ifndef __CDCACM_WINDOWS_H_
|
||||
#define __CDCACM_WINDOWS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
namespace icsneo {
|
||||
|
||||
class STM32 : public VCP {
|
||||
class CDCACM : public VCP {
|
||||
public:
|
||||
STM32(const device_eventhandler_t& err, neodevice_t& forDevice) : VCP(err, forDevice) {}
|
||||
CDCACM(const device_eventhandler_t& err, neodevice_t& forDevice) : VCP(err, forDevice) {}
|
||||
static std::vector<neodevice_t> FindByProduct(int product) { return VCP::FindByProduct(product, { L"usbser" }); }
|
||||
};
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <dirent.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
|
@ -14,13 +14,13 @@
|
|||
|
||||
using namespace icsneo;
|
||||
|
||||
STM32::~STM32() {
|
||||
CDCACM::~CDCACM() {
|
||||
awaitModeChangeComplete();
|
||||
if(isOpen())
|
||||
close();
|
||||
}
|
||||
|
||||
bool STM32::open() {
|
||||
bool CDCACM::open() {
|
||||
if(isOpen()) {
|
||||
report(APIEvent::Type::DeviceCurrentlyOpen, APIEvent::Severity::Error);
|
||||
return false;
|
||||
|
|
@ -101,17 +101,17 @@ bool STM32::open() {
|
|||
}
|
||||
|
||||
// Create threads
|
||||
readThread = std::thread(&STM32::readTask, this);
|
||||
writeThread = std::thread(&STM32::writeTask, this);
|
||||
readThread = std::thread(&CDCACM::readTask, this);
|
||||
writeThread = std::thread(&CDCACM::writeTask, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool STM32::isOpen() {
|
||||
bool CDCACM::isOpen() {
|
||||
return fd >= 0; // Negative fd indicates error or not opened yet
|
||||
}
|
||||
|
||||
bool STM32::close() {
|
||||
bool CDCACM::close() {
|
||||
if(!isOpen() && !isDisconnected()) {
|
||||
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||
return false;
|
||||
|
|
@ -158,11 +158,11 @@ bool STM32::close() {
|
|||
}
|
||||
}
|
||||
|
||||
void STM32::modeChangeIncoming() {
|
||||
void CDCACM::modeChangeIncoming() {
|
||||
modeChanging = true;
|
||||
}
|
||||
|
||||
void STM32::awaitModeChangeComplete() {
|
||||
void CDCACM::awaitModeChangeComplete() {
|
||||
std::unique_lock<std::mutex> lk(modeChangeMutex);
|
||||
if(modeChanging && !modeChangeThread.joinable()) // Waiting for the thread to start
|
||||
modeChangeCV.wait_for(lk, std::chrono::seconds(1), [this] { return modeChangeThread.joinable(); });
|
||||
|
|
@ -170,7 +170,7 @@ void STM32::awaitModeChangeComplete() {
|
|||
modeChangeThread.join();
|
||||
}
|
||||
|
||||
void STM32::readTask() {
|
||||
void CDCACM::readTask() {
|
||||
constexpr size_t READ_BUFFER_SIZE = 2048;
|
||||
uint8_t readbuf[READ_BUFFER_SIZE];
|
||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||
|
|
@ -209,7 +209,7 @@ void STM32::readTask() {
|
|||
}
|
||||
}
|
||||
|
||||
void STM32::writeTask() {
|
||||
void CDCACM::writeTask() {
|
||||
WriteOperation writeOp;
|
||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||
while(!closing && !isDisconnected()) {
|
||||
|
|
@ -260,7 +260,7 @@ void STM32::writeTask() {
|
|||
}
|
||||
}
|
||||
|
||||
bool STM32::fdIsValid() {
|
||||
bool CDCACM::fdIsValid() {
|
||||
struct termios tty = {};
|
||||
return tcgetattr(fd, &tty) == 0 ? true : false;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
|
@ -79,7 +79,7 @@ private:
|
|||
io_object_t toRelease;
|
||||
};
|
||||
|
||||
std::vector<neodevice_t> STM32::FindByProduct(int product) {
|
||||
std::vector<neodevice_t> CDCACM::FindByProduct(int product) {
|
||||
std::vector<neodevice_t> found;
|
||||
|
||||
CFMutableDictionaryRef ref = IOServiceMatching(kIOSerialBSDServiceValue);
|
||||
|
|
@ -179,10 +179,10 @@ std::vector<neodevice_t> STM32::FindByProduct(int product) {
|
|||
return found;
|
||||
}
|
||||
|
||||
std::string STM32::HandleToTTY(neodevice_handle_t handle) {
|
||||
std::string CDCACM::HandleToTTY(neodevice_handle_t handle) {
|
||||
std::lock_guard<std::mutex> lk(ttyTableMutex);
|
||||
const size_t index = size_t(handle - HANDLE_OFFSET);
|
||||
if(index >= ttyTable.size())
|
||||
return ""; // Not found, generic driver (stm32.cpp) will throw an error
|
||||
return ""; // Not found, generic driver (cdcacm.cpp) will throw an error
|
||||
return ttyTable[index];
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "icsneo/platform/stm32.h"
|
||||
#include "icsneo/platform/cdcacm.h"
|
||||
#include <dirent.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
|
@ -80,16 +80,16 @@ private:
|
|||
std::string serial;
|
||||
};
|
||||
|
||||
std::vector<neodevice_t> STM32::FindByProduct(int product) {
|
||||
std::vector<neodevice_t> CDCACM::FindByProduct(int product) {
|
||||
std::vector<neodevice_t> found;
|
||||
|
||||
Directory directory("/sys/bus/usb/drivers/cdc_acm"); // Query the STM32 driver
|
||||
Directory directory("/sys/bus/usb/drivers/cdc_acm"); // Query the CDCACM driver
|
||||
if(!directory.openedSuccessfully())
|
||||
return found;
|
||||
|
||||
std::vector<std::string> foundusbs;
|
||||
for(auto& entry : directory.ls()) {
|
||||
/* This directory will have directories (links) for all devices using the cdc_acm driver (as STM32 devices do)
|
||||
/* This directory will have directories (links) for all devices using the cdc_acm driver (as CDCACM devices do)
|
||||
* There will also be other files and directories providing information about the driver in here. We want to ignore them.
|
||||
* Devices will be named like "7-2:1.0" where 7 is the enumeration for the USB controller, 2 is the device enumeration on
|
||||
* that specific controller (will change if the device is unplugged and replugged), 1 is the device itself and 0 is
|
||||
|
|
@ -195,7 +195,7 @@ std::vector<neodevice_t> STM32::FindByProduct(int product) {
|
|||
return found;
|
||||
}
|
||||
|
||||
std::string STM32::HandleToTTY(neodevice_handle_t handle) {
|
||||
std::string CDCACM::HandleToTTY(neodevice_handle_t handle) {
|
||||
std::stringstream ss;
|
||||
ss << "/dev/ttyACM" << (int)(handle - HANDLE_OFFSET);
|
||||
return ss.str();
|
||||
Loading…
Reference in New Issue