fp@1122: /***************************************************************************** fp@1122: * fp@1122: * $Id$ fp@1122: * fp@1122: ****************************************************************************/ fp@1122: fp@1122: #include fp@1122: fp@1122: #include fp@1122: #include fp@1122: #include fp@1122: using namespace std; fp@1122: fp@1122: #include "MasterDevice.h" fp@1122: fp@1122: /*****************************************************************************/ fp@1122: fp@1122: enum Verbosity { fp@1122: Quiet, fp@1122: Normal, fp@1122: Verbose fp@1122: }; fp@1122: fp@1125: extern string commandName; fp@1126: extern unsigned int masterIndex; fp@1122: extern int slavePosition; fp@1122: extern int domainIndex; fp@1122: extern vector commandArgs; fp@1122: extern Verbosity verbosity; fp@1122: extern string dataTypeStr; fp@1122: extern bool force; fp@1122: fp@1122: extern MasterDevice masterDev; fp@1122: fp@1122: /****************************************************************************/ fp@1122: fp@1122: class InvalidUsageException: fp@1122: public runtime_error fp@1122: { fp@1122: public: fp@1122: /** Constructor with std::string parameter. */ fp@1122: InvalidUsageException( fp@1122: const stringstream &s /**< Message. */ fp@1122: ): runtime_error(s.str()) {} fp@1122: }; fp@1122: fp@1122: /****************************************************************************/ fp@1122: fp@1136: class CommandException: fp@1122: public runtime_error fp@1122: { fp@1122: public: fp@1122: /** Constructor with std::string parameter. */ fp@1136: CommandException( fp@1122: const stringstream &s /**< Message. */ fp@1122: ): runtime_error(s.str()) {} fp@1122: }; fp@1122: fp@1122: /*****************************************************************************/ fp@1122: fp@1122: #define swap16(x) \ fp@1122: ((uint16_t)( \ fp@1122: (((uint16_t)(x) & 0x00ffU) << 8) | \ fp@1122: (((uint16_t)(x) & 0xff00U) >> 8) )) fp@1122: #define swap32(x) \ fp@1122: ((uint32_t)( \ fp@1122: (((uint32_t)(x) & 0x000000ffUL) << 24) | \ fp@1122: (((uint32_t)(x) & 0x0000ff00UL) << 8) | \ fp@1122: (((uint32_t)(x) & 0x00ff0000UL) >> 8) | \ fp@1122: (((uint32_t)(x) & 0xff000000UL) >> 24) )) fp@1122: fp@1122: #if __BYTE_ORDER == __LITTLE_ENDIAN fp@1122: fp@1122: #define le16tocpu(x) x fp@1122: #define le32tocpu(x) x fp@1122: fp@1122: #define cputole16(x) x fp@1122: #define cputole32(x) x fp@1122: fp@1122: #elif __BYTE_ORDER == __BIG_ENDIAN fp@1122: fp@1122: #define le16tocpu(x) swap16(x) fp@1122: #define le32tocpu(x) swap32(x) fp@1122: fp@1122: #define cputole16(x) swap16(x) fp@1122: #define cputole32(x) swap32(x) fp@1122: fp@1122: #endif fp@1122: fp@1122: /****************************************************************************/ fp@1126: fp@1126: enum {BreakAfterBytes = 16}; fp@1126: enum {DefaultBufferSize = 1024}; fp@1126: fp@1126: void printRawData(const uint8_t *, unsigned int); fp@1126: fp@1126: /****************************************************************************/