Motion Master
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
mm::comm::base Namespace Reference

Classes

class  Device
 Abstract interface representing a generic device. More...
 
class  DeviceManager
 Manages devices and performs cyclic process data exchange. More...
 
class  DeviceParameterRefresher
 Base class for periodically refreshing a set of device parameters in a background thread. More...
 
class  DeviceResponseException
 Exception thrown when a device responds with an error. More...
 
struct  MappedParameterValue
 Represents a single mapped parameter value. More...
 
struct  MappedParameterValues
 Holds collections of mapped parameter values for RX and TX directions. More...
 
class  Parameter
 Represents a device parameter identified by index and subindex. More...
 
struct  PdoMappingEntry
 Represents a single PDO (Process Data Object) mapping entry. More...
 
struct  PdoMappings
 Represents the mapped PDO entries for a slave device. More...
 
struct  UiConfigJson
 Top-level UI configuration JSON structure. More...
 
struct  UiPdoMapping
 Represents the PDO mapping for RX and TX channels. More...
 

Typedefs

using ParameterValue = 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 > >
 

Enumerations

enum class  EtherCATVendorID : uint32_t { SYNAPTICON = 0x000022d2 }
 Enum class representing EtherCAT vendor IDs. More...
 
enum class  ObjectFlags : uint16_t {
  None = 0x0000 , PO_RD = 0x0001 , SO_RD = 0x0002 , OP_RD = 0x0004 ,
  ALL_RD = PO_RD | SO_RD | OP_RD , PO_WR = 0x0008 , SO_WR = 0x0010 , OP_WR = 0x0020 ,
  ALL_WR = PO_WR | SO_WR | OP_WR , PO_RDWR = PO_RD | PO_WR , SO_RDWR = SO_RD | SO_WR , OP_RDWR = OP_RD | OP_WR ,
  ALL_RDWR = PO_RDWR | SO_RDWR | OP_RDWR , RXPDO_MAP = 0x0040 , TXPDO_MAP = 0x0080 , RXTXPDO_MAP = 0x00C0 ,
  BACKUP = 0x0100 , STARTUP = 0x0200 , ALL_LIST_FLAGS = RXPDO_MAP | TXPDO_MAP | BACKUP | STARTUP
}
 Enum class representing various object flags. More...
 
enum class  ObjectDataType : uint16_t {
  UNSPECIFIED = 0x0000 , BOOLEAN = 0x0001 , BYTE = 0x001E , WORD = 0x001F ,
  DWORD = 0x0020 , BIT1 = 0x0030 , BIT2 = 0x0031 , BIT3 = 0x0032 ,
  BIT4 = 0x0033 , BIT5 = 0x0034 , BIT6 = 0x0035 , BIT7 = 0x0036 ,
  BIT8 = 0x0037 , BIT9 = 0x0038 , BIT10 = 0x0039 , BIT11 = 0x003A ,
  BIT12 = 0x003B , BIT13 = 0x003C , BIT14 = 0x003D , BIT15 = 0x003E ,
  BIT16 = 0x003F , BITARR8 = 0x002D , BITARR16 = 0x002E , BITARR32 = 0x002F ,
  INTEGER8 = 0x0002 , INTEGER16 = 0x0003 , INTEGER24 = 0x0010 , INTEGER32 = 0x0004 ,
  INTEGER40 = 0x0012 , INTEGER48 = 0x0013 , INTEGER56 = 0x0014 , INTEGER64 = 0x0015 ,
  UNSIGNED8 = 0x0005 , UNSIGNED16 = 0x0006 , UNSIGNED24 = 0x0016 , UNSIGNED32 = 0x0007 ,
  UNSIGNED40 = 0x0018 , UNSIGNED48 = 0x0019 , UNSIGNED56 = 0x001A , UNSIGNED64 = 0x001B ,
  REAL32 = 0x0008 , REAL64 = 0x0011 , GUID = 0x001D , VISIBLE_STRING = 0x0009 ,
  OCTET_STRING = 0x000A , UNICODE_STRING = 0x000B , ARRAY_OF_INT = 0x0260 , ARRAY_OF_SINT = 0x0261 ,
  ARRAY_OF_DINT = 0x0262 , ARRAY_OF_UDINT = 0x0263 , PDO_MAPPING = 0x0021 , IDENTITY = 0x0023 ,
  COMMAND_PAR = 0x0025 , PDO_PARAMETER = 0x0027 , ENUM = 0x0028 , SM_SYNCHRONIZATION ,
  RECORD = 0x002A , BACKUP_PARAMETER = 0x002B , MODULAR_DEVICE_PARAMETER = 0x002C , ERROR_SETTING = 0x0281 ,
  DIAGNOSIS_HISTORY , EXTERNAL_SYNC_STATUS = 0x0283 , EXTERNAL_SYNC_SETTINGS = 0x0284 , DEFTYPE_FSOEFRAME = 0x0285 ,
  DEFTYPE_FSOECOMMPAR , TIME_OF_DAY = 0x000C , TIME_DIFFERENCE , UTYPE_START = 0x0800 ,
  UTYPE_END = 0x0FFF
}
 Enumerates the supported data types for parameters. More...
 
