fix previous commit, formatting
This commit is contained in:
@@ -208,7 +208,7 @@ MainLoop::~MainLoop() {
|
|||||||
void MainLoop::shutdown() {
|
void MainLoop::shutdown() {
|
||||||
m_shutdown = true;
|
m_shutdown = true;
|
||||||
if (m_requestQueue != nullptr) {
|
if (m_requestQueue != nullptr) {
|
||||||
m_requestQueue->push(nullptr); // just to notify potentially waiting thread
|
m_requestQueue->push(nullptr); // just to notify potentially waiting thread
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +314,8 @@ void MainLoop::run() {
|
|||||||
if (scanCompleted > SCAN_REPEAT_COUNT) { // repeat failed scan only every Nth time
|
if (scanCompleted > SCAN_REPEAT_COUNT) { // repeat failed scan only every Nth time
|
||||||
scanCompleted = 0;
|
scanCompleted = 0;
|
||||||
scanRetry++;
|
scanRetry++;
|
||||||
logNotice(lf_main, "scan completed %d time(s), %s", scanRetry, scanRetry <= m_scanRetries ? "check again" : "end");
|
logNotice(lf_main, "scan completed %d time(s), %s", scanRetry,
|
||||||
|
scanRetry <= m_scanRetries ? "check again" : "end");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_scanStatus = SCAN_STATUS_RUNNING;
|
m_scanStatus = SCAN_STATUS_RUNNING;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/src \
|
|||||||
noinst_LIBRARIES = libutils.a
|
noinst_LIBRARIES = libutils.a
|
||||||
|
|
||||||
libutils_a_SOURCES = \
|
libutils_a_SOURCES = \
|
||||||
|
arg.h arg.cpp \
|
||||||
log.h log.cpp \
|
log.h log.cpp \
|
||||||
tcpsocket.h tcpsocket.cpp \
|
tcpsocket.h tcpsocket.cpp \
|
||||||
thread.h thread.cpp \
|
thread.h thread.cpp \
|
||||||
|
|||||||
+11
-7
@@ -48,7 +48,8 @@ void calcCounts(const argDef *argDefs, int &count, int &shortCharsCount, int &sh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildOpts(const argDef *argDefs, int &count, int &shortCharsCount, int &shortOptsCount, struct option *longOpts, char *shortChars, int *shortIndexes, char *shortOpts, int argDefIdx) {
|
void buildOpts(const argDef *argDefs, int &count, int &shortCharsCount, int &shortOptsCount,
|
||||||
|
struct option *longOpts, char *shortChars, int *shortIndexes, char *shortOpts, int argDefIdx) {
|
||||||
struct option *opt = longOpts+count;
|
struct option *opt = longOpts+count;
|
||||||
for (const argDef *arg = argDefs; arg && arg->help; arg++, argDefIdx++) {
|
for (const argDef *arg = argDefs; arg && arg->help; arg++, argDefIdx++) {
|
||||||
if (!arg->name) {
|
if (!arg->name) {
|
||||||
@@ -108,15 +109,19 @@ int argParse(const argParseOpt *parseOpt, int argc, char **argv, int *argIndex)
|
|||||||
shortOpts[shortOptsCount++] = '+'; // posix mode to stop at first non-option
|
shortOpts[shortOptsCount++] = '+'; // posix mode to stop at first non-option
|
||||||
shortOpts[shortOptsCount++] = ':'; // return ':' for missing option
|
shortOpts[shortOptsCount++] = ':'; // return ':' for missing option
|
||||||
if (!(parseOpt->flags & af_noHelp)) {
|
if (!(parseOpt->flags & af_noHelp)) {
|
||||||
buildOpts(helpArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0xff00);
|
buildOpts(helpArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0xff00);
|
||||||
}
|
}
|
||||||
if (!(parseOpt->flags & af_noVersion)) {
|
if (!(parseOpt->flags & af_noVersion)) {
|
||||||
buildOpts(versionArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0xff01);
|
buildOpts(versionArgDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0xff01);
|
||||||
}
|
}
|
||||||
buildOpts(parseOpt->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0);
|
buildOpts(parseOpt->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0);
|
||||||
int children = 0;
|
int children = 0;
|
||||||
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
||||||
buildOpts(child->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars, shortIndexes, shortOpts, 0x100*(++children));
|
buildOpts(child->argDefs, count, shortCharsCount, shortOptsCount, longOpts, shortChars,
|
||||||
|
shortIndexes, shortOpts, 0x100*(++children));
|
||||||
}
|
}
|
||||||
optind = 1; // setting to 0 does not work
|
optind = 1; // setting to 0 does not work
|
||||||
int c = 0, longIdx = -1, ret = 0;
|
int c = 0, longIdx = -1, ret = 0;
|
||||||
@@ -320,8 +325,7 @@ void argHelp(const argParseOpt *parseOpt) {
|
|||||||
}
|
}
|
||||||
printf("Usage: %s [OPTION...] %s\n",
|
printf("Usage: %s [OPTION...] %s\n",
|
||||||
parseOpt->name,
|
parseOpt->name,
|
||||||
parseOpt->positional ? parseOpt->positional : ""
|
parseOpt->positional ? parseOpt->positional : "");
|
||||||
);
|
|
||||||
wrap(parseOpt->help, 0, 0);
|
wrap(parseOpt->help, 0, 0);
|
||||||
printArgs(parseOpt->argDefs, indent);
|
printArgs(parseOpt->argDefs, indent);
|
||||||
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
for (const argParseChildOpt *child = parseOpt->childOpts; child && child->argDefs; child++) {
|
||||||
|
|||||||
+3
-3
@@ -16,8 +16,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIB_UTILS_ARGS_H_
|
#ifndef LIB_UTILS_ARG_H_
|
||||||
#define LIB_UTILS_ARGS_H_
|
#define LIB_UTILS_ARG_H_
|
||||||
|
|
||||||
namespace ebusd {
|
namespace ebusd {
|
||||||
|
|
||||||
@@ -94,4 +94,4 @@ void argHelp(const argParseOpt *parseOpt);
|
|||||||
|
|
||||||
} // namespace ebusd
|
} // namespace ebusd
|
||||||
|
|
||||||
#endif // LIB_UTILS_ARGS_H_
|
#endif // LIB_UTILS_ARG_H_
|
||||||
|
|||||||
@@ -1053,7 +1053,7 @@ int readSettings(int fd, uint8_t* currentData = nullptr) {
|
|||||||
// non-mask bits outside of |gw reach
|
// non-mask bits outside of |gw reach
|
||||||
uint8_t mask = maskLen <= 24 ? 0 : (255^((1 << (8 - (maskLen-24))) - 1));
|
uint8_t mask = maskLen <= 24 ? 0 : (255^((1 << (8 - (maskLen-24))) - 1));
|
||||||
ip[3] |= ((~mask)^0x1f) | (gw&0x1f);
|
ip[3] |= ((~mask)^0x1f) | (gw&0x1f);
|
||||||
if (maskLen<24) {
|
if (maskLen < 24) {
|
||||||
// more than just the last IP byte are affected: set non-mask bits to 1 as well in bytes 0-2
|
// more than just the last IP byte are affected: set non-mask bits to 1 as well in bytes 0-2
|
||||||
for (uint8_t pos = 0, maskRemain = maskLen; pos < 3; pos++, maskRemain -= maskRemain >= 8 ? 8 : maskRemain) {
|
for (uint8_t pos = 0, maskRemain = maskLen; pos < 3; pos++, maskRemain -= maskRemain >= 8 ? 8 : maskRemain) {
|
||||||
mask = maskRemain >= 8 ? 255 : maskRemain == 0 ? 0 : (255^((1 << (8 - maskRemain)) - 1));
|
mask = maskRemain >= 8 ? 255 : maskRemain == 0 ? 0 : (255^((1 << (8 - maskRemain)) - 1));
|
||||||
@@ -1107,7 +1107,7 @@ int readSettings(int fd, uint8_t* currentData = nullptr) {
|
|||||||
} else {
|
} else {
|
||||||
std::cout << ", ignore hardware jumpers";
|
std::cout << ", ignore hardware jumpers";
|
||||||
}
|
}
|
||||||
if ((configData[5]&0x07)==0x07) {
|
if ((configData[5]&0x07) == 0x07) {
|
||||||
std::cout << " (default)";
|
std::cout << " (default)";
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
@@ -1144,7 +1144,7 @@ bool writeSettings(int fd, uint8_t* currentData = nullptr) {
|
|||||||
}
|
}
|
||||||
if (setVariant) {
|
if (setVariant) {
|
||||||
configData[5] = (configData[5]&0x38) | (setVariantForced?0:0x04) | (setVariantValue&0x03);
|
configData[5] = (configData[5]&0x38) | (setVariantForced?0:0x04) | (setVariantValue&0x03);
|
||||||
if (setVariantValue==0) {
|
if (setVariantValue == 0) {
|
||||||
configData[1] = (configData[1]&~0x1f); // set mask=0 to disable Ethernet
|
configData[1] = (configData[1]&~0x1f); // set mask=0 to disable Ethernet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1191,7 +1191,7 @@ int main(int argc, char* argv[]) {
|
|||||||
std::cerr << "incomplete IP arguments" << std::endl;
|
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 (arg_index < 0 || argc-arg_index < 1) {
|
||||||
if (flashFile) {
|
if (flashFile) {
|
||||||
printFileChecksum();
|
printFileChecksum();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|||||||
Reference in New Issue
Block a user