From 78e3eb18dfa16c5cb3a7b664d28f1879586f10d1 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 4 May 2021 22:37:16 -0400 Subject: [PATCH] Drivers: Rename STM32 to CDC ACM This is much more descriptive of what the driver actually is --- CMakeLists.txt | 6 ++--- .../device/tree/etherbadge/etherbadge.h | 6 ++--- .../device/tree/neoobd2pro/neoobd2pro.h | 6 ++--- .../device/tree/neoobd2sim/neoobd2sim.h | 6 ++--- .../device/tree/radmoonduo/radmoonduo.h | 6 ++--- .../icsneo/device/tree/radpluto/radplutousb.h | 6 ++--- .../device/tree/valuecan4/valuecan4-1.h | 6 ++--- .../device/tree/valuecan4/valuecan4-2.h | 6 ++--- .../device/tree/valuecan4/valuecan4-2eleth.h | 2 +- .../device/tree/valuecan4/valuecan4-2elusb.h | 6 ++--- .../device/tree/valuecan4/valuecan4-4.h | 6 ++--- .../tree/valuecan4/valuecan4industrialusb.h | 6 ++--- .../icsneo/device/tree/vividcan/vividcan.h | 6 ++--- include/icsneo/platform/cdcacm.h | 14 +++++++++++ .../platform/posix/{stm32.h => cdcacm.h} | 14 +++++------ include/icsneo/platform/stm32.h | 14 ----------- .../platform/windows/{stm32.h => cdcacm.h} | 8 +++---- platform/posix/{stm32.cpp => cdcacm.cpp} | 24 +++++++++---------- .../{stm32darwin.cpp => cdcacmdarwin.cpp} | 8 +++---- .../linux/{stm32linux.cpp => cdcacmlinux.cpp} | 10 ++++---- 20 files changed, 83 insertions(+), 83 deletions(-) create mode 100644 include/icsneo/platform/cdcacm.h rename include/icsneo/platform/posix/{stm32.h => cdcacm.h} (83%) delete mode 100644 include/icsneo/platform/stm32.h rename include/icsneo/platform/windows/{stm32.h => cdcacm.h} (54%) rename platform/posix/{stm32.cpp => cdcacm.cpp} (94%) rename platform/posix/darwin/{stm32darwin.cpp => cdcacmdarwin.cpp} (96%) rename platform/posix/linux/{stm32linux.cpp => cdcacmlinux.cpp} (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 425d247..ba50246 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/include/icsneo/device/tree/etherbadge/etherbadge.h b/include/icsneo/device/tree/etherbadge/etherbadge.h index 8f5f415..7489614 100644 --- a/include/icsneo/device/tree/etherbadge/etherbadge.h +++ b/include/icsneo/device/tree/etherbadge/etherbadge.h @@ -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> Find() { std::vector> 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(); + initialize(); } protected: diff --git a/include/icsneo/device/tree/neoobd2pro/neoobd2pro.h b/include/icsneo/device/tree/neoobd2pro/neoobd2pro.h index e41b5aa..9be6392 100644 --- a/include/icsneo/device/tree/neoobd2pro/neoobd2pro.h +++ b/include/icsneo/device/tree/neoobd2pro/neoobd2pro.h @@ -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> Find() { std::vector> 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(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = PRODUCT_ID; } diff --git a/include/icsneo/device/tree/neoobd2sim/neoobd2sim.h b/include/icsneo/device/tree/neoobd2sim/neoobd2sim.h index 52cae00..65f7b81 100644 --- a/include/icsneo/device/tree/neoobd2sim/neoobd2sim.h +++ b/include/icsneo/device/tree/neoobd2sim/neoobd2sim.h @@ -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> Find() { std::vector> 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(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = PRODUCT_ID; } diff --git a/include/icsneo/device/tree/radmoonduo/radmoonduo.h b/include/icsneo/device/tree/radmoonduo/radmoonduo.h index 77ed88c..a73be99 100644 --- a/include/icsneo/device/tree/radmoonduo/radmoonduo.h +++ b/include/icsneo/device/tree/radmoonduo/radmoonduo.h @@ -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> Find() { std::vector> 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(); + initialize(); productId = PRODUCT_ID; getWritableNeoDevice().type = DEVICE_TYPE; } diff --git a/include/icsneo/device/tree/radpluto/radplutousb.h b/include/icsneo/device/tree/radpluto/radplutousb.h index ac5b393..fdb6042 100644 --- a/include/icsneo/device/tree/radpluto/radplutousb.h +++ b/include/icsneo/device/tree/radpluto/radplutousb.h @@ -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> Find() { std::vector> 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(); + initialize(); } }; diff --git a/include/icsneo/device/tree/valuecan4/valuecan4-1.h b/include/icsneo/device/tree/valuecan4/valuecan4-1.h index 5572b13..edd950d 100644 --- a/include/icsneo/device/tree/valuecan4/valuecan4-1.h +++ b/include/icsneo/device/tree/valuecan4/valuecan4-1.h @@ -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 namespace icsneo { @@ -19,7 +19,7 @@ public: static std::vector> Find() { std::vector> 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(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = USB_PRODUCT_ID; } diff --git a/include/icsneo/device/tree/valuecan4/valuecan4-2.h b/include/icsneo/device/tree/valuecan4/valuecan4-2.h index 5121938..4481b02 100644 --- a/include/icsneo/device/tree/valuecan4/valuecan4-2.h +++ b/include/icsneo/device/tree/valuecan4/valuecan4-2.h @@ -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 namespace icsneo { @@ -24,7 +24,7 @@ public: static std::vector> Find() { std::vector> 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(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = USB_PRODUCT_ID; } diff --git a/include/icsneo/device/tree/valuecan4/valuecan4-2eleth.h b/include/icsneo/device/tree/valuecan4/valuecan4-2eleth.h index d08bf5d..d2091a7 100644 --- a/include/icsneo/device/tree/valuecan4/valuecan4-2eleth.h +++ b/include/icsneo/device/tree/valuecan4/valuecan4-2eleth.h @@ -67,7 +67,7 @@ protected: private: ValueCAN4_2EL_ETH(neodevice_t neodevice) : ValueCAN4_2EL(neodevice) { - initialize(); + initialize(); productId = ETH_PRODUCT_ID; } }; diff --git a/include/icsneo/device/tree/valuecan4/valuecan4-2elusb.h b/include/icsneo/device/tree/valuecan4/valuecan4-2elusb.h index c8f171b..a5c24ec 100644 --- a/include/icsneo/device/tree/valuecan4/valuecan4-2elusb.h +++ b/include/icsneo/device/tree/valuecan4/valuecan4-2elusb.h @@ -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 namespace icsneo { @@ -14,7 +14,7 @@ public: static std::vector> Find() { std::vector> 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(); + initialize(); productId = USB_PRODUCT_ID; } }; diff --git a/include/icsneo/device/tree/valuecan4/valuecan4-4.h b/include/icsneo/device/tree/valuecan4/valuecan4-4.h index fa7d640..4d147d4 100644 --- a/include/icsneo/device/tree/valuecan4/valuecan4-4.h +++ b/include/icsneo/device/tree/valuecan4/valuecan4-4.h @@ -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 namespace icsneo { @@ -26,7 +26,7 @@ public: static std::vector> Find() { std::vector> 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(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = USB_PRODUCT_ID; } diff --git a/include/icsneo/device/tree/valuecan4/valuecan4industrialusb.h b/include/icsneo/device/tree/valuecan4/valuecan4industrialusb.h index 554af32..1aeae8b 100644 --- a/include/icsneo/device/tree/valuecan4/valuecan4industrialusb.h +++ b/include/icsneo/device/tree/valuecan4/valuecan4industrialusb.h @@ -4,7 +4,7 @@ #ifdef __cplusplus #include "icsneo/device/tree/valuecan4/valuecan4industrial.h" -#include "icsneo/platform/stm32.h" +#include "icsneo/platform/cdcacm.h" #include namespace icsneo { @@ -14,7 +14,7 @@ public: static std::vector> Find() { std::vector> 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(); + initialize(); } }; diff --git a/include/icsneo/device/tree/vividcan/vividcan.h b/include/icsneo/device/tree/vividcan/vividcan.h index 2d4a148..72242c6 100644 --- a/include/icsneo/device/tree/vividcan/vividcan.h +++ b/include/icsneo/device/tree/vividcan/vividcan.h @@ -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> Find() { std::vector> 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(); + initialize(); getWritableNeoDevice().type = DEVICE_TYPE; productId = PRODUCT_ID; } diff --git a/include/icsneo/platform/cdcacm.h b/include/icsneo/platform/cdcacm.h new file mode 100644 index 0000000..e898fc8 --- /dev/null +++ b/include/icsneo/platform/cdcacm.h @@ -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 \ No newline at end of file diff --git a/include/icsneo/platform/posix/stm32.h b/include/icsneo/platform/posix/cdcacm.h similarity index 83% rename from include/icsneo/platform/posix/stm32.h rename to include/icsneo/platform/posix/cdcacm.h index c20bf04..a3f8d43 100644 --- a/include/icsneo/platform/posix/stm32.h +++ b/include/icsneo/platform/posix/cdcacm.h @@ -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 FindByProduct(int product); bool open() override; diff --git a/include/icsneo/platform/stm32.h b/include/icsneo/platform/stm32.h deleted file mode 100644 index d732174..0000000 --- a/include/icsneo/platform/stm32.h +++ /dev/null @@ -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 \ No newline at end of file diff --git a/include/icsneo/platform/windows/stm32.h b/include/icsneo/platform/windows/cdcacm.h similarity index 54% rename from include/icsneo/platform/windows/stm32.h rename to include/icsneo/platform/windows/cdcacm.h index c35acca..507191e 100644 --- a/include/icsneo/platform/windows/stm32.h +++ b/include/icsneo/platform/windows/cdcacm.h @@ -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 FindByProduct(int product) { return VCP::FindByProduct(product, { L"usbser" }); } }; diff --git a/platform/posix/stm32.cpp b/platform/posix/cdcacm.cpp similarity index 94% rename from platform/posix/stm32.cpp rename to platform/posix/cdcacm.cpp index 46e0f4b..5cecfea 100644 --- a/platform/posix/stm32.cpp +++ b/platform/posix/cdcacm.cpp @@ -1,4 +1,4 @@ -#include "icsneo/platform/stm32.h" +#include "icsneo/platform/cdcacm.h" #include #include #include @@ -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 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; } diff --git a/platform/posix/darwin/stm32darwin.cpp b/platform/posix/darwin/cdcacmdarwin.cpp similarity index 96% rename from platform/posix/darwin/stm32darwin.cpp rename to platform/posix/darwin/cdcacmdarwin.cpp index 5e429be..08eb24b 100644 --- a/platform/posix/darwin/stm32darwin.cpp +++ b/platform/posix/darwin/cdcacmdarwin.cpp @@ -1,4 +1,4 @@ -#include "icsneo/platform/stm32.h" +#include "icsneo/platform/cdcacm.h" #include #include #include @@ -79,7 +79,7 @@ private: io_object_t toRelease; }; -std::vector STM32::FindByProduct(int product) { +std::vector CDCACM::FindByProduct(int product) { std::vector found; CFMutableDictionaryRef ref = IOServiceMatching(kIOSerialBSDServiceValue); @@ -179,10 +179,10 @@ std::vector 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 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]; } \ No newline at end of file diff --git a/platform/posix/linux/stm32linux.cpp b/platform/posix/linux/cdcacmlinux.cpp similarity index 96% rename from platform/posix/linux/stm32linux.cpp rename to platform/posix/linux/cdcacmlinux.cpp index d36e308..fd9aec5 100644 --- a/platform/posix/linux/stm32linux.cpp +++ b/platform/posix/linux/cdcacmlinux.cpp @@ -1,4 +1,4 @@ -#include "icsneo/platform/stm32.h" +#include "icsneo/platform/cdcacm.h" #include #include #include @@ -80,16 +80,16 @@ private: std::string serial; }; -std::vector STM32::FindByProduct(int product) { +std::vector CDCACM::FindByProduct(int product) { std::vector 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 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 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();