enum class  ObjectCode : uint16_t {
  DEFTYPE = 0x0005 , DEFSTRUCT = 0x0006 , VAR = 0x0007 , ARRAY = 0x0008 ,
  RECORD = 0x0009
}
 Enum class representing different object types used in the EtherCAT protocol. More...
 
enum class  PdoMappingStatus { NOT_MAPPED , MAPPED_RX_PDO , MAPPED_TX_PDO }
 Represents the PDO mapping status of a parameter. More...
 
enum class  DeviceFileError : uint8_t {
  None = 0x00 , NotFound = 0x01 , AccessDenied = 0x02 , StorageFull = 0x03 ,
  IllegalRequest = 0x04 , PacketNumber = 0x05 , AlreadyExists = 0x06 , NoUser = 0x07 ,
  BootstrapOnly = 0x08 , NotBootstrap = 0x09 , NoRights = 0x0A , ProgramError = 0x0B ,
  Busy = 0x0C , FilenameLength = 0x0D , Timeout = 0x0E , FlashBusy = 0x28 ,
  SuccessAcknowledgement = 0x58 , CommunicationBridgeError = 0x63 , EmptyContent = 0xD0 , UnexpectedNullTerminator = 0xD1 ,
  ZipFailure = 0xD2 , UnzipFailure = 0xD3 , FlashFailure = 0xD4 , WriteFailure = 0xD5 ,
  RemoveFailure = 0xD6 , Unknown = 0xFF
}
 Enumeration of possible device file-related error codes. More...
 

Functions

void from_json (const nlohmann::json &j, UiPdoMapping &p)
 Deserialize a JSON object into a UiPdoMapping structure. More...
 
void from_json (const nlohmann::json &j, UiConfigJson &r)
 Deserialize a JSON object into a UiConfigJson structure. More...
 
std::string convertParameterValueToString (const ParameterValue &value)
 Converts a ParameterValue to a string representation. More...
 
void assignGroupsToParameters (std::vector< Parameter > &parameters)
 Assigns group names to parameters based on their index and subindex. More...
 
void logParametersMap (const std::unordered_map< Parameter::Address, Parameter > &parametersMap, bool sortParameters=true)
 Logs the contents of a map of parameters with an option to sort them. More...
 
std::vector< std::uint8_t > readCompleteDeviceFile (Device &device, const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(20000))
 Reads a file from the device, supporting both complete and multipart zipped files. More...
 
void writeDeviceFileInOptionalParts (Device &device, const std::string &filename, const std::vector< std::uint8_t > &data, std::function< void(uint8_t, std::string)> progressCallback=nullptr, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(30000))
 Write a file to a device, splitting it into parts if necessary. More...
 
