-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit with project skeleton
0 parents
commit 51a4c0a
Showing
9 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
release-build | ||
debug-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "lib/log"] | ||
path = lib/log | ||
url = ../logtools | ||
[submodule "lib/xptools"] | ||
path = lib/xptools | ||
url = ../xptools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
cmake_minimum_required(VERSION 3.3) | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | ||
project(scopehal-pico-bridge) | ||
|
||
set(ANALYZE CACHE BOOL "Run static analysis on the code, requires cppcheck and clang-analyzer to be installed") | ||
|
||
set(WARNINGS "-Wall -Wextra -Wuninitialized ") | ||
set(WARNINGS "${WARNINGS} -Wshadow -Wunsafe-loop-optimizations -Wpedantic -Wcast-align -Wwrite-strings") | ||
set(WARNINGS "${WARNINGS} -Wmissing-declarations -Wvla") | ||
set(CMAKE_CXX_FLAGS "-g -fopenmp ${WARNINGS} --std=c++11 -mtune=native -ffast-math") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O3") | ||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -fsanitize=address") | ||
|
||
if(WIN32) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_USE_MATH_DEFINES -D_POSIX_THREAD_SAFE_FUNCTIONS") | ||
endif() | ||
|
||
find_package(PkgConfig) | ||
find_package(OpenCL) | ||
|
||
if(ANALYZE) | ||
find_program(CPPCHECK_PATH cppcheck DOC "Path to cppcheck when ANALYZE is enabled") | ||
if(CPPCHECK_PATH) | ||
execute_process(COMMAND ${CPPCHECK_PATH} "--version" OUTPUT_VARIABLE CPPCHECK_VER_STR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
string(REPLACE "Cppcheck " "" CPPCHECK_VERSION ${CPPCHECK_VER_STR}) | ||
if(CPPCHECK_VERSION VERSION_GREATER_EQUAL "2") | ||
set(CMAKE_CXX_CPPCHECK "${CPPCHECK_PATH};-DFT_USE_AUTOCONF_SIZEOF_TYPES;-D__GNUC__;--enable=warning,performance,portability;--suppress=*:*sigc*;--suppress=*:*glibmm*;--suppress=*:*gtkmm*;--inline-suppr;-q;--std=c++11") | ||
message(STATUS "Found CPPCheck: ${CPPCHECK_PATH} (found version \"${CPPCHECK_VERSION}\")") | ||
else() | ||
message(STATUS "Found CPPCheck: ${CPPCHECK_PATH} but ignored it as it was ${CPPCHECK_VERSION} < 2") | ||
endif() | ||
else() | ||
message(STATUS "CPPCheck not found") | ||
endif() | ||
# The actual clang-analyzer compiler wrapper doesn't get installed on $PATH, only scan-build which is useless to us | ||
find_program(CLANGANALYZER_SCANBUILD_PATH scan-build DOC "Path to clang-analyzer's scan-build tool, used as a hint to find the rest of the clang-analyzer") | ||
get_filename_component(CLANGANALYZER_SCANBUILD_BIN ${CLANGANALYZER_SCANBUILD_PATH} REALPATH) | ||
get_filename_component(CLANGANALYZER_BIN_PATH ${CLANGANALYZER_SCANBUILD_BIN} DIRECTORY) | ||
find_program(CLANGANALYZER_CXXANALYZER_PATH "c++-analyzer" HINTS "${CLANGANALYZER_BIN_PATH}/../libexec" DOC "Path to clang-analyzer's c++-analyzer") | ||
if(CLANGANALYZER_CXXANALYZER_PATH) | ||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CLANGANALYZER_CXXANALYZER_PATH}") | ||
message(STATUS "Found clang-analyzer: ${CLANGANALYZER_CXXANALYZER_PATH}") | ||
else() | ||
message(STATUS "clang-analyzer not found") | ||
endif() | ||
endif() | ||
|
||
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/log") | ||
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/xptools") | ||
add_subdirectory("${PROJECT_SOURCE_DIR}/src/ps6000d") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2021, Andrew Zonenberg | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# scopehal-pico-bridge | ||
|
||
Socket servers for Pico Technology instruments allowing remote access via libscopehal. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Additional libraries on Windows | ||
if(WIN32) | ||
set(WIN_LIBS shlwapi) | ||
endif() | ||
|
||
#Set up include paths | ||
include_directories('/opt/picoscope/include/libps6000a') | ||
|
||
############################################################################### | ||
#C++ compilation | ||
add_executable(ps6000d | ||
main.cpp | ||
) | ||
|
||
############################################################################### | ||
#Linker settings | ||
target_link_libraries(ps6000d | ||
xptools | ||
log | ||
/opt/picoscope/lib/libps6000a.so | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*********************************************************************************************************************** | ||
* * | ||
* ps6000d * | ||
* * | ||
* Copyright (c) 2012-2021 Andrew D. Zonenberg * | ||
* All rights reserved. * | ||
* * | ||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * | ||
* following conditions are met: * | ||
* * | ||
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the * | ||
* following disclaimer. * | ||
* * | ||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the * | ||
* following disclaimer in the documentation and/or other materials provided with the distribution. * | ||
* * | ||
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products * | ||
* derived from this software without specific prior written permission. * | ||
* * | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * | ||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * | ||
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * | ||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * | ||
* POSSIBILITY OF SUCH DAMAGE. * | ||
* * | ||
***********************************************************************************************************************/ | ||
|
||
/** | ||
@file | ||
@author Andrew D. Zonenberg | ||
@brief Program entry point | ||
*/ | ||
|
||
#ifdef _WIN32 | ||
#include <windows.h> | ||
#include <shlwapi.h> | ||
#endif | ||
|
||
#include "../../lib/log/log.h" | ||
#include "../../lib/xptools/Socket.h" | ||
#include <thread> | ||
|
||
using namespace std; | ||
|
||
void help(); | ||
|
||
void help() | ||
{ | ||
fprintf(stderr, | ||
"ps6000d [general options] [logger options]\n" | ||
"\n" | ||
" [general options]:\n" | ||
" --help : this message...\n" | ||
"\n" | ||
" [logger options]:\n" | ||
" levels: ERROR, WARNING, NOTICE, VERBOSE, DEBUG\n" | ||
" --quiet|-q : reduce logging level by one step\n" | ||
" --verbose : set logging level to VERBOSE\n" | ||
" --debug : set logging level to DEBUG\n" | ||
" --trace <classname>| : name of class with tracing messages. (Only relevant when logging level is DEBUG.)\n" | ||
" <classname::function>\n" | ||
" --logfile|-l <filename> : output log messages to file\n" | ||
" --logfile-lines|-L <filename> : output log messages to file, with line buffering\n" | ||
" --stdout-only : writes errors/warnings to stdout instead of stderr\n" | ||
); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
//Global settings | ||
Severity console_verbosity = Severity::NOTICE; | ||
|
||
//Parse command-line arguments | ||
for(int i=1; i<argc; i++) | ||
{ | ||
string s(argv[i]); | ||
|
||
//Let the logger eat its args first | ||
if(ParseLoggerArguments(i, argc, argv, console_verbosity)) | ||
continue; | ||
|
||
if(s == "--help") | ||
{ | ||
help(); | ||
return 0; | ||
} | ||
else if(s[0] == '-') | ||
{ | ||
fprintf(stderr, "Unrecognized command-line argument \"%s\", use --help\n", s.c_str()); | ||
return 1; | ||
} | ||
} | ||
|
||
//Set up logging | ||
g_log_sinks.emplace(g_log_sinks.begin(), new ColoredSTDLogSink(console_verbosity)); | ||
|
||
return 0; | ||
} |