diff --git a/hardware_integration/include/isobus/hardware_integration/toucan_vscp_canal.hpp b/hardware_integration/include/isobus/hardware_integration/toucan_vscp_canal.hpp index dd4e5954..d75e9344 100644 --- a/hardware_integration/include/isobus/hardware_integration/toucan_vscp_canal.hpp +++ b/hardware_integration/include/isobus/hardware_integration/toucan_vscp_canal.hpp @@ -70,6 +70,10 @@ namespace isobus /// @returns True if the configuration was changed, otherwise false (if the device is open false will be returned) bool reconfigure(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate = 250); + /// @brief Returns the currently configured serial number of the device which will be used to connect to the hardware + /// @returns The currently configured serial number of the device + std::uint32_t get_serial_number() const; + private: /// @brief Generates a device name string for the TouCAN device /// @param[in] deviceID The id to use for this device @@ -80,6 +84,7 @@ namespace isobus std::string name; ///< A configuration string that is used to connect to the hardware through the CANAL api std::uint32_t handle = 0; ///< The handle that the driver returns to us for the open hardware std::uint32_t openResult = CANAL_ERROR_NOT_OPEN; ///< Stores the result of the call to begin CAN communication. Used for is_valid check later. + std::uint32_t currentlyConfiguredSerialNumber = 0; ///< The serial number of the device that is being used }; } #endif // TOUCAN_VSCP_CANAL_PLUGIN_HPP diff --git a/hardware_integration/src/toucan_vscp_canal.cpp b/hardware_integration/src/toucan_vscp_canal.cpp index c5aa475e..91609a40 100644 --- a/hardware_integration/src/toucan_vscp_canal.cpp +++ b/hardware_integration/src/toucan_vscp_canal.cpp @@ -106,6 +106,11 @@ namespace isobus return retVal; } + std::uint32_t TouCANPlugin::get_serial_number() const + { + return currentlyConfiguredSerialNumber; + } + void TouCANPlugin::generate_device_name(std::int16_t deviceID, std::uint32_t serialNumber, std::uint16_t baudRate) { std::string deviceConfigString; @@ -118,6 +123,7 @@ namespace isobus isobus::CANStackLogger::critical("[TouCAN]: Invalid serial number. Must be 8 digits max."); serialNumber = 0; } + currentlyConfiguredSerialNumber = serialNumber; serialString = isobus::to_string(serialNumber); if (SERIAL_NUMBER_CHARACTER_REQUIREMENT > serialString.length())