void removeDeviceFileOrParts (Device &device, const std::string &filename, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(20000))
 Removes a file from the device, including handling multipart files if applicable. More...
 
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=nullptr, const std::chrono::steady_clock::duration expiryTime=std::chrono::milliseconds(60000))
 Writes a firmware package to the given device. More...
 
bool operator== (uint32_t lhs, EtherCATVendorID rhs)
 Compares a uint32_t value with an EtherCATVendorID enum value. More...
 
bool operator== (EtherCATVendorID lhs, uint32_t rhs)
 Compares an EtherCATVendorID enum value with a uint32_t value. More...
 
ObjectFlags operator| (ObjectFlags lhs, ObjectFlags rhs)
 Bitwise OR operator for ObjectFlags enum class. More...
 
ObjectFlags operator& (ObjectFlags lhs, ObjectFlags rhs)
 Bitwise AND operator for ObjectFlags enum class. More...
 
ObjectFlagsoperator|= (ObjectFlags &lhs, ObjectFlags rhs)
 Bitwise OR assignment operator for ObjectFlags enum class. More...
 
ObjectFlags SetObjectFlags (ObjectFlags b, ObjectFlags s, ObjectFlags p, ObjectFlags a)
 Combine multiple ObjectFlags values into one. More...
 
bool isAppBinFile (const std::string &filename)
 Checks whether a given filename starts with "app_" and ends with ".bin". More...
 
bool isComBinFile (const std::string &filename)
 Checks whether a given filename starts with "com_" and ends with ".bin". More...
 
bool isFirmwareBinFile (const std::string &filename)
 Checks whether the given file is a firmware binary file. More...
 
std::string deviceFileErrorToString (DeviceFileError error)
 Convert a DeviceFileError enum value to a human-readable string. More...
 
std::string makeParameterId (int index, int subindex)
 Formats the given index and subindex into a parameter identifier string. More...
 

Variables

std::set< std::string > kNonPartedFileNames
 Set of filenames that are always stored as complete files and can be read directly. More...
 
constexpr std::size_t kDeviceFilePartSize
 

Typedef Documentation

◆ ParameterValue

using mm::comm::base::ParameterValue = typedef 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> >

Alias for a variant type holding multiple value types.

Enumeration Type Documentation

◆ DeviceFileError

enum class mm::comm::base::DeviceFileError : uint8_t
strong

Enumeration of possible device file-related error codes.

Enumerator
None 
NotFound 
AccessDenied 
StorageFull 
IllegalRequest 
PacketNumber 
AlreadyExists 
NoUser 
BootstrapOnly 
NotBootstrap 
NoRights 
ProgramError 
Busy 
FilenameLength 
Timeout 
FlashBusy 
SuccessAcknowledgement 
CommunicationBridgeError 
EmptyContent 
UnexpectedNullTerminator 
ZipFailure 
UnzipFailure 
FlashFailure 
WriteFailure 
RemoveFailure 
Unknown 

◆ EtherCATVendorID

enum class mm::comm::base::EtherCATVendorID : uint32_t
strong

Enum class representing EtherCAT vendor IDs.

This enum class defines vendor IDs for EtherCAT devices, with each vendor ID being represented by a unique 32-bit unsigned integer value. It is used to identify different EtherCAT vendors in the system.

Enumerator
SYNAPTICON 

Vendor ID for Synapticon GmbH.

Synapticon GmbH provides high-performance and compact servo drives. Vendor ID for Synapticon GmbH

◆ ObjectCode

enum class mm::comm::base::ObjectCode : uint16_t
strong

Enum class representing different object types used in the EtherCAT protocol.

This enum class defines various object types that represent the kind of object in an EtherCAT device. Each value corresponds to a specific type of object, such as a definition, variable, array, or record, in the EtherCAT protocol.

