kopia lustrzana https://github.com/cariboulabs/cariboulite
Logging update (#4)
* listen to environment variable * added socket target * reset color when dumping memory (ZF_LOG bug) * minor improvements (build script) * added generous send buffer and improved on thread-safety * log which error prevented device from being openedbug_fixes_integration_tx
rodzic
02a8eb3c6c
commit
c61b73054d
92
install.sh
92
install.sh
|
@ -19,9 +19,10 @@ git submodule update
|
|||
|
||||
## kernel module dev dependencies
|
||||
printf "\n[ 2 ] ${GREEN}Updating system and installing dependencies...${NC}\n"
|
||||
sudo -u root apt-get update
|
||||
sudo -u root apt-get install raspberrypi-kernel-headers module-assistant pkg-config libncurses5-dev cmake git libzmq3-dev avahi-daemon libavahi-client-dev
|
||||
sudo -u root depmod -a
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install raspberrypi-kernel-headers module-assistant pkg-config libncurses5-dev cmake git libzmq3-dev
|
||||
sudo apt-get -y install swig avahi-daemon libavahi-client-dev python3-distutils libpython3-dev
|
||||
sudo depmod -a
|
||||
|
||||
# clone SoapySDR dependencies
|
||||
printf "\n[ 3 ] ${GREEN}Checking Soapy SDR installation ($SOAPY_UTILS_EXE)...${NC}\n"
|
||||
|
@ -31,75 +32,66 @@ SOAPY_UTIL_PATH=`which $SOAPY_UTILS_EXE`
|
|||
if test -f "${SOAPY_UTIL_PATH}"; then
|
||||
printf "${CYAN}Found SoapySDRUtil at ${SOAPY_UTIL_PATH}${NC}\n"
|
||||
else
|
||||
mkdir installations
|
||||
cd installations
|
||||
mkdir -p $ROOT_DIR/installations
|
||||
|
||||
printf "${RED}Did not find SoapySDRUtil${NC}. Do you want to clone and install? [Y/n]: "
|
||||
read -s -n1
|
||||
REPLY="${REPLY}Y <- default"
|
||||
|
||||
if [ "$REPLY" == "${REPLY#[Yy]}" ]; then
|
||||
printf "N\n"
|
||||
else
|
||||
printf "Y\n"
|
||||
|
||||
printf "${RED}Did not find SoapySDRUtil${NC}. Do you want to clone and install? (Y/[N]):"
|
||||
read -p ' ' InstallSoapy
|
||||
|
||||
if [ "$InstallSoapy" = "Y" ]; then
|
||||
printf "==> ${GREEN}Cloning SoapySDR, and compiling...${NC}\n"
|
||||
rm -R SoapySDR
|
||||
cd $ROOT_DIR/installations
|
||||
|
||||
rm -rf SoapySDR
|
||||
git clone https://github.com/pothosware/SoapySDR.git
|
||||
|
||||
|
||||
# Soapy
|
||||
|
||||
# Soapy SDR -- the SDR abstraction library
|
||||
cd SoapySDR
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir -p build && cd build
|
||||
cmake ../
|
||||
make -j4 && sudo -u root make install
|
||||
sudo -u root ldconfig
|
||||
make && sudo make install
|
||||
sudo ldconfig
|
||||
|
||||
printf "==> ${GREEN}Cloning SoapyRemote, and compiling...${NC}\n"
|
||||
cd $ROOT_DIR/installations
|
||||
|
||||
rm -rf SoapyRemote
|
||||
git clone https://github.com/pothosware/SoapyRemote.git
|
||||
|
||||
# Soapy Server -- Use any Soapy SDR remotely
|
||||
cd SoapyRemote
|
||||
mkdir -p build && cd build
|
||||
cmake ../
|
||||
make && sudo make install
|
||||
sudo ldconfig
|
||||
fi
|
||||
|
||||
SOAPYMODPATH=`SoapySDRUtil --info | grep "Search path" | cut -d":" -f2 | xargs | cut -d" " -f1`
|
||||
SOAPYMODPATH_PREFIX=`SoapySDRUtil --info | grep "Search path" | cut -d":" -f2 | xargs | cut -d" " -f1 | awk -F '/Soapy' '{print $1}'`
|
||||
sudo -u root mkdir -p $SOAPYMODPATH
|
||||
|
||||
#cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ../ && make all install
|
||||
|
||||
if [ "$InstallSoapy" = "Y" ]; then
|
||||
printf "==> ${GREEN}Cloning SoapyRemote, and compiling...${NC}\n"
|
||||
rm -R SoapyRemote
|
||||
git clone https://github.com/pothosware/SoapyRemote.git
|
||||
|
||||
# Soapy Remote (Server)
|
||||
cd ../..
|
||||
cd SoapyRemote
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX:PATH=$SOAPYMODPATH_PREFIX ../
|
||||
make -j4 && sudo -u root make install
|
||||
sudo -u root ldconfig
|
||||
fi
|
||||
|
||||
printf "\n[ 4 ] ${GREEN}Checking the installed Soapy utilities...${NC}\n"
|
||||
SOAPY_UTIL_PATH=`which $SOAPY_UTILS_EXE`
|
||||
if test -f "${SOAPY_UTIL_PATH}"; then
|
||||
printf "${CYAN}Found SoapySDRUtil at ${SOAPY_UTIL_PATH}${NC}\n"
|
||||
else
|
||||
printf "\n${RED}Failed installing Soapy. Exiting...${NC}\n\n"
|
||||
cd ..
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ..
|
||||
fi
|
||||
|
||||
## Main Software
|
||||
printf "\n[ 5 ] ${GREEN}Compiling main source...${NC}\n"
|
||||
printf "${CYAN}1. External Tools...${NC}\n"
|
||||
cd $ROOT_DIR/software/utils
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir -p build && cd build
|
||||
cmake ../
|
||||
make
|
||||
mv $ROOT_DIR/software/utils/build/generate_bin_blob $ROOT_DIR/software/utils/generate_bin_blob
|
||||
|
||||
printf "${CYAN}2. libIIR ${NC}\n"
|
||||
cd $ROOT_DIR/software/libcariboulite/src/iir/
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir -p build && cd build
|
||||
cmake ../
|
||||
make
|
||||
sudo make install
|
||||
|
@ -107,18 +99,16 @@ sudo ldconfig
|
|||
|
||||
printf "${CYAN}3. SMI kernel module...${NC}\n"
|
||||
cd $ROOT_DIR/software/libcariboulite/src/caribou_smi/kernel
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir -p build && cd build
|
||||
cmake ../
|
||||
make
|
||||
|
||||
printf "${CYAN}3. Main software...${NC}\n"
|
||||
printf "${CYAN}4. Main software...${NC}\n"
|
||||
cd $ROOT_DIR
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir -p build && cd build
|
||||
cmake $ROOT_DIR/software/libcariboulite/
|
||||
make
|
||||
sudo -u root make install
|
||||
sudo make install
|
||||
|
||||
# Configuration File
|
||||
printf "\n[ 6 ] ${GREEN}Environmental Settings...${NC}\n"
|
||||
|
|
|
@ -461,7 +461,7 @@ int caribou_smi_init(caribou_smi_st* dev,
|
|||
int fd = open(smi_file, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
ZF_LOGE("couldn't open smi driver file '%s'", smi_file);
|
||||
ZF_LOGE("couldn't open smi driver file '%s' (%s)", smi_file, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
dev->filedesc = fd;
|
||||
|
|
|
@ -30,7 +30,7 @@ endif()
|
|||
if(ZF_LOG_USE_DEBUGSTRING)
|
||||
target_compile_definitions(zf_log PRIVATE "ZF_LOG_USE_DEBUGSTRING")
|
||||
endif()
|
||||
if(ZF_LOG_USE_CONFIG_HEADER)
|
||||
if(ZF_LOG_USE_CONFIG_HEADER OR DEFINED ENV{ZF_LOG_USE_CONFIG_HEADER})
|
||||
target_compile_definitions(zf_log PRIVATE "ZF_LOG_USE_CONFIG_HEADER")
|
||||
endif()
|
||||
if(ZF_LOG_OPTIMIZE_SIZE)
|
||||
|
|
|
@ -1198,7 +1198,7 @@ static void put_src(zf_log_message *const msg, const src_location *const src)
|
|||
#define FRED_ERROR "\033[0;31m"
|
||||
#define FPURPLE_FATAL "\033[0;35m"
|
||||
|
||||
static char* font_colors[] =
|
||||
static char* font_colors[] =
|
||||
{
|
||||
NONE, // 0 level
|
||||
NONE, // Verbose
|
||||
|
@ -1262,6 +1262,7 @@ static void output_mem(const zf_log_spec *log, zf_log_message *const msg,
|
|||
*hex++ = ' ';
|
||||
}
|
||||
msg->p = ascii;
|
||||
put_color(msg, 0);
|
||||
log->output->callback(msg, log->output->arg);
|
||||
}
|
||||
}
|
||||
|
@ -1329,7 +1330,7 @@ static void _zf_log_write_imp(
|
|||
if (0 != mem && ZF_LOG_PUT_MSG & mask)
|
||||
{
|
||||
output_mem(log, &msg, mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _ZF_LOG_CONFIG_H_
|
||||
#define _ZF_LOG_CONFIG_H_
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
|
||||
#if defined(__linux__)
|
||||
#if !defined(__ANDROID__) && !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "zf_log.h"
|
||||
|
||||
#define ZF_LOG_EXTERN_GLOBAL_OUTPUT 1
|
||||
|
||||
#define DO(expr) while((expr) < 0 && errno == EINTR)
|
||||
|
||||
static struct target
|
||||
{
|
||||
const char *ip; /* IPv4 address */
|
||||
const int port; /* port number */
|
||||
|
||||
struct sockaddr_in addr; /* housekeeping */
|
||||
int fd; /* ... */
|
||||
|
||||
} sink = {"239.192.0.1", 42099, {0}, -2};
|
||||
|
||||
static void socket_output_init()
|
||||
{
|
||||
sink.addr.sin_family = AF_INET;
|
||||
sink.addr.sin_port = htons(sink.port);
|
||||
|
||||
if (sink.ip && inet_pton(AF_INET, sink.ip, &sink.addr.sin_addr) == 1)
|
||||
if ((sink.fd = socket(AF_INET, SOCK_DGRAM|SOCK_NONBLOCK, 0)) != -1)
|
||||
{
|
||||
int optval = 0x200000;
|
||||
setsockopt(sink.fd, SOL_SOCKET, SO_SNDBUF, &optval, sizeof(optval));
|
||||
}
|
||||
|
||||
if (sink.fd < 0) zf_log_set_output_v(ZF_LOG_OUT_STDERR); /* install fallback */
|
||||
}
|
||||
|
||||
static void socket_output_callback(const zf_log_message *msg, void *arg)
|
||||
{
|
||||
static pthread_once_t socket_is_initialized = PTHREAD_ONCE_INIT;
|
||||
pthread_once(&socket_is_initialized, socket_output_init);
|
||||
|
||||
if (sink.fd < 0) zf_log_out_stderr_callback(msg, arg); /* trigger fallback */
|
||||
else
|
||||
DO(sendto(sink.fd, msg->buf, (msg->p - msg->buf), 0, (struct sockaddr *)&sink.addr, sizeof(sink.addr)));
|
||||
}
|
||||
|
||||
ZF_LOG_DEFINE_GLOBAL_OUTPUT = {ZF_LOG_PUT_STD, 0, socket_output_callback};
|
||||
|
||||
#endif /* !defined(_WIN32) && !defined(_WIN64) */
|
||||
#endif /* _ZF_LOG_CONFIG_H_ */
|
Ładowanie…
Reference in New Issue