From 5c07889801c34811560c3d5c8590121d1d48f6bf Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 10 Jan 2021 15:36:02 +0100 Subject: [PATCH] formatting --- src/ebusd/mqtthandler.cpp | 40 +++++----- src/lib/ebus/device.cpp | 6 +- src/lib/ebus/device.h | 25 +++--- src/tools/ebuspicloader.cpp | 148 +++++++++++++++++++----------------- 4 files changed, 115 insertions(+), 104 deletions(-) diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index 194dbd2b..e8f4eb24 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -49,36 +49,36 @@ using std::dec; /** the definition of the MQTT arguments. */ static const struct argp_option g_mqtt_argp_options[] = { - {nullptr, 0, nullptr, 0, "MQTT options:", 1 }, - {"mqtthost", O_HOST, "HOST", 0, "Connect to MQTT broker on HOST [localhost]", 0 }, - {"mqttport", O_PORT, "PORT", 0, "Connect to MQTT broker on PORT (usually 1883), 0 to disable [0]", 0 }, + {nullptr, 0, nullptr, 0, "MQTT options:", 1 }, + {"mqtthost", O_HOST, "HOST", 0, "Connect to MQTT broker on HOST [localhost]", 0 }, + {"mqttport", O_PORT, "PORT", 0, "Connect to MQTT broker on PORT (usually 1883), 0 to disable [0]", 0 }, {"mqttclientid", O_CLID, "ID", 0, "Set client ID for connection to MQTT broker [" PACKAGE_NAME "_" PACKAGE_VERSION "_]", 0 }, - {"mqttuser", O_USER, "USER", 0, "Connect as USER to MQTT broker (no default)", 0 }, - {"mqttpass", O_PASS, "PASSWORD", 0, "Use PASSWORD when connecting to MQTT broker (no default)", 0 }, - {"mqtttopic", O_TOPI, "TOPIC", 0, + {"mqttuser", O_USER, "USER", 0, "Connect as USER to MQTT broker (no default)", 0 }, + {"mqttpass", O_PASS, "PASSWORD", 0, "Use PASSWORD when connecting to MQTT broker (no default)", 0 }, + {"mqtttopic", O_TOPI, "TOPIC", 0, "Use MQTT TOPIC (prefix before /%circuit/%name or complete format) [ebusd]", 0 }, - {"mqttretain", O_RETA, nullptr, 0, "Retain all topics instead of only selected global ones", 0 }, - {"mqttjson", O_JSON, nullptr, 0, "Publish in JSON format instead of strings", 0 }, + {"mqttretain", O_RETA, nullptr, 0, "Retain all topics instead of only selected global ones", 0 }, + {"mqttjson", O_JSON, nullptr, 0, "Publish in JSON format instead of strings", 0 }, #if (LIBMOSQUITTO_VERSION_NUMBER >= 1003001) - {"mqttlog", O_LOGL, nullptr, 0, "Log library events", 0 }, + {"mqttlog", O_LOGL, nullptr, 0, "Log library events", 0 }, #endif #if (LIBMOSQUITTO_VERSION_NUMBER >= 1004001) - {"mqttversion", O_VERS, "VERSION", 0, "Use protocol VERSION [3.1]", 0 }, + {"mqttversion", O_VERS, "VERSION", 0, "Use protocol VERSION [3.1]", 0 }, #endif {"mqttignoreinvalid", O_IGIN, nullptr, 0, "Ignore invalid parameters during init (e.g. for DNS not resolvable yet)", 0 }, - {"mqttchanges", O_CHGS, nullptr, 0, "Whether to only publish changed messages instead of all received", 0 }, + {"mqttchanges", O_CHGS, nullptr, 0, "Whether to only publish changed messages instead of all received", 0 }, #if (LIBMOSQUITTO_MAJOR >= 1) - {"mqttca", O_CAFI, "CA", 0, "Use CA file or dir (ending with '/') for MQTT TLS (no default)", 0 }, - {"mqttcert", O_CERT, "CERTFILE", 0, "Use CERTFILE for MQTT TLS client certificate (no default)", 0 }, - {"mqttkey", O_KEYF, "KEYFILE", 0, "Use KEYFILE for MQTT TLS client certificate (no default)", 0 }, - {"mqttkeypass", O_KEPA, "PASSWORD", 0, "Use PASSWORD for the encrypted KEYFILE (no default)", 0 }, - {"mqttinsecure",O_INSE, nullptr, 0, "Allow insecure TLS connection (e.g. using a self signed certificate)", 0 }, + {"mqttca", O_CAFI, "CA", 0, "Use CA file or dir (ending with '/') for MQTT TLS (no default)", 0 }, + {"mqttcert", O_CERT, "CERTFILE", 0, "Use CERTFILE for MQTT TLS client certificate (no default)", 0 }, + {"mqttkey", O_KEYF, "KEYFILE", 0, "Use KEYFILE for MQTT TLS client certificate (no default)", 0 }, + {"mqttkeypass", O_KEPA, "PASSWORD", 0, "Use PASSWORD for the encrypted KEYFILE (no default)", 0 }, + {"mqttinsecure", O_INSE, nullptr, 0, "Allow insecure TLS connection (e.g. using a self signed certificate)", 0 }, #endif - {nullptr, 0, nullptr, 0, nullptr, 0 }, + {nullptr, 0, nullptr, 0, nullptr, 0 }, }; static const char* g_host = "localhost"; //!< host name of MQTT broker [localhost] @@ -251,7 +251,7 @@ static error_t mqtt_parse_opt(int key, char *arg, struct argp_state *state) { } g_keypass = replaceSecret(arg); break; - case O_INSE: //--mqttinsecure + case O_INSE: // --mqttinsecure g_insecure = true; break; #endif @@ -647,11 +647,11 @@ void MqttHandler::notifyTopic(const string& topic, const string& data) { if (isList) { logOtherInfo("mqtt", "received list topic for %s %s", circuit.c_str(), name.c_str()); deque messages; - bool circuitPrefix = circuit.length()>0 && circuit.find_last_of('*') == circuit.length()-1; + bool circuitPrefix = circuit.length() > 0 && circuit.find_last_of('*') == circuit.length()-1; if (circuitPrefix) { circuit = circuit.substr(0, circuit.length()-1); } - bool namePrefix = name.length()>0 && name.find_last_of('*') == name.length()-1; + bool namePrefix = name.length() > 0 && name.find_last_of('*') == name.length()-1; if (namePrefix) { name = name.substr(0, name.length()-1); } diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index b7925586..3c467fda 100755 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -692,11 +692,11 @@ result_t NetworkDevice::open() { ret = setsockopt(m_fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&value), sizeof(value)); value = 1; setsockopt(m_fd, SOL_SOCKET, SO_KEEPALIVE, reinterpret_cast(&value), sizeof(value)); - value = 3; // send keepalive after 3 seconds of silence + value = 3; // send keepalive after 3 seconds of silence setsockopt(m_fd, IPPROTO_TCP, TCP_KEEPIDLE, reinterpret_cast(&value), sizeof(value)); - value = 2; // send keepalive in interval of 2 seconds + value = 2; // send keepalive in interval of 2 seconds setsockopt(m_fd, IPPROTO_TCP, TCP_KEEPINTVL, reinterpret_cast(&value), sizeof(value)); - value = 2; // drop connection after 2 failed keep alive sends + value = 2; // drop connection after 2 failed keep alive sends setsockopt(m_fd, IPPROTO_TCP, TCP_KEEPCNT, reinterpret_cast(&value), sizeof(value)); } if (ret >= 0) { diff --git a/src/lib/ebus/device.h b/src/lib/ebus/device.h index 05d23037..fb01a9f4 100755 --- a/src/lib/ebus/device.h +++ b/src/lib/ebus/device.h @@ -52,12 +52,12 @@ namespace ebusd { /** the arbitration state handled by @a Device. */ enum ArbitrationState { - as_none, //!< no arbitration in process - as_start, //!< arbitration start requested - as_error, //!< error while sending master address - as_running, //!< arbitration currently running (master address sent, waiting for reception) - as_lost, //!< arbitration lost - as_won, //!< arbitration won + as_none, //!< no arbitration in process + as_start, //!< arbitration start requested + as_error, //!< error while sending master address + as_running, //!< arbitration currently running (master address sent, waiting for reception) + as_lost, //!< arbitration lost + as_won, //!< arbitration won }; /** @@ -101,7 +101,7 @@ class Device { * @param enhancedProto whether to use the ebusd enhanced protocol. */ Device(const char* name, bool checkDevice, unsigned int latency, bool readOnly, bool initialSend, - bool enhancedProto=false); + bool enhancedProto = false); public: /** @@ -174,7 +174,7 @@ class Device { * Return whether the device is currently in arbitration. * @return true when the device is currently in arbitration. */ - bool isArbitrating() const { return m_arbitrationMaster != SYN; }; + bool isArbitrating() const { return m_arbitrationMaster != SYN; } /** * Return the device name. @@ -220,7 +220,7 @@ class Device { * @param startArbitration true to start arbitration. * @return true on success, false on error. */ - virtual bool write(symbol_t value, bool startArbitration=false); + virtual bool write(symbol_t value, bool startArbitration = false); /** * Check whether a symbol is available for reading immediately (without waiting). @@ -236,7 +236,8 @@ class Device { * @param incomplete the variable in which to store when a partial transfer needs another poll. * @return true on success, false on error. */ - virtual bool read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrationState=nullptr, bool* incomplete=nullptr); + virtual bool read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrationState = nullptr, + bool* incomplete = nullptr); /** the device name (e.g. "/dev/ttyUSB0" for serial, "127.0.0.1:1234" for network). */ const char* m_name; @@ -299,7 +300,7 @@ class SerialDevice : public Device { * @param enhancedProto whether to use the ebusd enhanced protocol. */ SerialDevice(const char* name, bool checkDevice, unsigned int extraLatency, bool readOnly, bool initialSend, - bool enhancedProto=false) + bool enhancedProto = false) : Device(name, checkDevice, extraLatency, readOnly, initialSend, enhancedProto) {} // @copydoc @@ -337,7 +338,7 @@ class NetworkDevice : public Device { * @param enhancedProto whether to use the ebusd enhanced protocol. */ NetworkDevice(const char* name, const char* hostOrIp, uint16_t port, unsigned int extraLatency, bool readOnly, - bool initialSend, bool udp, bool enhancedProto=false) + bool initialSend, bool udp, bool enhancedProto = false) : Device(name, true, NETWORK_LATENCY_MS+extraLatency, readOnly, initialSend, enhancedProto), m_hostOrIp(hostOrIp), m_port(port), m_udp(udp) {} diff --git a/src/tools/ebuspicloader.cpp b/src/tools/ebuspicloader.cpp index 76d0a4c2..2ae50f08 100644 --- a/src/tools/ebuspicloader.cpp +++ b/src/tools/ebuspicloader.cpp @@ -258,15 +258,15 @@ ssize_t waitWrite(int fd, uint8_t *data, size_t len, int timeoutMillis) { return ret; } ret = write(fd, data, len); - if (ret<0) { + if (ret < 0) { return ret; } #ifdef DEBUG_RAW - std::cout<<"> "<(ret)<<"/"<(len)<<":"<(data[pos]); + std::cout << "> " << std::dec << static_cast(ret) << "/" << static_cast(len) << ":" << std::hex; + for (int pos = 0; pos < ret; pos++) { + std::cout << " " << std::setw(2) << std::setfill('0') << static_cast(data[pos]); } - std::cout<(ret)<<"/"<(len)<<":"<(data[pos]); + std::cout << "< " << std::dec << static_cast(ret) << "/" << static_cast(len) << ":" << std::hex; + for (int pos = 0; pos < ret; pos++) { + std::cout << " " << std::setw(2) << std::setfill('0') << static_cast(data[pos]); } - std::cout<(frame.data[2] | (frame.data[3] << 8)) << std::endl; } - std::cout << "Device ID: " << std::setfill('0') << std::setw(4) << std::hex << static_cast(frame.data[6] | (frame.data[7] << 8)); + std::cout << "Device ID: " << std::setfill('0') << std::setw(4) << std::hex + << static_cast(frame.data[6] | (frame.data[7] << 8)); if (frame.data[6] == 0xb0 && frame.data[7] == 0x30) { std::cout << " (PIC16F15356)"; } @@ -414,10 +415,14 @@ int readVersion(int fd, bool verbose=true) { if (verbose) { std::cout << "Blocksize erase: " << std::dec << static_cast(frame.data[10]) << std::endl; std::cout << "Blocksize write: " << std::dec << static_cast(frame.data[11]) << std::endl; - std::cout << "User ID 1: " << std::setfill('0') << std::setw(2) << std::hex << static_cast(frame.data[12]) << std::endl; - std::cout << "User ID 2: " << std::setfill('0') << std::setw(2) << std::hex << static_cast(frame.data[13]) << std::endl; - std::cout << "User ID 3: " << std::setfill('0') << std::setw(2) << std::hex << static_cast(frame.data[14]) << std::endl; - std::cout << "User ID 4: " << std::setfill('0') << std::setw(2) << std::hex << static_cast(frame.data[15]) << std::endl; + std::cout << "User ID 1: " << std::setfill('0') << std::setw(2) << std::hex + << static_cast(frame.data[12]) << std::endl; + std::cout << "User ID 2: " << std::setfill('0') << std::setw(2) << std::hex + << static_cast(frame.data[13]) << std::endl; + std::cout << "User ID 3: " << std::setfill('0') << std::setw(2) << std::hex + << static_cast(frame.data[14]) << std::endl; + std::cout << "User ID 4: " << std::setfill('0') << std::setw(2) << std::hex + << static_cast(frame.data[15]) << std::endl; } return 0; } @@ -426,14 +431,14 @@ int printFrameData(frame_t frame, bool skipHigh) { uint16_t address = (frame.address_H << 8)|frame.address_L; int pos; std::cout << std::hex; - for (pos = 0; pos(address) << ":"; } std::cout << " " << std::setw(2) << static_cast(frame.data[pos++]); if (skipHigh) { pos++; - } else if (pos(frame.data[pos++]); } address++; @@ -448,10 +453,12 @@ int printFrameData(frame_t frame, bool skipHigh) { } int printFrame(frame_t frame) { - std::cout << "command: 0x" << std::setfill('0') << std::setw(2) << std::hex << static_cast(frame.command) << std::endl; + std::cout << "command: 0x" << std::setfill('0') << std::setw(2) << std::hex + << static_cast(frame.command) << std::endl; std::cout << "data_length: " << std::dec << static_cast(frame.data_length) << std::endl; - std::cout << "address: 0x" << std::setw(2) << std::hex << static_cast(frame.address_H) << std::setw(2) << std::hex << static_cast(frame.address_L); - for (int pos = 0; pos(frame.address_H) << std::setw(2) + << std::hex << static_cast(frame.address_L); + for (int pos = 0; pos < frame.data_length; ) { if ((pos%16) == 0) { std::cout << std::endl << std::setw(4) << static_cast(pos) << ":" << std::endl; } @@ -462,7 +469,8 @@ int printFrame(frame_t frame) { return 0; } -int readConfig(int fd, uint16_t address, uint16_t len, bool skipHigh=false, bool print=true, uint8_t* storeData=nullptr) { +int readConfig(int fd, uint16_t address, uint16_t len, bool skipHigh = false, bool print = true, + uint8_t* storeData = nullptr) { frame_t frame; memset(frame.buffer, 0, FRAME_MAX_LEN); frame.command = READ_CONFIG; @@ -502,7 +510,7 @@ int writeConfig(int fd, uint16_t address, uint16_t len, uint8_t* data) { return 0; } -int readFlash(int fd, uint16_t address, bool skipHigh=false, bool print=true, uint8_t* storeData=nullptr) { +int readFlash(int fd, uint16_t address, bool skipHigh = false, bool print = true, uint8_t* storeData = nullptr) { frame_t frame; memset(frame.buffer, 0, FRAME_MAX_LEN); frame.command = READ_FLASH; @@ -522,7 +530,7 @@ int readFlash(int fd, uint16_t address, bool skipHigh=false, bool print=true, ui return 0; } -int writeFlash(int fd, uint16_t address, uint16_t len, uint8_t* data, bool hideErrors=false) { +int writeFlash(int fd, uint16_t address, uint16_t len, uint8_t* data, bool hideErrors = false) { frame_t frame; memset(frame.buffer, 0, FRAME_MAX_LEN); frame.command = WRITE_FLASH; @@ -593,7 +601,7 @@ struct termios termios_original; int openSerial(std::string port) { // open serial port - int fd = open(port.c_str(), O_RDWR | O_NOCTTY | O_NDELAY); // non-blocking IO: | O_NONBLOCK); + int fd = open(port.c_str(), O_RDWR | O_NOCTTY | O_NDELAY); // non-blocking IO: | O_NONBLOCK); if (fd == -1) { std::cerr << "unable to open " << port << std::endl; return -1; @@ -617,7 +625,7 @@ int openSerial(std::string port) { close(fd); return -1; } - termios.c_iflag |= 0;//IGNPAR;//IGNBRK|IGNPAR|IGNCR; + termios.c_iflag |= 0; termios.c_oflag |= 0; termios.c_cflag |= CS8 | CREAD | CLOCAL; termios.c_lflag |= 0; @@ -636,7 +644,7 @@ void closeSerial(int fd) { close(fd); } -int calcFileChecksum(uint8_t* storeFirstBlock=nullptr) { +int calcFileChecksum(uint8_t* storeFirstBlock = nullptr) { std::ifstream inStream; inStream.open(flashFile, ifstream::in); if (!inStream.good()) { @@ -645,7 +653,7 @@ int calcFileChecksum(uint8_t* storeFirstBlock=nullptr) { } intelhex ih; inStream >> ih; - if (ih.getNoErrors()>0 || ih.getNoWarnings()>0) { + if (ih.getNoErrors() > 0 || ih.getNoWarnings() > 0) { std::cerr << "unable to read file" << std::endl; return -1; } @@ -654,7 +662,7 @@ int calcFileChecksum(uint8_t* storeFirstBlock=nullptr) { std::cerr << "unable to read file" << std::endl; return -1; } - if (startAddr=END_FLASH_BYTES || endAddr= END_FLASH_BYTES || endAddr < startAddr || (startAddr&0xf) != 0) { std::cerr << "invalid address range" << std::endl; return -1; } @@ -666,14 +674,14 @@ int calcFileChecksum(uint8_t* storeFirstBlock=nullptr) { } unsigned long blockStart = END_BOOT_BYTES; uint16_t checkSum = 0; - while (blockStart> ih; - if (ih.getNoErrors()>0 || ih.getNoWarnings()>0) { + if (ih.getNoErrors() > 0 || ih.getNoWarnings() > 0) { std::cerr << "errors or warnings while reading the file:" << std::endl; string str; while (ih.popNextWarning(str)) { @@ -730,7 +738,7 @@ bool flashPic(int fd) { << std::hex << std::setfill('0') << std::setw(4) << static_cast(endAddr) << std::endl; } - if (startAddr=END_FLASH_BYTES || endAddr= END_FLASH_BYTES || endAddr < startAddr || (startAddr&0xf) != 0) { std::cerr << "invalid address range" << std::endl; return false; } @@ -738,7 +746,8 @@ bool flashPic(int fd) { uint8_t buf[WRITE_FLASH_BLOCKSIZE]; unsigned long nextAddr = ih.currentAddress(); if (nextAddr != END_BOOT_BYTES) { - std::cerr << "unexpected start address in file: 0x" << std::hex << std::setfill('0') << std::setw(4) << static_cast(nextAddr) << std::endl; + std::cerr << "unexpected start address in file: 0x" << std::hex << std::setfill('0') << std::setw(4) + << static_cast(nextAddr) << std::endl; return false; } unsigned long blockStart = END_BOOT_BYTES; @@ -752,7 +761,7 @@ bool flashPic(int fd) { std::cout << "flashing: 0x" << std::hex << std::setfill('0') << std::setw(4) << static_cast(nextAddr/2) << " - 0x" << static_cast(endAddr/2) << std::endl; size_t blocks = 0; - while (blockStart(blockStart/2) << " "; + std::cout << std::endl << "0x" << std::hex << std::setfill('0') << std::setw(4) + << static_cast(blockStart/2) << " "; } if (writeFlash(fd, blockStart/2, WRITE_FLASH_BLOCKSIZE, buf, true) != 0) { // repeat once silently: @@ -777,7 +787,7 @@ bool flashPic(int fd) { } } std::cout << "."; - if (++blocks>=64) { + if (++blocks >= 64) { blocks = 0; } std::cout.flush(); @@ -786,7 +796,7 @@ bool flashPic(int fd) { } std::cout << std::endl << "flashing finished." << std::endl; int picSum = calcChecksum(fd, startAddr/2, blockStart-startAddr); - if (picSum<0) { + if (picSum < 0) { std::cout << "unable to read checksum." << std::endl; return false; } @@ -799,30 +809,30 @@ bool flashPic(int fd) { } void readIpSettings(int fd) { - uint8_t mac[] = {0xae, 0xb0, 0x53, 0xef, 0xfe, 0xef}; // "Adapter-eBUS3" + (UserID or MUI) + uint8_t mac[] = {0xae, 0xb0, 0x53, 0xef, 0xfe, 0xef}; // "Adapter-eBUS3" + (UserID or MUI) uint8_t ip[4] = {0, 0, 0, 0}; bool useMUI = true; uint8_t maskLen = 0; uint8_t configData[8]; - readConfig(fd, 0x0000, 8, false, false, configData); // User ID - useMUI = (configData[1]&0x20) != 0; // if highest bit is set, then use MUI. if cleared, use User ID + readConfig(fd, 0x0000, 8, false, false, configData); // User ID + useMUI = (configData[1]&0x20) != 0; // if highest bit is set, then use MUI. if cleared, use User ID maskLen = configData[1]&0x1f; - for (int i=0; i<4; i++) { + for (int i=0; i < 4; i++) { ip[i] = configData[i*2]; - if (!useMUI && i>0) { + if (!useMUI && i > 0) { mac[2+i] = configData[i*2]; } } if (useMUI) { // read MUI to build uniqueMAC address // start with MUI6, end with MUI8 (MUI9 is reserved) - readConfig(fd, 0x0106, 8, true, false, configData); // MUI - for (int i=0; i<3; i++) { + readConfig(fd, 0x0106, 8, true, false, configData); // MUI + for (int i=0; i < 3; i++) { mac[3+i] = configData[i*2]; } } std::cout << "MAC address:"; - for (int i=0; i<6; i++) { + for (int i=0; i < 6; i++) { std::cout << (i == 0?' ':':') << std::hex << std::setw(2) << std::setfill('0') << static_cast(mac[i]); } std::cout << std::endl; @@ -830,20 +840,20 @@ void readIpSettings(int fd) { std::cout << "IP address: DHCP" << std::endl; } else { std::cout << "IP address:"; - for (int i=0; i<4; i++) { + for (int i=0; i < 4; i++) { std::cout << (i == 0?' ':'.') << std::dec << static_cast(ip[i]); } std::cout << "/" << std::dec << static_cast(maskLen) << std::endl; /* // build gateway - for (uint8_t pos=0; pos<4; pos++) { - mask[pos] = maskLen>=8 ? 255 : maskLen<=0 ? 0 : (255^((1 << (8-maskLen))-1)); + for (uint8_t pos=0; pos < 4; pos++) { + mask[pos] = maskLen >= 8 ? 255 : maskLen<=0 ? 0 : (255^((1 << (8-maskLen))-1)); ip[pos] &= mask[pos]; - maskLen = maskLen>=8 ? maskLen-8 : 0; + maskLen = maskLen >= 8 ? maskLen-8 : 0; } ip[3] |= 1; // first address in network is used as gateway (not needed anyway)) std::cout << "IP gateway:"; - for (int i=0; i<4; i++) { + for (int i=0; i < 4; i++) { std::cout << (i == 0?' ':'.') << std::dec << static_cast(ip[i]); } std::cout << std::endl; @@ -855,7 +865,7 @@ bool writeIpSettings(int fd) { std::cout << "Writing IP settings: "; uint8_t configData[] = {0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f}; if (setMacFromIp) { - configData[1] &= ~0x20; // set useMUI + configData[1] &= ~0x20; // set useMUI } configData[1] = (configData[1]&~0x1f) | (setMaskLen&0x1f); if (setIp) { @@ -883,9 +893,9 @@ int main(int argc, char* argv[]) { if (setIp != setMask || (setMacFromIp && !setIp)) { std::cerr << "incomplete IP arguments" << std::endl; - arg_index = argc; // force help output + arg_index = argc; // force help output } - if (argc-arg_index<1) { + if (argc-arg_index < 1) { if (flashFile) { printFileChecksum(); exit(EXIT_SUCCESS); @@ -896,7 +906,7 @@ int main(int argc, char* argv[]) { } int fd = openSerial(argv[arg_index]); - if (fd<0) { + if (fd < 0) { exit(EXIT_FAILURE); } @@ -908,19 +918,19 @@ int main(int argc, char* argv[]) { uint8_t data[0x10]; if (verbose) { std::cout << "User ID:" << std::endl; - readConfig(fd, 0x0000, 8); // User ID + readConfig(fd, 0x0000, 8); // User ID std::cout << "Rev ID, Device ID:" << std::endl; } - readConfig(fd, 0x0005, 4, false, verbose, data); // Rev ID and Device ID + readConfig(fd, 0x0005, 4, false, verbose, data); // Rev ID and Device ID std::cout << "Device revision: " << static_cast(((data[1]&0xf) << 2) | ((data[0]&0xc0)>>6)) << "." << static_cast(data[0]&0x3f) << std::endl; if (verbose) { std::cout << "Configuration words:" << std::endl; - readConfig(fd, 0x0007, 5*2); // Configuration Words + readConfig(fd, 0x0007, 5*2); // Configuration Words std::cout << "MUI:" << std::endl; - readConfig(fd, 0x0100, 9*2, true); // MUI + readConfig(fd, 0x0100, 9*2, true); // MUI std::cout << "EUI:"<< std::endl; - readConfig(fd, 0x010a, 8*2); // EUI + readConfig(fd, 0x010a, 8*2); // EUI } if (verbose) { std::cout << "Flash:" << std::endl;