Enumerator
DEFTYPE 

Definition type object.

DEFSTRUCT 

Definition structure object.

VAR 

Variable object type.

ARRAY 

Array object type.

RECORD 

Record object type.

◆ ObjectDataType

enum class mm::comm::base::ObjectDataType : uint16_t
strong

Enumerates the supported data types for parameters.

This enumeration defines the various data types that parameters can use. Each entry is explicitly mapped to a 16-bit unsigned integer value. It includes basic types such as integers, floating-point numbers, strings, time-related types, bitfields, and user-defined types.

Note
The values in this enumeration are defined in the ETG.1020 document, which outlines the EtherCAT protocol and its supported data types.
Enumerator
UNSPECIFIED 

Undefined or unknown data type.

BOOLEAN 

Boolean value (true or false).

BYTE 

8-bit unsigned integer.

WORD 

Two octets (16 bits) unsigned integer.

DWORD 

Four octets (32 bits) unsigned integer.

BIT1 

1-bit field.

BIT2 

2-bit field.

BIT3 

3-bit field.

BIT4 

4-bit field.

BIT5 

5-bit field.

BIT6 

6-bit field.

BIT7 

7-bit field.

BIT8 

8-bit field.

BIT9 

9-bit field.

BIT10 

10-bit field.

BIT11 

11-bit field.

BIT12 

12-bit field.

BIT13 

13-bit field.

BIT14 

14-bit field.

BIT15 

15-bit field.

BIT16 

16-bit field.

BITARR8 

Array of 8 bits.

BITARR16 

Array of 16 bits.

BITARR32 

Array of 32 bits.

INTEGER8 

8-bit signed integer.

INTEGER16 

16-bit signed integer.

INTEGER24 

24-bit signed integer.

INTEGER32 

32-bit signed integer.

INTEGER40 

40-bit signed integer.

INTEGER48 

48-bit signed integer.

INTEGER56 

56-bit signed integer.

INTEGER64 

64-bit signed integer.

UNSIGNED8 

8-bit unsigned integer.

UNSIGNED16 

16-bit unsigned integer.

UNSIGNED24 

24-bit unsigned integer.

UNSIGNED32 

32-bit unsigned integer.

UNSIGNED40 

40-bit unsigned integer.

UNSIGNED48 

48-bit unsigned integer.

UNSIGNED56 

56-bit unsigned integer.

UNSIGNED64 

64-bit unsigned integer.

REAL32 

32-bit floating-point number.

REAL64 

64-bit floating-point number (double).

GUID 

128-bit globally unique identifier.

VISIBLE_STRING 

Null-terminated ASCII string.

OCTET_STRING 

Array of raw bytes.

UNICODE_STRING 

Null-terminated Unicode string (UTF-16/UTF-32 depending on platform).

ARRAY_OF_INT 

Sequence of INT.

ARRAY_OF_SINT 

Sequence of SINT.

ARRAY_OF_DINT 

Sequence of DINT.

ARRAY_OF_UDINT 

Sequence of UDINT.

PDO_MAPPING 

For PDO_MAPPING definition see ETG.1000.

IDENTITY 

For IDENTITY definition see ETG.1000.

COMMAND_PAR 

For COMMAND_PAR definition see ETG.1000.

PDO_PARAMETER 

For PDO_PARAMETER definition see ETG.1020.

ENUM 

For ENUM definition see ETG.1020.

SM_SYNCHRONIZATION 

For SM_SYNCHRONIZATION definition see ETG.1000.

RECORD 

No pre-defined Record structure. Can be used as a general data type for Records.

BACKUP_PARAMETER 

For BACKUP_PARAMETER definition see ETG.1020.

MODULAR_DEVICE_PARAMETER 

For MODULAR_DEVICE_PARAMETER definition see ETG.5001

ERROR_SETTING 

For ERROR_SETTING definition see ETG.1020.

