forked from Ivasoft/DSView
add: log class lib
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "pv/config/appconfig.h"
|
||||
#include "config.h"
|
||||
#include "pv/appcontrol.h"
|
||||
#include "pv/log.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -51,6 +52,7 @@ void usage()
|
||||
"Help Options:\n"
|
||||
" -l, --loglevel Set libsigrok/libsigrokdecode loglevel\n"
|
||||
" -V, --version Show release version\n"
|
||||
" -lf, --savelog save log to locale file\n"
|
||||
" -h, -?, --help Show help option\n"
|
||||
"\n", DS_BIN_NAME, DS_DESCRIPTION);
|
||||
}
|
||||
@@ -123,8 +125,13 @@ bool bHighScale = true;
|
||||
QApplication::setOrganizationName("DreamSourceLab");
|
||||
QApplication::setOrganizationDomain("www.DreamSourceLab.com");
|
||||
|
||||
qDebug()<<"\n----------------- version:"<<DS_VERSION_STRING<<"-----------------\n";
|
||||
qDebug()<<"Qt:"<<QT_VERSION_STR;
|
||||
dsv_log_init();
|
||||
|
||||
xlog_print(dsv_log, 3, NULL, "----------------- version:%s-----------------", DS_VERSION_STRING);
|
||||
xlog_print(dsv_log, 3, NULL, "Qt:%s", QT_VERSION_STR);
|
||||
|
||||
//qDebug()<<"\n----------------- version:"<<DS_VERSION_STRING<<"-----------------\n";
|
||||
//qDebug()<<"Qt:"<<QT_VERSION_STR;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// Use low version qt plugins, for able to debug
|
||||
@@ -223,6 +230,7 @@ bool bHighScale = true;
|
||||
//uninit
|
||||
control->UnInit();
|
||||
control->Destroy();
|
||||
dsv_log_uninit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
41
DSView/pv/log.cpp
Normal file
41
DSView/pv/log.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
|
||||
xlog_writer *dsv_log = nullptr;
|
||||
xlog_context *log_ctx = nullptr;
|
||||
|
||||
void dsv_log_init()
|
||||
{
|
||||
if (log_ctx == nullptr){
|
||||
log_ctx = xlog_new();
|
||||
dsv_log = xlog_create_writer(log_ctx, "DSView");
|
||||
}
|
||||
}
|
||||
|
||||
void dsv_log_uninit()
|
||||
{
|
||||
xlog_free(log_ctx);
|
||||
xlog_free_writer(dsv_log);
|
||||
log_ctx = nullptr;
|
||||
dsv_log = nullptr;
|
||||
}
|
||||
33
DSView/pv/log.h
Normal file
33
DSView/pv/log.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _DSV_LOG_H_
|
||||
#define _DSV_LOG_H_
|
||||
|
||||
#include <common/log/xlog.h>
|
||||
|
||||
extern xlog_writer *dsv_log;
|
||||
|
||||
void dsv_log_init();
|
||||
|
||||
void dsv_log_uninit();
|
||||
|
||||
#endif
|
||||
433
common/log/xlog.c
Normal file
433
common/log/xlog.c
Normal file
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "xlog.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define RECEIVER_MAX_COUNT 10
|
||||
#define LOG_MAX_LENGTH 1000
|
||||
|
||||
enum xlog_receiver_type{
|
||||
RECEIVER_TYPE_CONSOLE = 0,
|
||||
RECEIVER_TYPE_FILE = 1,
|
||||
RECEIVER_TYPE_CALLBACK = 2,
|
||||
};
|
||||
|
||||
struct xlog_receiver_info;
|
||||
|
||||
typedef void (*xlog_print_func)(struct xlog_receiver_info *info, const char *domain, const char *prefix, const char *format, va_list args);
|
||||
|
||||
struct xlog_receiver_info
|
||||
{
|
||||
int _type; //see enum xlog_receiver_type
|
||||
FILE *_file;
|
||||
xlog_print_func _fn; // print function
|
||||
xlog_receiver _rev; //user callback
|
||||
};
|
||||
|
||||
struct xlog_context
|
||||
{
|
||||
struct xlog_receiver_info _receivers[RECEIVER_MAX_COUNT];
|
||||
int _log_level;
|
||||
char _error[50];
|
||||
int _count;
|
||||
};
|
||||
|
||||
struct xlog_writer{
|
||||
char _domain[20];
|
||||
xlog_context *_ctx;
|
||||
};
|
||||
|
||||
/**
|
||||
* the default mode process
|
||||
*/
|
||||
static void print_to_console(struct xlog_receiver_info *info, const char *domain, const char *prefix, const char *format, va_list args)
|
||||
{
|
||||
(void)info;
|
||||
|
||||
if (domain && *domain){
|
||||
fprintf(stderr, "%s", domain);
|
||||
fprintf(stderr, ": ");
|
||||
}
|
||||
if (prefix){
|
||||
fprintf(stderr, "%s", prefix);
|
||||
fprintf(stderr, ": ");
|
||||
}
|
||||
|
||||
vfprintf(stderr, format, args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* the file mode process
|
||||
*/
|
||||
static void print_to_file(struct xlog_receiver_info *info, const char *domain, const char *prefix, const char *format, va_list args)
|
||||
{
|
||||
char buf[LOG_MAX_LENGTH + 1];
|
||||
int fmtl;
|
||||
int wr=0;
|
||||
int strl;
|
||||
|
||||
if (info->_file == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
if (domain && *domain){
|
||||
strl = strlen(domain);
|
||||
strcpy(buf + wr, domain);
|
||||
wr += strl;
|
||||
strcpy(buf + wr, ": ");
|
||||
wr += 2;
|
||||
}
|
||||
if (prefix && *prefix){
|
||||
strl = strlen(prefix);
|
||||
strcpy(buf + wr, prefix);
|
||||
wr += strl;
|
||||
strcpy(buf + wr, ": ");
|
||||
wr += 2;
|
||||
}
|
||||
|
||||
fmtl = vsnprintf(buf + wr, LOG_MAX_LENGTH - wr - 1, format, args);
|
||||
wr += fmtl;
|
||||
*(buf + wr) = '\n';
|
||||
wr += 1;
|
||||
|
||||
fwrite(buf, wr, 1, info->_file);
|
||||
fflush(info->_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* the callback mode process
|
||||
*/
|
||||
static void print_to_user_callback(struct xlog_receiver_info *info, const char *domain, const char *prefix, const char *format, va_list args)
|
||||
{
|
||||
char buf[LOG_MAX_LENGTH + 1];
|
||||
int fmtl;
|
||||
int wr=0;
|
||||
int strl;
|
||||
|
||||
if (info->_rev == NULL){
|
||||
return;
|
||||
}
|
||||
|
||||
if (domain && *domain){
|
||||
strl = strlen(domain);
|
||||
strcpy(buf + wr, domain);
|
||||
wr += strl;
|
||||
strcpy(buf + wr, ": ");
|
||||
wr += 2;
|
||||
}
|
||||
if (prefix && *prefix){
|
||||
strl = strlen(prefix);
|
||||
strcpy(buf + wr, prefix);
|
||||
wr += strl;
|
||||
strcpy(buf + wr, ": ");
|
||||
wr += 2;
|
||||
}
|
||||
|
||||
fmtl = vsnprintf(buf + wr, LOG_MAX_LENGTH - wr - 1, format, args);
|
||||
wr += fmtl;
|
||||
*(buf + wr) = '\n';
|
||||
wr += 1;
|
||||
|
||||
info->_rev(buf, wr);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a log context, the console is default log receiver
|
||||
*/
|
||||
XLOG_API xlog_context* xlog_new()
|
||||
{
|
||||
int i=0;
|
||||
xlog_context *ctx = (xlog_context*)malloc(sizeof(xlog_context));
|
||||
if (ctx != NULL){
|
||||
for(i=0; i< RECEIVER_MAX_COUNT; i++){
|
||||
ctx->_receivers[i]._fn = NULL;
|
||||
ctx->_receivers[i]._file = NULL;
|
||||
}
|
||||
ctx->_receivers[0]._fn = print_to_console;
|
||||
ctx->_receivers[0]._type = RECEIVER_TYPE_CONSOLE;
|
||||
ctx->_log_level = XLOG_INFO;
|
||||
ctx->_count = 1;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* free a log context, return 0 if success.
|
||||
*/
|
||||
XLOG_API void xlog_free(xlog_context* ctx)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
if (ctx != NULL){
|
||||
for (i = 0; i < ctx->_count; i++)
|
||||
{
|
||||
if (ctx->_receivers[i]._file != NULL
|
||||
&& ctx->_receivers[i]._type == RECEIVER_TYPE_FILE)
|
||||
{
|
||||
fclose(ctx->_receivers[i]._file); // close the log file
|
||||
ctx->_receivers[i]._file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* append a log data receiver, return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_add_receiver(xlog_context* ctx, xlog_receiver rev, int *out_index)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ctx == NULL){
|
||||
return -1;
|
||||
}
|
||||
if (rev == NULL){
|
||||
strcpy(ctx->_error, "param @rev is null");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < RECEIVER_MAX_COUNT; i++){
|
||||
if (ctx->_receivers[i]._fn == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == RECEIVER_MAX_COUNT){
|
||||
strcpy(ctx->_error, "receiver count is full");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->_receivers[i]._type = RECEIVER_TYPE_CALLBACK;
|
||||
ctx->_receivers[i]._rev = rev;
|
||||
ctx->_receivers[i]._fn = print_to_user_callback;
|
||||
ctx->_count++;
|
||||
|
||||
if (out_index)
|
||||
*out_index = i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* append a log data receiver, return 0 if success.
|
||||
* the log data will be writed to file.
|
||||
*/
|
||||
XLOG_API int xlog_add_receiver_from_file(xlog_context* ctx, const char *file_path, int *out_index)
|
||||
{
|
||||
int i;
|
||||
FILE *fh = NULL;
|
||||
|
||||
if (ctx == NULL){
|
||||
return -1;
|
||||
}
|
||||
if (!file_path || *file_path == 0){
|
||||
strcpy(ctx->_error, "param @file_path is null");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < RECEIVER_MAX_COUNT; i++){
|
||||
if (ctx->_receivers[i]._fn == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == RECEIVER_MAX_COUNT){
|
||||
strcpy(ctx->_error, "receiver list is full");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fh = fopen(file_path, "a+");
|
||||
if (fh == NULL){
|
||||
strcpy(ctx->_error, "open file error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->_receivers[i]._type = RECEIVER_TYPE_FILE;
|
||||
ctx->_receivers[i]._fn = print_to_file;
|
||||
ctx->_receivers[i]._file = fh;
|
||||
ctx->_count++;
|
||||
|
||||
if (out_index)
|
||||
*out_index = i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove a log data receiver,return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_remove_receiver_by_index(xlog_context* ctx, int index)
|
||||
{
|
||||
if (ctx == NULL){
|
||||
return -1;
|
||||
}
|
||||
if (index < 0 || index >= ctx->_count){
|
||||
strcpy(ctx->_error, "index out of range");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->_receivers[index]._fn = NULL;
|
||||
index++;
|
||||
|
||||
while (index < RECEIVER_MAX_COUNT)
|
||||
{
|
||||
ctx->_receivers[index-1]._fn = ctx->_receivers[index]._fn;
|
||||
ctx->_receivers[index-1]._type = ctx->_receivers[index]._type;
|
||||
ctx->_receivers[index-1]._rev = ctx->_receivers[index]._rev;
|
||||
ctx->_receivers[index-1]._file = ctx->_receivers[index]._file;
|
||||
}
|
||||
ctx->_count--;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all receiver,return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_clear_all_receiver(xlog_context* ctx)
|
||||
{
|
||||
int i;
|
||||
if (ctx == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < RECEIVER_MAX_COUNT; i++){
|
||||
ctx->_receivers[i]._fn = NULL;
|
||||
}
|
||||
ctx->_count = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get last error.
|
||||
*/
|
||||
XLOG_API const char* xlog_get_error(xlog_context* ctx)
|
||||
{
|
||||
if (ctx != NULL && ctx->_error[0] != 0){
|
||||
return ctx->_error;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the log level,return 0 if success. see enum xlog_level_code
|
||||
*/
|
||||
XLOG_API int xlog_set_level(xlog_context* ctx, int level)
|
||||
{
|
||||
if (ctx == NULL){
|
||||
return -1;
|
||||
}
|
||||
if (level < XLOG_NONE || level > XLOG_SPEW){
|
||||
strcpy(ctx->_error, "@level value must between 0 and 5");
|
||||
return -1;
|
||||
}
|
||||
ctx->_log_level = level;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------print api
|
||||
|
||||
/**
|
||||
* create a new writer
|
||||
*/
|
||||
XLOG_API xlog_writer* xlog_create_writer(xlog_context* ctx, const char *domain)
|
||||
{
|
||||
xlog_writer *wr = NULL;
|
||||
|
||||
if (ctx != NULL){
|
||||
wr = (xlog_writer*)malloc(sizeof(xlog_writer));
|
||||
wr->_ctx = ctx;
|
||||
xlog_set_domain(wr, domain);
|
||||
return wr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* free a log writer
|
||||
*/
|
||||
XLOG_API void xlog_free_writer(xlog_writer *wr)
|
||||
{
|
||||
if (wr != NULL){
|
||||
free(wr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the main prefix string, return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_set_domain(xlog_writer* wr, const char *domain)
|
||||
{
|
||||
if (wr == NULL){
|
||||
return -1;
|
||||
}
|
||||
wr->_domain[0] = '\0';
|
||||
|
||||
if (domain && *domain){
|
||||
strncpy(wr->_domain, domain, sizeof(wr->_domain));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* print a log data, return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_print(xlog_writer *wr, int level, const char *prefix, const char *format, ...)
|
||||
{
|
||||
int i;
|
||||
struct xlog_receiver_info *inf;
|
||||
va_list args;
|
||||
|
||||
if (wr == NULL){
|
||||
return -1;
|
||||
}
|
||||
xlog_context *ctx = wr->_ctx;
|
||||
|
||||
if (ctx == NULL || ctx->_log_level < level){
|
||||
return -1;
|
||||
}
|
||||
if (ctx->_count == 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < RECEIVER_MAX_COUNT; i++){
|
||||
inf = &ctx->_receivers[i];
|
||||
if (inf->_fn != NULL){
|
||||
va_start(args, format);
|
||||
inf->_fn(inf, wr->_domain, prefix, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
135
common/log/xlog.h
Normal file
135
common/log/xlog.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This file is part of the DSView project.
|
||||
* DSView is based on PulseView.
|
||||
*
|
||||
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* example:
|
||||
* xlog_context *ctx = xlog_new();
|
||||
* xlog_writer *wr = xlog_create_writer(ctx, "module name");
|
||||
* xlog_print(wr, 2, "prefix", "count:%d", 100); //print: "module name: prefix: count:100\n"
|
||||
* xlog_free(ctx); //free the context, all writer will can't to use
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _X_LOG_H_
|
||||
#define _X_LOG_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#define XLOG_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define XLOG_API
|
||||
#endif
|
||||
|
||||
/** loglevels. */
|
||||
enum xlog_level_code{
|
||||
XLOG_NONE = 0, /**< Output no messages at all. */
|
||||
XLOG_ERR = 1, /**< Output error messages. */
|
||||
XLOG_WARN = 2, /**< Output warnings. */
|
||||
XLOG_INFO = 3, /**< Output informational messages. */
|
||||
XLOG_DBG = 4, /**< Output debug messages. */
|
||||
XLOG_SPEW = 5, /**< Output very noisy debug messages. */
|
||||
};
|
||||
|
||||
struct xlog_context;
|
||||
typedef struct xlog_context xlog_context;
|
||||
|
||||
struct xlog_writer;
|
||||
typedef struct xlog_writer xlog_writer;
|
||||
|
||||
/**
|
||||
* define log data receiver type
|
||||
*/
|
||||
typedef void (*xlog_receiver)(const char *data, int length);
|
||||
|
||||
/*
|
||||
create a log context, the console is default log receiver
|
||||
*/
|
||||
XLOG_API xlog_context* xlog_new();
|
||||
|
||||
/**
|
||||
* free a log context, return 0 if success.
|
||||
* and all xlog_writer will be can't to use.
|
||||
*/
|
||||
XLOG_API void xlog_free(xlog_context* ctx);
|
||||
|
||||
/**
|
||||
* append a log data receiver, return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_add_receiver(xlog_context* ctx, xlog_receiver rev, int *out_index);
|
||||
|
||||
/**
|
||||
* append a log data receiver, return 0 if success.
|
||||
* the log data will be writed to file.
|
||||
*/
|
||||
XLOG_API int xlog_add_receiver_from_file(xlog_context* ctx, const char *file_path, int *out_index);
|
||||
|
||||
/**
|
||||
* remove a log data receiver,return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_remove_receiver_by_index(xlog_context* ctx, int index);
|
||||
|
||||
/**
|
||||
* clear all receiver,return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_clear_all_receiver(xlog_context* ctx);
|
||||
|
||||
/**
|
||||
* get last error.
|
||||
*/
|
||||
XLOG_API const char* xlog_get_error(xlog_context* ctx);
|
||||
|
||||
/**
|
||||
* set the log level,return 0 if success. see enum xlog_level_code
|
||||
*/
|
||||
XLOG_API int xlog_set_level(xlog_context* ctx, int level);
|
||||
|
||||
//-------------------------------------------------print api
|
||||
|
||||
/**
|
||||
* create a new writer
|
||||
* use free to delete the returns object.
|
||||
*/
|
||||
XLOG_API xlog_writer* xlog_create_writer(xlog_context* ctx, const char *domain);
|
||||
|
||||
/**
|
||||
* free a log writer
|
||||
*/
|
||||
XLOG_API void xlog_free_writer(xlog_writer *wr);
|
||||
|
||||
/**
|
||||
* set the main prefix string, return 0 if success.
|
||||
*/
|
||||
XLOG_API int xlog_set_domain(xlog_writer* wr, const char *domain);
|
||||
|
||||
/**
|
||||
* print a log data, return 0 if success.
|
||||
* @level see enum xlog_level_code
|
||||
*/
|
||||
XLOG_API int xlog_print(xlog_writer *wr, int level, const char *prefix, const char *format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
-------------------------------------------------------------------------------
|
||||
AUTHORS
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Please check the source code files and/or git history and/or ChangeLog for
|
||||
a list of all authors and contributors.
|
||||
|
||||
12054
libsigrok4DSL/ChangeLog
12054
libsigrok4DSL/ChangeLog
File diff suppressed because it is too large
Load Diff
@@ -1,176 +0,0 @@
|
||||
0.2.0 (2013-05-04)
|
||||
------------------
|
||||
|
||||
Note: This release DOES change the libsigrok API. That means it is NOT
|
||||
backwards-compatible and frontends will need updates.
|
||||
|
||||
* Support for analog sources (oscilloscopes, DMMs, data loggers) was added.
|
||||
* New supported hardware:
|
||||
- Logic analyzers:
|
||||
- CWAV USBee DX
|
||||
- ZEROPLUS LAP-16128U
|
||||
- Oscilloscopes:
|
||||
- Hantek DSO-2090 (USB scope)
|
||||
- Rigol DS1052D
|
||||
- Rigol DS1052E
|
||||
- Rigol DS1102D
|
||||
- Rigol DS1102E
|
||||
- Multimeters:
|
||||
- Agilent U1231A
|
||||
- Agilent U1232A
|
||||
- Agilent U1233A
|
||||
- Brymen BM857
|
||||
- Digitek DT4000ZC
|
||||
- Fluke 187
|
||||
- Fluke 189
|
||||
- Fluke 287
|
||||
- Fluke 289
|
||||
- Fluke ScopeMeter 199B
|
||||
- MASTECH MAS345
|
||||
- Metex ME-31
|
||||
- Metex M-3640D
|
||||
- PCE PCE-DM32
|
||||
- PeakTech 3410
|
||||
- PeakTech 4370
|
||||
- RadioShack 22-168
|
||||
- RadioShack 22-805
|
||||
- RadioShack 22-812
|
||||
- Tecpel DMM-8060
|
||||
- Tecpel DMM-8061
|
||||
- TekPower TP4000ZC
|
||||
- UNI-T UT61D
|
||||
- UNI-T UT61E
|
||||
- V&A VA18B
|
||||
- Victor 70C
|
||||
- Victor 86C
|
||||
- Voltcraft VC-820
|
||||
- Voltcraft VC-840
|
||||
- Sound level meters:
|
||||
- Colead SL-5868P
|
||||
- Tondaj SL-814
|
||||
- Temperature/humidity/CO loggers:
|
||||
- Lascar EL-USB and EL-USB CO series (various models)
|
||||
- MIC 98581
|
||||
- MIC 98583
|
||||
* The limitation of max. 64 digital probes has been removed in many places.
|
||||
* Added generic DMM protocol parsers usable for various DMMs, over various
|
||||
cables and/or transports (e.g. same protocol over serial or USB/HID):
|
||||
- Cyrustek ES51922 binary protocol.
|
||||
- Fortune Semiconductor FS9721_LP3/FS9721B binary protocol.
|
||||
- Fortune Semiconductor FS9922-DMM3/DMM4 binary protocol.
|
||||
- Metex 14-byte ASCII protocol.
|
||||
- RadioShack 22-812 binary protocol.
|
||||
* zeroplus-logic-cube driver:
|
||||
- Fix acquisition at some specific samplerates. Only report valid ones.
|
||||
- Default to a samplerate of 1MHz.
|
||||
- Fix trigger code.
|
||||
- Add pre-trigger (capture ratio) setting.
|
||||
- Add support for the ZEROPLUS LAP-16128U.
|
||||
* fx2lafw driver:
|
||||
- Add support for the CWAV USBee DX. This requires the latest version of
|
||||
the fx2lafw firmware files.
|
||||
- Add support for wide sampling (i.e. 16 probes instead of just 8).
|
||||
- Fix multi-stage (software) triggers.
|
||||
- Fix various memory leaks, firmware upload timeout bugs, and other issues.
|
||||
- Various performance and memory usage improvements in the driver.
|
||||
* chronovu-la8 driver:
|
||||
- Add support for newer LA8 versions with USB VID/PID 0403:8867.
|
||||
* demo driver:
|
||||
- Various bugfixes when setting time/sample limits.
|
||||
* openbench-logic-sniffer driver:
|
||||
- Don't try to scan all available serial ports for OLS devices. Instead,
|
||||
the serial port to use now has to be specified by the user.
|
||||
- Allow disabling RLE.
|
||||
* udev rules file: Add many new entries for additional devices.
|
||||
* New output formats:
|
||||
- analog: Prints analog values and their unit (e.g. from scopes or DMMs).
|
||||
* New input formats:
|
||||
- vcd: Value Change Dump format
|
||||
- wav: Waveform audio file format (for analog data)
|
||||
* 'binary' input format: Add support for a 'samplerate' option.
|
||||
* API related changes:
|
||||
- There is generated Doxygen API documentation now.
|
||||
- The header that frontends should include is: <libsigrok/libsigrok.h>.
|
||||
There are other headers which are installed, but those are not meant to
|
||||
be included directly by the frontends.
|
||||
- There were numerous API changes, additions and removals, too many to list
|
||||
here. Please check the source code or Doxygen API documentation for the
|
||||
current set of API functions.
|
||||
* Serial port code:
|
||||
- Various improvements and fixes related to multiple parameters such as
|
||||
directions, baudrate, flow control, and others.
|
||||
- Add support for more baudrates (e.g. very low ones such as 600/1200)
|
||||
that are used in some devices.
|
||||
- Add support for setting DTR/RTS.
|
||||
* gnuplot files: Add sample files for CWAV USBee DX (for 8/16 bit sampling).
|
||||
* Documentation updates:
|
||||
- Add a README.devices file which contains various notes for users of
|
||||
libsigrok about device- and/or driver-specific issues.
|
||||
- Update README, HACKING, and other documents.
|
||||
- Updated build dependencies list.
|
||||
- The following libs are needed in more recent versions now:
|
||||
- glib (required): Now must be >= 2.32.0.
|
||||
- libusb-1.0 (optional): Now must be >= 1.0.9.
|
||||
- The following new libs were added as (optional) dependencies:
|
||||
- libasound / alsa-lib (optional): >= 1.0
|
||||
- check (optional, only needed for unit tests): >= 0.9.4
|
||||
* Portability:
|
||||
- Various compile fixes for Windows, FreeBSD/NetBSD/OpenBSD, and Mac OS X.
|
||||
- Simplify/allow/fix cross-compilation of libsigrok.
|
||||
- Various bugfixes for 32bit systems.
|
||||
- Various endianness fixes.
|
||||
* configure:
|
||||
- Add a --disable-all-drivers option. This can be overridden by
|
||||
additional --enable-<drivername> options to selectively enable only some.
|
||||
- Improve autodetection of libraries, and only enable drivers for which
|
||||
all required libraries were found.
|
||||
* Add a test suite for libsigrok with a few unit tests (the list will grow).
|
||||
|
||||
0.1.1 (2012-05-30)
|
||||
------------------
|
||||
|
||||
Note: This release does NOT change the libsigrok API.
|
||||
|
||||
* The 'saleae-logic' driver (which depends on the Saleae firmware), has
|
||||
been replaced with the new 'fx2lafw' driver, which uses an open-source
|
||||
firmware for Cypress FX2 chips which is also named 'fx2lafw'.
|
||||
Details: http://sigrok.org/wiki/Fx2lafw
|
||||
This new driver (+ firmware) currently supports the following devices:
|
||||
- ARMFLY AX-Pro
|
||||
- Braintechnology USB-LPS
|
||||
- EE Electronics ESLA100
|
||||
- EE Electronics ESLA201A
|
||||
- Robomotic MiniLogic
|
||||
- Robomotic BugLogic 3
|
||||
- Saleae Logic
|
||||
- USBee AX
|
||||
- USBee SX
|
||||
- All Cypress FX2 eval boards with stock Cypress VID/PID, including:
|
||||
- Lcsoft Mini Board
|
||||
- Braintechnology USB Interface V2.x
|
||||
Only acquisition with 8 probes is supported so far. Support for 16 probes
|
||||
and support for analog signal acquisition (on devices which have these
|
||||
capabilities) will be added later.
|
||||
* ASIX SIGMA driver:
|
||||
- Add support for the ASIX SIGMA2. This requires the latest version of
|
||||
the SIGMA/SIGMA2 firmware files.
|
||||
Details: http://sigrok.org/wiki/Firmware
|
||||
- Various bugfixes.
|
||||
* ZEROPLUS Logic Cube LAP-C (16032): Fix a segfault.
|
||||
* udev file: Add entries for Robomotic BugLogic 3, Velleman PCSU1000,
|
||||
Ideofy LA-08, ARMFLY AX-Pro, and Braintechnology USB Interface V2.x.
|
||||
* The zlib dependency has been removed (no longer needed).
|
||||
* Fix compiling with "Homebrew" (Mac OS X).
|
||||
* libsigrok now expects firmware files in $prefix/share/sigrok-firmware by
|
||||
default (was $prefix/share/libsigrok/firmware before).
|
||||
* Fix a Makefile.am bug which caused the generated ChangeLog files being
|
||||
accidentally deleted upon 'make distclean'.
|
||||
* ChronoVu LA8 input file format: Improve autodetection of the file format.
|
||||
We now only accept files of the size 8388613 bytes (all LA8 files have
|
||||
exactly this amount of bytes).
|
||||
|
||||
0.1.0 (2012-04-17)
|
||||
------------------
|
||||
|
||||
* Initial release.
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
-------------------------------------------------------------------------------
|
||||
README
|
||||
-------------------------------------------------------------------------------
|
||||
libsigrok4DSL is a shared library which provides the basic API
|
||||
for DreamSourceLab hardware.
|
||||
libsigrok4DSL is based on libsigrok, a shared library from the sigrok project.
|
||||
|
||||
The sigrok project aims at creating a portable, cross-platform,
|
||||
Free/Libre/Open-Source signal analysis software suite that supports various
|
||||
device types (such as logic analyzers, oscilloscopes, multimeters, and more).
|
||||
|
||||
libsigrok is a shared library written in C which provides the basic API
|
||||
for talking to hardware and reading/writing the acquired data into various
|
||||
input/output file formats.
|
||||
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
libsigrok is in a usable state and has had official tarball releases.
|
||||
|
||||
While the API can change from release to release, this will always be
|
||||
properly documented and reflected in the package version number and
|
||||
in the shared library / libtool / .so-file version numbers.
|
||||
|
||||
However, there are _NO_ guarantees at all for stable APIs in git snapshots!
|
||||
Distro packagers should only use released tarballs (no git snapshots).
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
- git
|
||||
- gcc (>= 4.0)
|
||||
- make
|
||||
- autoconf >= 2.63
|
||||
- automake >= 1.11
|
||||
- libtool
|
||||
- pkg-config >= 0.22
|
||||
- libglib >= 2.32.0
|
||||
- libusb-1.0 >= 1.0.9 (optional, used by most drivers)
|
||||
- libftdi >= 0.16 (optional, used by some drivers)
|
||||
- libasound / alsa-lib >= 1.0 (optional, only used by the alsa driver)
|
||||
- check >= 0.9.4 (optional, only needed to run unit tests)
|
||||
|
||||
|
||||
Building and installing
|
||||
-----------------------
|
||||
Get the libsigrok4DSL source code from: www.dreamsourcelab.com/download.html
|
||||
In order to build it, run:
|
||||
|
||||
$ cd libsigrok
|
||||
$ ./autogen.sh
|
||||
$ ./configure
|
||||
$ make
|
||||
|
||||
For installing libsigrok4DSL:
|
||||
|
||||
$ make install
|
||||
|
||||
See INSTALL or the following wiki page for more (OS-specific) instructions:
|
||||
|
||||
http://sigrok.org/wiki/Building
|
||||
|
||||
|
||||
Copyright and license
|
||||
---------------------
|
||||
|
||||
libsigrok4DSL is licensed under the terms of the GNU General Public License
|
||||
(GPL), version 3 or later.
|
||||
|
||||
While some individual source code files are licensed under the GPLv2+, and
|
||||
some files are licensed under the GPLv3+, this doesn't change the fact that
|
||||
the library as a whole is licensed under the terms of the GPLv3+.
|
||||
|
||||
Please see the individual source files for the full list of copyright holders.
|
||||
|
||||
|
||||
Mailing lists
|
||||
-------------
|
||||
|
||||
There are two mailing lists for sigrok/libsigrok:
|
||||
|
||||
https://lists.sourceforge.net/lists/listinfo/sigrok-devel
|
||||
https://lists.sourceforge.net/lists/listinfo/sigrok-commits
|
||||
|
||||
|
||||
IRC
|
||||
---
|
||||
|
||||
You can find the sigrok developers in the #sigrok IRC channel on Freenode.
|
||||
|
||||
|
||||
Website
|
||||
-------
|
||||
|
||||
http://sigrok.org/wiki/Libsigrok
|
||||
http://dreamsourcelab.com
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is part of the libsigrok project.
|
||||
*
|
||||
* Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LIBSIGROK_VERSION_H
|
||||
#define LIBSIGROK_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Version number definitions and macros.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup grp_versions
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Package version macros (can be used for conditional compilation).
|
||||
*/
|
||||
|
||||
/** The libsigrok package 'major' version number. */
|
||||
#define SR_PACKAGE_VERSION_MAJOR @SR_PACKAGE_VERSION_MAJOR@
|
||||
|
||||
/** The libsigrok package 'minor' version number. */
|
||||
#define SR_PACKAGE_VERSION_MINOR @SR_PACKAGE_VERSION_MINOR@
|
||||
|
||||
/** The libsigrok package 'micro' version number. */
|
||||
#define SR_PACKAGE_VERSION_MICRO @SR_PACKAGE_VERSION_MICRO@
|
||||
|
||||
/** The libsigrok package version ("major.minor.micro") as string. */
|
||||
#define SR_PACKAGE_VERSION_STRING "@SR_PACKAGE_VERSION@"
|
||||
|
||||
/*
|
||||
* Library/libtool version macros (can be used for conditional compilation).
|
||||
*/
|
||||
|
||||
/** The libsigrok libtool 'current' version number. */
|
||||
#define SR_LIB_VERSION_CURRENT @SR_LIB_VERSION_CURRENT@
|
||||
|
||||
/** The libsigrok libtool 'revision' version number. */
|
||||
#define SR_LIB_VERSION_REVISION @SR_LIB_VERSION_REVISION@
|
||||
|
||||
/** The libsigrok libtool 'age' version number. */
|
||||
#define SR_LIB_VERSION_AGE @SR_LIB_VERSION_AGE@
|
||||
|
||||
/** The libsigrok libtool version ("current:revision:age") as string. */
|
||||
#define SR_LIB_VERSION_STRING "@SR_LIB_VERSION@"
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user