3#include <condition_variable>
10#include <unordered_map>
11#include <unordered_set>
16#include <nlohmann/json.hpp>
31 std::map<std::uint16_t, std::vector<std::uint32_t>>
rx;
32 std::map<std::uint16_t, std::vector<std::uint32_t>>
tx;
98 return lhs ==
static_cast<uint32_t
>(rhs);
113 return static_cast<uint32_t
>(lhs) == rhs;
184 total +=
entry.bitlength;
196 total +=
entry.bitlength;
269 return static_cast<ObjectFlags>(
static_cast<uint16_t
>(lhs) |
270 static_cast<uint16_t
>(rhs));
284 return static_cast<ObjectFlags>(
static_cast<uint16_t
>(lhs) &
285 static_cast<uint16_t
>(rhs));
318 return b | s | p | a;
467 std::variant<bool, std::int8_t, std::int16_t, std::int32_t, std::int64_t,
468 std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t,
469 float, double, std::string,
470 std::vector<std::uint8_t>>;
492 std::vector<MappedParameterValue>
rx;
493 std::vector<MappedParameterValue>
tx;
603 std::vector<std::uint8_t>
data;
654 template <
typename T>
660 if (
auto ptr = std::get_if<T>(&val)) {
663 throw std::bad_variant_access();
682 template <
typename T>
685 if (
auto ptr = std::get_if<T>(&val)) {
703 template <
typename T>
747 template <
typename T>
770 template <
typename T>
772 auto expectedType = [
this]() -> std::type_index {
778 return typeid(std::int8_t);
781 return typeid(std::int16_t);
785 return typeid(std::int32_t);
788 return typeid(std::int64_t);
795 return typeid(std::uint8_t);
798 return typeid(std::uint16_t);
802 return typeid(std::uint32_t);
805 return typeid(std::uint64_t);
808 return typeid(float);
811 return typeid(double);
816 return typeid(std::string);
824 const std::type_index expected = expectedType();
825 if (expected !=
typeid(T) &&
826 typeid(T) !=
typeid(std::vector<std::uint8_t>)) {
979 const std::unordered_map<Parameter::Address, Parameter>& parametersMap,
980 bool sortParameters =
true);
990 "stack_image.svg.zip",
"SOMANET_CiA_402.xml.zip"};
1005 return filename.rfind(
"app_", 0) == 0 && filename.size() >= 4 &&
1006 filename.compare(filename.size() - 4, 4,
".bin") == 0;
1022 return filename.rfind(
"com_", 0) == 0 && filename.size() >= 4 &&
1023 filename.compare(filename.size() - 4, 4,
".bin") == 0;
1083 return "File not found";
1085 return "File is empty";
1087 return "File starts with a null terminator";
1089 return "Failed to unzip file";
1091 return "Failed to flash device";
1093 return "Failed to write to device";
1095 return "An unknown error occurred";
1097 return "Unrecognized error";
1148 bool refresh =
false,
1149 const std::chrono::steady_clock::duration expiryTime =
1150 std::chrono::milliseconds(5000)) = 0;
1165 const std::chrono::steady_clock::duration expiryTime =
1166 std::chrono::milliseconds(5000)) = 0;
1183 const std::string& filename,
1184 const std::chrono::steady_clock::duration expiryTime =
1185 std::chrono::milliseconds(5000)) = 0;
1210 const bool stripSizeSuffix,
1211 const std::chrono::steady_clock::duration expiryTime =
1212 std::chrono::milliseconds(5000)) = 0;
1227 const std::vector<uint8_t>& data,
1228 const std::chrono::steady_clock::duration expiryTime =
1229 std::chrono::milliseconds(5000)) = 0;
1239 const std::chrono::steady_clock::duration expiryTime =
1240 std::chrono::milliseconds(5000)) = 0;
1254 const std::vector<std::uint8_t>& data,
1255 const std::vector<std::string>& skipFiles = {},
1256 std::function<void(uint8_t, std::string)> progressCallback =
nullptr,
1257 const std::chrono::steady_clock::duration expiryTime =
1258 std::chrono::milliseconds(60000)) = 0;
1270 bool readValues,
const std::chrono::steady_clock::duration expiryTime =
1271 std::chrono::milliseconds(9000)) = 0;
1287 virtual std::vector<std::reference_wrapper<Parameter>>
parameters() = 0;
1324 uint16_t
index, uint8_t subindex,
1325 const std::chrono::steady_clock::duration expiryTime =
1326 std::chrono::milliseconds(5000)) = 0;
1344 const std::chrono::steady_clock::duration expiryTime =
1345 std::chrono::milliseconds(5000)) = 0;
1366 const std::chrono::steady_clock::duration expiryTime =
1367 std::chrono::milliseconds(5000)) = 0;
1381 uint64_t missedCycles = 0) = 0;
1399 uint8_t subindex)
const = 0;
1434 uint8_t state,
const std::chrono::steady_clock::duration expiryTime) = 0;
1449 const std::vector<uint8_t>& data,
1450 const std::chrono::steady_clock::duration expiryTime) = 0;
1464 uint64_t missedCycles,
1465 const std::chrono::steady_clock::duration expiryTime) = 0;
1470 std::vector<Device> devices_;
1495 uint16_t
position()
const noexcept;
1500 int code()
const noexcept;
1555 Device& device,
const std::string& filename,
1556 const std::chrono::steady_clock::duration expiryTime =
1557 std::chrono::milliseconds(20000));
1587 Device& device,
const std::string& filename,
1588 const std::vector<std::uint8_t>& data,
1589 std::function<
void(uint8_t, std::string)> progressCallback =
nullptr,
1590 const std::chrono::steady_clock::duration expiryTime =
1591 std::chrono::milliseconds(30000));
1614 const std::chrono::steady_clock::duration
1615 expiryTime = std::chrono::milliseconds(20000));
1637 Device& device,
const std::vector<std::uint8_t>& data,
1638 const std::vector<std::string>& skipFiles = {},
1639 std::function<void(uint8_t, std::string)> progressCallback =
nullptr,
1640 const std::chrono::steady_clock::duration expiryTime =
1641 std::chrono::milliseconds(60000));
1658 std::stringstream oss;
1660 oss <<
"0x" << std::setw(4) << std::setfill(
'0') << std::hex << std::uppercase
1661 <<
index <<
":" << std::setw(2) << std::setfill(
'0') << std::hex
1662 << std::uppercase << subindex;
1697 std::chrono::milliseconds intervalBetweenUploads);
1711 void add(uint16_t
index, uint8_t subindex);
1783 virtual void refresh(
const std::vector<Parameter::Address>& addresses) = 0;
1785 std::chrono::milliseconds
1787 std::condition_variable
1790 std::vector<Parameter::Address>
1835 uint8_t pdoSubindex);
1850 uint16_t start, uint16_t end, uint8_t maxSubIndex);
1871struct adl_serializer<
mm::comm::base::ParameterValue> {
1873 std::visit([&j](
const auto& val) { j = val; },
value);
1877 if (j.is_boolean()) {
1878 value = j.get<
bool>();
1879 }
else if (j.is_number_integer()) {
1880 int64_t num = j.get<int64_t>();
1881 if (num >= -128 && num <= 127) {
1882 value =
static_cast<int8_t
>(num);
1883 }
else if (num >= -32768 && num <= 32767) {
1884 value =
static_cast<int16_t
>(num);
1885 }
else if (num >= -2147483648LL && num <= 2147483647LL) {
1886 value =
static_cast<int32_t
>(num);
1890 }
else if (j.is_number_unsigned()) {
1891 uint64_t num = j.get<uint64_t>();
1893 value =
static_cast<uint8_t
>(num);
1894 }
else if (num <= 65535) {
1895 value =
static_cast<uint16_t
>(num);
1896 }
else if (num <= 4294967295ULL) {
1897 value =
static_cast<uint32_t
>(num);
1901 }
else if (j.is_number_float()) {
1902 double f = j.get<
double>();
1904 if (f >= -3.4e38 && f <= 3.4e38) {
1905 value =
static_cast<float>(f);
1909 }
else if (j.is_string()) {
1910 value = j.get<std::string>();
1911 }
else if (j.is_array()) {
1912 value = j.get<std::vector<uint8_t>>();
1914 throw std::runtime_error(
"Unsupported JSON type for ParameterValue");
1937 j.at(
"index").get_to(p.
index);
1938 j.at(
"subindex").get_to(p.
subindex);
1939 j.at(
"value").get_to(p.
value);
1948 j =
json{{
"rx", p.
rx}, {
"tx", p.
tx}};
1957 j.at(
"rx").get_to(p.
rx);
1958 j.at(
"tx").get_to(p.
tx);
nlohmann::json json
Definition circulo_encoder_configuration.cc:13
Manages devices and performs cyclic process data exchange.
Definition base.h:1417
virtual void exchangeProcessDataAndUpdateParameters(uint64_t missedCycles, const std::chrono::steady_clock::duration expiryTime)=0
Exchanges process data and updates internal parameters for each device.
virtual std::vector< Device > & devices()=0
virtual bool setState(uint8_t state, const std::chrono::steady_clock::duration expiryTime)=0
Sets the operational state of all managed devices.
virtual std::vector< uint8_t > exchangeProcessData(const std::vector< uint8_t > &data, const std::chrono::steady_clock::duration expiryTime)=0
Exchanges process data with devices.
virtual void refresh(const std::vector< Parameter::Address > &addresses)=0
Rereads the specified device parameters.
void triggerManualRefresh(bool async=false)
Triggers a manual refresh of device parameters.
Definition base.cc:700
void remove(uint16_t index, uint8_t subindex)
Remove a parameter identified by (index, subindex) from the refresh list.
Definition base.cc:631
void start()
Starts the refresher background thread if it is not already running.
Definition base.cc:643
std::vector< Parameter::Address > addresses_
List of parameter addresses to refresh.
Definition base.h:1791
~DeviceParameterRefresher()
Destructor ensures the refresher thread is stopped cleanly.
Definition base.cc:610
bool running_
Flag indicating whether the refresher thread is running.
Definition base.h:1793
void clear()
Remove all parameters from the refresh list.
Definition base.cc:638
Device & device_
Reference to the device instance used for uploading.
Definition base.h:1792
DeviceParameterRefresher(Device &device, std::chrono::milliseconds intervalBetweenUploads)
Constructor initializes the refresher with a device reference and upload interval.
Definition base.cc:606
std::chrono::milliseconds interval_
Time to wait between consecutive parameter uploads.
Definition base.h:1786
std::mutex mutex_
Mutex protecting access to shared data members.
Definition base.h:1789
std::condition_variable cv_
Condition variable used to notify the worker thread.
Definition base.h:1788
std::thread worker_
The background thread performing periodic uploads.
Definition base.h:1794
void add(uint16_t index, uint8_t subindex)
Add a parameter identified by (index, subindex) to the refresh list.
Definition base.cc:612
void stop()
Stops the refresher background thread if it is running.
Definition base.cc:654
uint16_t position() const noexcept
Returns the device position or ID.
Definition base.cc:324
int code() const noexcept
Returns the device-specific error code.
Definition base.cc:328
DeviceResponseException(const std::string &what_arg, uint16_t position, int code)
Constructs a DeviceResponseException.
Definition base.cc:320
Abstract interface representing a generic device.
Definition base.h:1108
virtual ~Device()=default
Virtual destructor for Device interface.
virtual uint16_t getPosition() const =0
Gets the device's position in the network chain.
virtual size_t loadParameters(bool readValues, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(9000))=0
Loads parameters from the device and stores them locally.
virtual Parameter & upload(uint16_t index, uint8_t subindex, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Uploads a parameter from the device via SDO and updates the local parameter store.
virtual void removeFile(const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Removes a file from the device.
virtual void exchangeProcessDataAndUpdateParameters(uint64_t missedCycles=0)=0
Exchanges process data with the remote device and updates local parameters accordingly.
virtual void writeFile(const std::string &filename, const std::vector< uint8_t > &data, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Sends a file to the device.
virtual void download(uint16_t index, uint8_t subindex, const ParameterValue &value, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Sets a parameter value in the local store and downloads it to the device.
virtual PdoMappingStatus getPdoMappingStatus(uint16_t index, uint8_t subindex) const =0
Determines the PDO mapping status of a parameter by its index and subindex.
virtual void updateFirmware(const std::vector< std::uint8_t > &data, const std::vector< std::string > &skipFiles={}, std::function< void(uint8_t, std::string)> progressCallback=nullptr, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(60000))=0
Updates the device firmwares.
virtual std::vector< uint8_t > readFile(const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Reads the contents of a file from the device.
virtual std::vector< std::string > readFileList(const bool stripSizeSuffix, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Reads a list of file names from the device.
virtual void clearParameters()=0
Clears all loaded object dictionary parameters.
virtual bool isOnline()=0
Checks if the device is online.
virtual void download(uint16_t index, uint8_t subindex, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Downloads a parameter to the device using SDO communication.
virtual bool setState(uint8_t state, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Sets the device to a specified state.
virtual Parameter & findParameter(uint16_t index, uint8_t subindex)=0
Finds and returns a reference to a parameter by its index and subindex.
virtual std::vector< std::reference_wrapper< Parameter > > parameters()=0
Get a vector of references to parameters.
virtual uint8_t getState(bool refresh=false, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(5000))=0
Reads and returns the current state of the device.
Represents a device parameter identified by index and subindex.
Definition base.h:529
bool hasAllRead() const
Checks if all read access flags are set in the access field.
Definition base.cc:208
ParameterValue getValue() const
Retrieves the value of the parameter based on its data type.
Definition base.cc:41
ObjectDataType dataType
The data type of the parameter.
Definition base.h:575
T getIntValue()
Converts the internal byte vector to an integer of type T.
Definition base.h:704
ObjectCode code
The object code for the parameter.
Definition base.h:580
ObjectFlags access
The access flags for the parameter.
Definition base.h:590
std::optional< T > tryGetValue() const
Attempts to retrieve the parameter value from the ParameterValue variant as the specified type.
Definition base.h:683
std::string name
Name of the parameter.
Definition base.h:550
static void to_json(nlohmann::json &j, const Parameter &p)
Serializes a Parameter object to JSON.
Definition base.cc:216
static void from_json(const nlohmann::json &j, Parameter &p)
Deserializes a Parameter object from JSON.
Definition base.cc:228
std::pair< uint16_t, uint8_t > Address
Alias for a pair of uint16_t and uint8_t representing a parameter address.
Definition base.h:539
void setValue(const T &value)
Sets the parameter value using a strongly-typed input.
Definition base.h:748
std::vector< std::uint8_t > data
Holds raw data as a vector of uint8_t elements.
Definition base.h:603
bool operator==(const Parameter &other) const
Checks if two Parameter objects are equal.
Definition base.h:900
std::uint16_t index
Index of the parameter.
Definition base.h:555
T getValue() const
Retrieves the parameter value from the ParameterValue variant as the specified type.
Definition base.h:655
bool operator<(const Parameter &other) const
Compares two Parameter objects for ordering.
Definition base.h:864
bool trySetValue(const T &value)
Attempts to set the parameter value with a strongly-typed input.
Definition base.h:771
std::uint16_t bitLength
Bit length of the parameter.
Definition base.h:565
bool hasAllWrite() const
Checks if all write access flags are set in the access field.
Definition base.cc:212
std::string group
Name of the group this parameter belongs to. Applicable only to ARRAY and RECORD objects.
Definition base.h:545
ObjectFlags flags
The object flags for the parameter.
Definition base.h:585
bool operator>(const Parameter &other) const
Compares two Parameter objects for reverse ordering.
Definition base.h:882
std::uint8_t subindex
Subindex of the parameter.
Definition base.h:560
void setValue(const ParameterValue &value)
Sets the internal raw data representation from a given value.
Definition base.cc:129
int byteLength
Byte length of the parameter.
Definition base.h:570
PdoMappingStatus pdoMappingStatus
PDO mapping status of this parameter.
Definition base.h:598
uint8_t * value
Definition co_dictionary.h:9
uint16_t index
Definition co_dictionary.h:0
COD_Subitem * entry
Definition co_dictionary.h:8
void from_json(const nlohmann::json &j, UiPdoMapping &p)
Deserialize a JSON object into a UiPdoMapping structure.
Definition base.cc:15
std::string makeParameterId(int index, int subindex)
Formats the given index and subindex into a parameter identifier string.
Definition base.h:1657
std::string deviceFileErrorToString(DeviceFileError error)
Convert a DeviceFileError enum value to a human-readable string.
Definition base.h:1078
std::set< std::string > kNonPartedFileNames
Set of filenames that are always stored as complete files and can be read directly.
Definition base.cc:330
const std::unordered_set< std::string > kFirmwareInstallationFilenameWhitelist
Whitelist of allowed filenames inside a firmware package archive.
Definition base.h:989
bool operator==(uint32_t lhs, EtherCATVendorID rhs)
Compares a uint32_t value with an EtherCATVendorID enum value.
Definition base.h:97
ObjectDataType
Enumerates the supported data types for parameters.
Definition base.h:333
@ BIT14
14-bit field.
Definition base.h:354
@ UNSIGNED40
40-bit unsigned integer.
Definition base.h:375
@ INTEGER16
16-bit signed integer.
Definition base.h:363
@ UNICODE_STRING
Definition base.h:387
@ BACKUP_PARAMETER
For BACKUP_PARAMETER definition see ETG.1020.
Definition base.h:403
@ UNSPECIFIED
Undefined or unknown data type.
Definition base.h:334
@ INTEGER64
64-bit signed integer.
Definition base.h:369
@ SM_SYNCHRONIZATION
For SM_SYNCHRONIZATION definition see ETG.1000.
Definition base.h:399
@ EXTERNAL_SYNC_STATUS
Definition base.h:409
@ BIT8
8-bit field.
Definition base.h:348
@ ERROR_SETTING
For ERROR_SETTING definition see ETG.1020.
Definition base.h:406
@ INTEGER32
32-bit signed integer.
Definition base.h:365
@ BIT10
10-bit field.
Definition base.h:350
@ ARRAY_OF_INT
Sequence of INT.
Definition base.h:389
@ TIME_OF_DAY
Time of day format (implementation-defined).
Definition base.h:419
@ REAL32
32-bit floating-point number.
Definition base.h:380
@ UNSIGNED56
56-bit unsigned integer.
Definition base.h:377
@ UNSIGNED8
8-bit unsigned integer.
Definition base.h:371
@ MODULAR_DEVICE_PARAMETER
Definition base.h:404
@ BITARR8
Array of 8 bits.
Definition base.h:358
@ BITARR32
Array of 32 bits.
Definition base.h:360
@ UNSIGNED64
64-bit unsigned integer.
Definition base.h:378
@ BIT3
3-bit field.
Definition base.h:343
@ REAL64
64-bit floating-point number (double).
Definition base.h:381
@ DEFTYPE_FSOECOMMPAR
Definition base.h:415
@ BIT13
13-bit field.
Definition base.h:353
@ GUID
128-bit globally unique identifier.
Definition base.h:383
@ BIT1
1-bit field.
Definition base.h:341
@ INTEGER40
40-bit signed integer.
Definition base.h:366
@ PDO_PARAMETER
For PDO_PARAMETER definition see ETG.1020.
Definition base.h:397
@ ENUM
For ENUM definition see ETG.1020.
Definition base.h:398
@ EXTERNAL_SYNC_SETTINGS
Definition base.h:411
@ UNSIGNED48
48-bit unsigned integer.
Definition base.h:376
@ DWORD
Four octets (32 bits) unsigned integer.
Definition base.h:339
@ BIT9
9-bit field.
Definition base.h:349
@ BIT16
16-bit field.
Definition base.h:356
@ UTYPE_END
End of user-defined type range.
Definition base.h:423
@ ARRAY_OF_SINT
Sequence of SINT.
Definition base.h:390
@ RECORD
Definition base.h:401
@ UNSIGNED16
16-bit unsigned integer.
Definition base.h:372
@ INTEGER48
48-bit signed integer.
Definition base.h:367
@ ARRAY_OF_UDINT
Sequence of UDINT.
Definition base.h:392
@ BIT6
6-bit field.
Definition base.h:346
@ BIT2
2-bit field.
Definition base.h:342
@ INTEGER56
56-bit signed integer.
Definition base.h:368
@ DEFTYPE_FSOEFRAME
Definition base.h:413
@ BITARR16
Array of 16 bits.
Definition base.h:359
@ VISIBLE_STRING
Null-terminated ASCII string.
Definition base.h:385
@ BIT11
11-bit field.
Definition base.h:351
@ BIT4
4-bit field.
Definition base.h:344
@ BIT12
12-bit field.
Definition base.h:352
@ WORD
Two octets (16 bits) unsigned integer.
Definition base.h:338
@ BIT5
5-bit field.
Definition base.h:345
@ BIT15
15-bit field.
Definition base.h:355
@ BOOLEAN
Boolean value (true or false).
Definition base.h:336
@ BIT7
7-bit field.
Definition base.h:347
@ UNSIGNED32
32-bit unsigned integer.
Definition base.h:374
@ DIAGNOSIS_HISTORY
For DIAGNOSIS_HISTORY definition see ETG.1020.
Definition base.h:407
@ INTEGER24
24-bit signed integer.
Definition base.h:364
@ ARRAY_OF_DINT
Sequence of DINT.
Definition base.h:391
@ COMMAND_PAR
For COMMAND_PAR definition see ETG.1000.
Definition base.h:396
@ IDENTITY
For IDENTITY definition see ETG.1000.
Definition base.h:395
@ TIME_DIFFERENCE
Time difference format (implementation-defined).
Definition base.h:420
@ BYTE
8-bit unsigned integer.
Definition base.h:337
@ PDO_MAPPING
For PDO_MAPPING definition see ETG.1000.
Definition base.h:394
@ UNSIGNED24
24-bit unsigned integer.
Definition base.h:373
@ OCTET_STRING
Array of raw bytes.
Definition base.h:386
@ INTEGER8
8-bit signed integer.
Definition base.h:362
@ UTYPE_START
Start of user-defined type range.
Definition base.h:422
void writeDeviceFileInOptionalParts(Device &device, const std::string &filename, const std::vector< std::uint8_t > &data, std::function< void(uint8_t, std::string)> progressCallback, const std::chrono::steady_clock::duration expiryTime)
Write a file to a device in a single transfer.
Definition base.cc:434
mm::comm::base::PdoMappingEntry parsePdoMapping(uint32_t mapping, uint16_t pdoIndex, uint8_t pdoSubindex)
Parses a 32-bit raw PDO mapping value into a PdoMappingEntry.
Definition base.cc:721
EtherCATVendorID
Enum class representing EtherCAT vendor IDs.
Definition base.h:75
@ SYNAPTICON
Vendor ID for Synapticon GmbH.
Definition base.h:81
@ SENSODRIVE
Vendor ID for Sensodrive GmbH.
Definition base.h:83
ObjectCode
Enum class representing different object types used in the EtherCAT protocol.
Definition base.h:435
@ DEFSTRUCT
Definition structure object.
Definition base.h:437
@ DEFTYPE
Definition type object.
Definition base.h:436
@ ARRAY
Array object type.
Definition base.h:439
@ VAR
Variable object type.
Definition base.h:438
void logParametersMap(const std::unordered_map< Parameter::Address, Parameter > ¶metersMap, bool sortParameters)
Logs the contents of a map of parameters with an option to sort them.
Definition base.cc:293
ObjectFlags SetObjectFlags(ObjectFlags b, ObjectFlags s, ObjectFlags p, ObjectFlags a)
Combine multiple ObjectFlags values into one.
Definition base.h:316
bool isComBinFile(const std::string &filename)
Checks whether a given filename starts with "com_" and ends with ".bin".
Definition base.h:1021
void removeDeviceFileOrParts(Device &device, const std::string &filename, const std::chrono::steady_clock::duration expiryTime)
Removes a file from the device, including any legacy chunks of the ESI / stack image files.
Definition base.cc:464
ObjectFlags operator|(ObjectFlags lhs, ObjectFlags rhs)
Bitwise OR operator for ObjectFlags enum class.
Definition base.h:268
DeviceFileError
Enumeration of possible device file-related error codes.
Definition base.h:1043
@ CommunicationBridgeError
Definition base.h:1061
@ StorageFull
Definition base.h:1047
@ PacketNumber
Definition base.h:1049
@ EmptyContent
Definition base.h:1062
@ FilenameLength
Definition base.h:1057
@ ZipFailure
Definition base.h:1064
@ FlashBusy
Definition base.h:1059
@ NotFound
Definition base.h:1045
@ None
Definition base.h:1044
@ IllegalRequest
Definition base.h:1048
@ BootstrapOnly
Definition base.h:1052
@ Unknown
Definition base.h:1069
@ SuccessAcknowledgement
Definition base.h:1060
@ AlreadyExists
Definition base.h:1050
@ UnzipFailure
Definition base.h:1065
@ RemoveFailure
Definition base.h:1068
@ NoUser
Definition base.h:1051
@ NoRights
Definition base.h:1054
@ FlashFailure
Definition base.h:1066
@ Timeout
Definition base.h:1058
@ AccessDenied
Definition base.h:1046
@ NotBootstrap
Definition base.h:1053
@ Busy
Definition base.h:1056
@ ProgramError
Definition base.h:1055
@ UnexpectedNullTerminator
Definition base.h:1063
@ WriteFailure
Definition base.h:1067
std::vector< mm::comm::base::Parameter::Address > makeAllPdoAddresses()
Generates a complete vector of all PDO addresses for Rx and Tx.
Definition base.cc:750
PdoMappingStatus
Represents the PDO mapping status of a parameter.
Definition base.h:502
@ MAPPED_RX_PDO
The parameter is mapped as a Receive PDO.
Definition base.h:504
@ NOT_MAPPED
The parameter is not mapped in any PDO.
Definition base.h:503
@ MAPPED_TX_PDO
The parameter is mapped as a Transmit PDO.
Definition base.h:505
void writeFirmwarePackage(Device &device, const std::vector< std::uint8_t > &data, const std::vector< std::string > &skipFiles, std::function< void(uint8_t, std::string)> progressCallback, const std::chrono::steady_clock::duration expiryTime)
Writes a firmware package to the given device.
Definition base.cc:535
std::variant< bool, std::int8_t, std::int16_t, std::int32_t, std::int64_t, std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t, float, double, std::string, std::vector< std::uint8_t > > ParameterValue
Alias for a variant that can hold multiple types of values.
Definition base.h:466
void assignGroupsToParameters(std::vector< Parameter > ¶meters)
Assigns group names to parameters based on their index and subindex.
Definition base.cc:259
std::vector< mm::comm::base::Parameter::Address > makeParameterAddressIndexRange(uint16_t start, uint16_t end, uint8_t maxSubIndex)
Generates a vector of Parameter addresses in a given index/subindex range.
Definition base.cc:735
std::vector< std::uint8_t > readCompleteDeviceFile(Device &device, const std::string &filename, const std::chrono::steady_clock::duration expiryTime)
Reads a file from the device.
Definition base.cc:344
ObjectFlags operator&(ObjectFlags lhs, ObjectFlags rhs)
Bitwise AND operator for ObjectFlags enum class.
Definition base.h:283
ObjectFlags & operator|=(ObjectFlags &lhs, ObjectFlags rhs)
Bitwise OR assignment operator for ObjectFlags enum class.
Definition base.h:298
ObjectFlags
Enum class representing various object flags.
Definition base.h:225
@ ALL_WR
Definition base.h:238
@ ALL_LIST_FLAGS
Definition base.h:255
@ RXPDO_MAP
Definition base.h:247
@ STARTUP
Definition base.h:253
@ OP_RDWR
Definition base.h:243
@ ALL_RDWR
Definition base.h:244
@ PO_RD
Definition base.h:229
@ ALL_RD
Definition base.h:232
@ PO_RDWR
Definition base.h:241
@ None
Definition base.h:226
@ RXTXPDO_MAP
Definition base.h:249
@ SO_WR
Definition base.h:236
@ OP_RD
Definition base.h:231
@ OP_WR
Definition base.h:237
@ SO_RDWR
Definition base.h:242
@ BACKUP
Definition base.h:252
@ SO_RD
Definition base.h:230
@ TXPDO_MAP
Definition base.h:248
@ PO_WR
Definition base.h:235
bool isAppBinFile(const std::string &filename)
Checks whether a given filename starts with "app_" and ends with ".bin".
Definition base.h:1004
bool isFirmwareBinFile(const std::string &filename)
Checks whether the given file is a firmware binary file.
Definition base.h:1035
std::string convertParameterValueToString(const ParameterValue &value)
Converts a ParameterValue to a string representation.
Definition base.cc:240
@ LITTLE
Definition util.h:77
T toInteger(const std::vector< std::uint8_t > &data, std::size_t offset=0, Endianness endian=Endianness::LITTLE)
Converts a byte sequence to an integer of type T with optional offset and endianness.
Definition util.h:103
void to_json(nlohmann::json &j, const mm::comm::base::MappedParameterValue &p)
Serialize MappedParameterValue to JSON.
Definition base.h:1924
void from_json(const nlohmann::json &j, mm::comm::base::MappedParameterValue &p)
Deserialize JSON into MappedParameterValue.
Definition base.h:1935
Represents a single mapped parameter value.
Definition base.h:479
uint8_t subindex
Definition base.h:481
uint16_t index
Definition base.h:480
ParameterValue value
Definition base.h:482
Holds collections of mapped parameter values for RX and TX directions.
Definition base.h:491
std::vector< MappedParameterValue > rx
Definition base.h:492
std::vector< MappedParameterValue > tx
Definition base.h:493
Represents a single PDO (Process Data Object) mapping entry.
Definition base.h:126
PdoMappingEntry(uint16_t pdoIndex, uint8_t pdoSubindex, uint16_t index, uint8_t subindex, uint8_t bitlength)
Constructs a PDO mapping entry.
Definition base.h:148
uint16_t index
The object dictionary index (e.g., 0x607A)
Definition base.h:129
PdoMappingEntry()=default
Default constructor for PdoMappingEntry.
uint8_t subindex
The subindex of the object (e.g., 0x00)
Definition base.h:130
uint8_t pdoSubindex
The subindex within the PDO (e.g., 1, 2, etc.)
Definition base.h:128
uint8_t bitlength
The size of the mapped entry in bits (e.g., 16, 32, etc.)
Definition base.h:132
uint16_t pdoIndex
The PDO index (e.g., 0x1600 or 0x1A00)
Definition base.h:127
Represents the mapped PDO entries for a slave device.
Definition base.h:171
std::vector< PdoMappingEntry > txPdos
Definition base.h:174
size_t txSizeBytes() const
Get total size of TxPDOs in bytes.
Definition base.h:215
size_t txSizeBits() const
Get total size of TxPDOs in bits.
Definition base.h:193
size_t rxSizeBytes() const
Get total size of RxPDOs in bytes.
Definition base.h:207
size_t rxSizeBits() const
Get total size of RxPDOs in bits.
Definition base.h:181
std::vector< PdoMappingEntry > rxPdos
Definition base.h:172
Top-level UI configuration JSON structure.
Definition base.h:40
UiPdoMapping pdoMapping
Definition base.h:41
Represents the PDO mapping for RX and TX channels.
Definition base.h:30
std::map< std::uint16_t, std::vector< std::uint32_t > > rx
Definition base.h:31
std::map< std::uint16_t, std::vector< std::uint32_t > > tx
Definition base.h:32
static void to_json(json &j, const mm::comm::base::ParameterValue &value)
Definition base.h:1872
static void from_json(const json &j, mm::comm::base::ParameterValue &value)
Definition base.h:1876