DIAGNOSIS_HISTORY 

For DIAGNOSIS_HISTORY definition see ETG.1020.

EXTERNAL_SYNC_STATUS 

For EXTERNAL_SYNC_STATUS definition see ETG.1020

EXTERNAL_SYNC_SETTINGS 

For EXTERNAL_SYNC_SETTINGS definition see ETG.1020

DEFTYPE_FSOEFRAME 

For DEFTYPE_FSOEFRAME definition see ETG.5120

DEFTYPE_FSOECOMMPAR 

For DEFTYPE_FSOECOMMPAR definition see ETG.5120

TIME_OF_DAY 

Time of day format (implementation-defined).

TIME_DIFFERENCE 

Time difference format (implementation-defined).

UTYPE_START 

Start of user-defined type range.

UTYPE_END 

End of user-defined type range.

◆ ObjectFlags

enum class mm::comm::base::ObjectFlags : uint16_t
strong

Enum class representing various object flags.

This enum class defines different flags used for controlling access, mapping, and other attributes. It is represented as a 16-bit unsigned integer.

Enumerator
None 
PO_RD 
SO_RD 
OP_RD 
ALL_RD 
PO_WR 
SO_WR 
OP_WR 
ALL_WR 
PO_RDWR 
SO_RDWR 
OP_RDWR 
ALL_RDWR 
RXPDO_MAP 
TXPDO_MAP 
RXTXPDO_MAP 
BACKUP 
STARTUP 
ALL_LIST_FLAGS 

◆ PdoMappingStatus

Represents the PDO mapping status of a parameter.

This enum indicates whether a parameter is not mapped in any PDO, or if it is mapped as a receive (RX) or transmit (TX) PDO.

Enumerator
NOT_MAPPED 

The parameter is not mapped in any PDO.

MAPPED_RX_PDO 

The parameter is mapped as a Receive PDO.

MAPPED_TX_PDO 

The parameter is mapped as a Transmit PDO.

Function Documentation

◆ assignGroupsToParameters()

void mm::comm::base::assignGroupsToParameters ( std::vector< Parameter > &  parameters)

Assigns group names to parameters based on their index and subindex.

This function iterates over a list of parameters and assigns a group name to each, based on the presence of subitems within the same index:

  • Parameters with subindex 0 and no subitems receive an empty group name.
  • Parameters with subindex 0 that have subitems receive their own name as the group.
  • Parameters with subindex greater than 0 receive the group name of the subindex 0 parameter sharing the same index.
Parameters
parametersVector of Parameter objects whose group fields will be updated in-place.

◆ convertParameterValueToString()

std::string mm::comm::base::convertParameterValueToString ( const ParameterValue value)

Converts a ParameterValue to a string representation.

This function uses std::visit to convert the given ParameterValue (a std::variant of numeric and string types) to a human-readable string.

  • bool values are converted to "true" or "false".
  • Integral and floating-point values are converted using std::to_string().
  • std::string values are returned as-is.
Parameters
valueThe parameter value to convert.
Returns
A string representation of the value.

◆ deviceFileErrorToString()

std::string mm::comm::base::deviceFileErrorToString ( DeviceFileError  error)
inline

Convert a DeviceFileError enum value to a human-readable string.

Parameters
errorThe DeviceFileError value to convert.
Returns
A std::string describing the error.

◆ from_json() [1/2]

void mm::comm::base::from_json ( const nlohmann::json &  j,
UiConfigJson r 
)

Deserialize a JSON object into a UiConfigJson structure.

Extracts the "pdoMapping" field from the JSON object and converts it into a UiPdoMapping instance, which is assigned to the pdoMapping member.

Parameters
jJSON object expected to contain a "pdoMapping" field.
rReference to UiConfigJson struct to populate.

◆ from_json() [2/2]

void mm::comm::base::from_json ( const nlohmann::json &  j,
UiPdoMapping p 
)

