initial docker support on x86
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#include <mutex>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/time.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "main.h"
|
||||
#include "tools.h"
|
||||
|
||||
std::mutex log_mutex;
|
||||
|
||||
void lprintf(const char *format, ...)
|
||||
{
|
||||
// Only print if debug flag is set, else do nothing
|
||||
if (debugFlag) {
|
||||
va_list ap;
|
||||
char fmt[2048];
|
||||
|
||||
//actual time
|
||||
time_t rawtime;
|
||||
struct tm *timeinfo;
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
char buf[256];
|
||||
strcpy(buf, asctime(timeinfo));
|
||||
buf[strlen(buf)-1] = 0;
|
||||
|
||||
//connect with args
|
||||
snprintf(fmt, sizeof(fmt), "%s %s\n", buf, format);
|
||||
|
||||
//put on screen:
|
||||
va_start(ap, format);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
//to the logfile:
|
||||
static FILE *log;
|
||||
log_mutex.lock();
|
||||
log = fopen(LOG_FILE, "a");
|
||||
va_start(ap, format);
|
||||
vfprintf(log, fmt, ap);
|
||||
va_end(ap);
|
||||
fclose(log);
|
||||
log_mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int print_help()
|
||||
{
|
||||
printf("USAGE: skymax [-r <raw command>] | [-h | --help]\n\n");
|
||||
printf("RAW COMMAND EXAMPLES (see protocol manual for complete list):\n");
|
||||
printf("Set output source priority POP00 (Utility first)\n");
|
||||
printf(" POP01 (Solar first)\n");
|
||||
printf(" POP02 (SBU)\n");
|
||||
printf("Set charger priority PCP00 (Utility first)\n");
|
||||
printf(" PCP01 (Solar first)\n");
|
||||
printf(" PCP02 (Solar and utility)\n");
|
||||
printf(" PCP03 (Solar only)\n");
|
||||
printf("Set other commands PEa / PDa (Enable/disable buzzer)\n");
|
||||
printf(" PEb / PDb (Enable/disable overload bypass)\n");
|
||||
printf(" PEj / PDj (Enable/disable power saving)\n");
|
||||
printf(" PEu / PDu (Enable/disable overload restart)\n");
|
||||
printf(" PEx / PDx (Enable/disable backlight)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user