Deserialize a JSON object into a UiPdoMapping structure.

This function parses the JSON object representing the PDO mappings, extracting the "rx" and "tx" maps. The JSON keys are hex strings (e.g., "0x1600") which are converted to uint16_t keys in the maps. The values are arrays of hex strings representing uint32_t entries.

Parameters
jJSON object expected to contain "rx" and "tx" mappings.
pReference to UiPdoMapping struct to populate with parsed data.

◆ isAppBinFile()

bool mm::comm::base::isAppBinFile ( const std::string &  filename)
inline

Checks whether a given filename starts with "app_" and ends with ".bin".

This function is used to determine if a file matches the expected naming pattern for application (firmware) binary files, such as "app_motion-drive-v5.4.1.bin".

Parameters
filenameThe name of the file to check.
Returns
true if the filename starts with "app_" and ends with ".bin", false otherwise.

◆ isComBinFile()

bool mm::comm::base::isComBinFile ( const std::string &  filename)
inline

Checks whether a given filename starts with "com_" and ends with ".bin".

This function is used to determine if a file matches the expected naming pattern for communication (netX chip) binary files, such as "com_motion-drive-v5.4.1-9002-01.bin".

Parameters
filenameThe name of the file to check.
Returns
true if the filename starts with "com_" and ends with ".bin", false otherwise.

◆ isFirmwareBinFile()

bool mm::comm::base::isFirmwareBinFile ( const std::string &  filename)
inline

Checks whether the given file is a firmware binary file.

This function returns true if the file is recognized as either an application binary (app_) or a communication binary (com_).

Parameters
filenameThe name of the file to check.
Returns
true if the file is a firmware binary; false otherwise.

◆ logParametersMap()

void mm::comm::base::logParametersMap ( const std::unordered_map< Parameter::Address, Parameter > &  parametersMap,
bool  sortParameters = true 
)

Logs the contents of a map of parameters with an option to sort them.

This function takes a map of parameters indexed by (index, subindex) pairs, optionally sorts them by index and subindex (based on the sortParameters flag), and logs each parameter's details including its name, access type, bit length, and other relevant information.

If the sortParameters flag is true, the parameters will be sorted by index and subindex before logging. If sortParameters is false, the parameters will be logged in their original order as they appear in the map.

Parameters
parametersMapA map where each key is a pair of (index, subindex) and the value is a Parameter object containing metadata.
sortParametersA boolean flag indicating whether to sort the parameters before logging. Default is true. If true, the parameters are sorted by index and subindex; if false, they are logged in their original order.

◆ makeParameterId()

std::string mm::comm::base::makeParameterId ( int  index,
int  subindex 
)
inline

Formats the given index and subindex into a parameter identifier string.

This function takes an index and a subindex and formats them into a string of the form "0xINDEX:SUBINDEX". The index is formatted as a 4-digit hexadecimal number, and the subindex is formatted as a 2-digit hexadecimal number.

Parameters
indexThe 16-bit index value (e.g., 0x2030).
subindexThe 8-bit subindex value (e.g., 0x01).
Returns
std::string The formatted parameter ID string in the format "0xINDEX:SUBINDEX".

◆ operator&()

ObjectFlags mm::comm::base::operator& ( ObjectFlags  lhs,
ObjectFlags  rhs 
)
inline

Bitwise AND operator for ObjectFlags enum class.

This operator allows for checking the intersection of two ObjectFlags values using the bitwise AND operator.

Parameters
lhsLeft-hand operand of the bitwise AND operation.
rhsRight-hand operand of the bitwise AND operation.
Returns
The result of the bitwise AND operation as an ObjectFlags value.

◆ operator==() [1/2]

bool mm::comm::base::operator== ( EtherCATVendorID  lhs,
uint32_t  rhs 
)
inline

Compares an EtherCATVendorID enum value with a uint32_t value.

This operator allows comparison between an EtherCATVendorID enum value and a raw vendor ID (uint32_t). It converts the enum value to its underlying uint32_t type for the comparison.

Parameters
lhsThe EtherCATVendorID enum value to compare.
rhsThe raw vendor ID as a uint32_t.
Returns
true if the enum value matches the vendor ID, false otherwise.

◆ operator==() [2/2]

bool mm::comm::base::operator== ( uint32_t  lhs,
EtherCATVendorID  rhs 
)
inline

Compares a uint32_t value with an EtherCATVendorID enum value.

This operator allows comparison between a raw vendor ID (uint32_t) and an EtherCATVendorID enum value. It converts the enum to its underlying uint32_t type for the comparison.

Parameters
lhsThe raw vendor ID as a uint32_t.
rhsThe EtherCATVendorID enum value to compare.
Returns
true if the vendor ID matches the enum value, false otherwise.

◆ operator|()

ObjectFlags mm::comm::base::operator| ( ObjectFlags  lhs,
ObjectFlags  rhs 
)
inline

Bitwise OR operator for ObjectFlags enum class.

This operator allows for combining two ObjectFlags values using the bitwise OR operator.

Parameters
lhsLeft-hand operand of the bitwise OR operation.
rhsRight-hand operand of the bitwise OR operation.
Returns
The result of the bitwise OR operation as an ObjectFlags value.

◆ operator|=()

ObjectFlags & mm::comm::base::operator|= ( ObjectFlags lhs,
ObjectFlags  rhs 
)
inline

Bitwise OR assignment operator for ObjectFlags enum class.

This operator allows the modification of an ObjectFlags value by OR'ing it with another.

Parameters
lhsLeft-hand operand, which will be modified with the OR operation.
rhsRight-hand operand to OR with the left-hand operand.
Returns
The modified left-hand operand as an ObjectFlags value.

◆ readCompleteDeviceFile()

std::vector< std::uint8_t > mm::comm::base::readCompleteDeviceFile ( Device device,
const std::string &  filename,
const std::chrono::steady_clock::duration  expiryTime = std::chrono::milliseconds(20000) 
)

Reads a file from the device, supporting both complete and multipart zipped files.

This function handles reading a file from the specified device, covering several cases:

  • If the file is listed as non-parted or its name starts with "hr_data", it is read directly.
  • If the filename does not end with ".zip", a direct read is attempted first.
  • If the direct read fails, the function tries to read the file as a multipart archive, composed of parts named <filename>.zip.partNNN. All available parts are read, concatenated, and then unzipped.

If the resulting content is empty or unzipping yields no files, the function throws a std::runtime_error.

Parameters
deviceReference to the device to read from.
filenameName of the file to read.
expiryTimeMaximum duration to wait for the operation (default: 20 seconds).
Returns
A vector containing the uncompressed file content.
Exceptions
std::runtime_errorIf the file is empty, missing, or the unzipped content is empty.
DeviceResponseExceptionIf a device-specific error occurs during reading.
boost::system::system_errorIf socket communication with the device fails.

Reads and concatenates multipart file segments from the device.

This lambda attempts to reconstruct a file split into multiple parts named using the pattern <filename>.zip.partNNN, where NNN is a zero-padded index. If the input filename does not already end with .zip, the extension is appended automatically.

Reading stops when a part file is missing or empty. All successfully read parts are concatenated in order and returned as a single byte buffer.

Parameters
filenameThe base name of the file to read (with or without ".zip").
Returns
std::vector<uint8_t> Concatenated file contents, or empty if no parts were read.

◆ removeDeviceFileOrParts()

void mm::comm::base::removeDeviceFileOrParts ( Device device,
const std::string &  filename,
const std::chrono::steady_clock::duration  expiryTime = std::chrono::milliseconds(20000) 
)

Removes a file from the device, including handling multipart files if applicable.

This function attempts to remove the specified file from the device by:

  • Removing it directly if the filename is listed as non-parted.
  • Checking the device's file list and removing the file if found.
  • If the file is split into parts (named .zip.partXXX), removing all corresponding parts.

If no file or parts matching the filename are found, the function logs a warning and throws a std::runtime_error.

Parameters
deviceReference to the device from which the file will be removed.
filenameName of the file to remove.
expiryTimeMaximum duration to wait for each removal operation before timing out. Defaults to 20 seconds.

◆ SetObjectFlags()

ObjectFlags mm::comm::base::SetObjectFlags ( ObjectFlags  b,
ObjectFlags  s,
ObjectFlags  p,
ObjectFlags  a 
)
inline

Combine multiple ObjectFlags values into one.

This function is a convenience method that combines multiple ObjectFlags values by OR'ing them together.

Parameters
bFirst ObjectFlags value.
sSecond ObjectFlags value.
pThird ObjectFlags value.
aFourth ObjectFlags value.
Returns
The result of combining the four ObjectFlags values as a single ObjectFlags value.

◆ writeDeviceFileInOptionalParts()

void mm::comm::base::writeDeviceFileInOptionalParts ( Device device,
const std::string &  filename,
const std::vector< std::uint8_t > &  data,
std::function< void(uint8_t, std::string)>  progressCallback = nullptr,
const std::chrono::steady_clock::duration  expiryTime = std::chrono::milliseconds(30000) 
)

Write a file to a device, splitting it into parts if necessary.

This function writes a file to the given device, handling both small and large files.

  • Small files (≤ 9 KB) or files with special names are written directly.
  • Large files are compressed (if not already zipped) and split into parts due to device transfer limits, then each part is written separately.
  • In BOOT state, firmware files are renamed to predefined names to avoid filename length issues during flashing.

Progress can be tracked via an optional callback function receiving completion percentage (0–100).

Parameters
deviceReference to the device object to write to.
filenameName of the file to write.
dataRaw file data to write.
progressCallbackOptional callback function called with progress percentage after each part.
expiryTimeMaximum duration to wait for each transfer operation before timing out. Defaults to 30 seconds.
Exceptions
std::runtime_errorIf compression fails or any error occurs during file writing.

◆ writeFirmwarePackage()

void mm::comm::base::writeFirmwarePackage ( Device device,
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) 
)

Writes a firmware package to the given device.

Unzips the provided firmware package data and writes each file to the device, unless the file name matches an entry in the skip list. Supports parted writing and optional progress reporting.

Parameters
deviceThe target device to write the firmware files to.
dataThe firmware package as a vector of bytes (expected to be a zip archive).
skipFilesA list of file names to skip during the firmware update.
progressCallbackOptional callback to report progress (accepts a percentage [0–100]).
expiryTimeThe maximum duration to wait for the operation to complete. Defaults to 60000 milliseconds.
Exceptions
std::runtime_errorIf no files are found in the package or if writing a file fails.

Variable Documentation

◆ kDeviceFilePartSize

constexpr std::size_t mm::comm::base::kDeviceFilePartSize
inlineconstexpr
Initial value:
=
9000

Default part size (in bytes) for device file operations. Due to the 9 KB transfer limit imposed by the IgH EtherCAT master.

◆ kNonPartedFileNames

std::set< std::string > mm::comm::base::kNonPartedFileNames
Initial value:
= {
".assembly_config", ".factory_config", "config.csv",
"fs-buffer", "fs-getlist", "fs-remove",
"logging_curr.log", "logging_prev.log", "plant_model.csv",
"ui.config.json", ".variant"}

Set of filenames that are always stored as complete files and can be read directly.

This constant defines a collection of specific filenames that are known to be stored on the device as whole, unsplit files. These files do not require multipart handling or decompression and are accessed via a direct call to device.readFile().

Note
This set is used in functions like readCompleteDeviceFile() to bypass multipart reading and related processing logic.