diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 786e383..36fb30b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -76,6 +76,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - name: setup id: setup @@ -104,7 +106,6 @@ jobs: path: | Build Resources - libONI deploy-linux: @@ -133,7 +134,7 @@ jobs: mkdir shared cp Resources/libokFrontPanel.so shared cp Resources/*.bit shared - cp -r libONI/linux/*.so shared + cp Build/lib/*.so shared zipfile=${package}_${new_plugin_ver}.zip zip -r -X $zipfile plugins shared curl -H "X-JFrog-Art-Api:$ARTIFACTORY_ACCESS_TOKEN" -T $zipfile "https://openephys.jfrog.io/artifactory/AcquisitionBoard-plugin/linux/$zipfile" diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 14b54ba..6427293 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -76,6 +76,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - name: setup id: setup @@ -102,7 +104,6 @@ jobs: path: | Build Resources - libONI deploy-mac: @@ -140,7 +141,7 @@ jobs: mkdir shared cp -r Resources/libokFrontPanel.1.dylib shared cp Resources/*.bit shared - cp -r libONI/osx/*.dylib shared + cp -r Build/lib/*.dylib shared # Turn our base64-encoded certificate back to a regular .p12 file echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8d7a4e9..4b169cc 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -76,6 +76,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: 'recursive' - name: setup id: setup @@ -84,7 +86,7 @@ jobs: cd ../.. git clone https://github.com/open-ephys/plugin-GUI.git --branch main cd plugin-GUI/Build - cmake -G "Visual Studio 17 2022" -A x64 .. + cmake -G "Visual Studio 17 2022" -A x64 .. mkdir Release && cd Release curl -L https://openephys.jfrog.io/artifactory/GUI-binaries/Libraries/open-ephys-lib-v1.0.0.zip --output open-ephys-lib.zip unzip open-ephys-lib.zip @@ -94,16 +96,20 @@ jobs: - name: configure run: | cd Build - cmake -G "Visual Studio 17 2022" -A x64 .. + cmake -G "Visual Studio 17 2022" -A x64 .. shell: bash - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v2 + # NB: To respect the ReleaseStatic configuration for liboni, we need to build the solution + # first before running INSTALL.vcxproj, otherwise it will build liboni in Release + # configuration and throw linking errors - name: build-plugin id: build-plugin run: | cd Build + msbuild OE_PLUGIN_acquisition-board.sln -p:Configuration=Release -p:Platform=x64 msbuild INSTALL.vcxproj -p:Configuration=Release -p:Platform=x64 shell: cmd @@ -116,7 +122,6 @@ jobs: path: | Build Resources - libONI deploy-windows: @@ -143,7 +148,7 @@ jobs: mkdir plugins cp $build_dir/*.dll plugins mkdir shared - cp libONI/win64/*.dll shared + cp Build/x64/Release/*.dll shared cp Resources/okFrontPanel.dll shared cp Resources/*.bit shared zipfile=${package}_${new_plugin_ver}.zip diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d7eac97 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "liboni"] + path = liboni + url = https://github.com/open-ephys/liboni diff --git a/CMakeLists.txt b/CMakeLists.txt index a2aa237..e5d43d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:NDEBUG=1> ) - set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Source) file(GLOB_RECURSE SRC_FILES LIST_DIRECTORIES false "${SOURCE_PATH}/*.cpp" "${SOURCE_PATH}/*.h") set(GUI_COMMONLIB_DIR ${GUI_BASE_DIR}/installed_libs) @@ -64,7 +63,7 @@ endif() #Libraries and compiler options if(MSVC) target_link_libraries(${PLUGIN_NAME} ${GUI_BIN_DIR}/open-ephys.lib) - target_compile_options(${PLUGIN_NAME} PRIVATE /sdl- /W0) + target_compile_options(${PLUGIN_NAME} PRIVATE /sdl- /W0 /MP) install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION ${GUI_BIN_DIR}/plugins CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) install(FILES $ DESTINATION ${GUI_BIN_DIR}/plugins OPTIONAL) @@ -86,10 +85,6 @@ elseif(APPLE) XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO) - add_custom_command(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND - install_name_tool -change "liboni.dylib" - "@rpath/liboni.dylib" $) - add_custom_command(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND install_name_tool -change "libonidriver_ft600.dylib" "@rpath/libonidriver_ft600.dylib" $) @@ -114,26 +109,137 @@ elseif(LINUX) target_link_libraries(${PLUGIN_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/Resources/libokFrontPanel.so") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Resources/libokFrontPanel.so DESTINATION ${GUI_BIN_DIR}/shared) elseif(APPLE) + set(MAC_SHARED_FOLDER $ENV{HOME}/Library/Application\ Support/open-ephys/shared-api10) + target_link_libraries(${PLUGIN_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/Resources/libokFrontPanel.dylib") - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Resources/libokFrontPanel.1.dylib DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/shared-api10) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Resources/libokFrontPanel.1.dylib DESTINATION "${MAC_SHARED_FOLDER}") endif() -set(LIBONI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libONI) -target_include_directories(${PLUGIN_NAME} PRIVATE ${LIBONI_DIR}/include) +function(vs_set_all_configurations target_name target_config_name) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${config} config_upper) + set_property( + TARGET ${target_name} + APPEND PROPERTY MAP_IMPORTED_CONFIG_${config_upper} "${target_config_name}" + ) + endforeach() +endfunction() + +include(ExternalProject) if (MSVC) - set(LIBONI_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libONI/win64) - target_link_libraries(${PLUGIN_NAME} "${LIBONI_LIB_DIR}/liboni.lib") - install(FILES ${LIBONI_LIB_DIR}/liboni.dll DESTINATION ${GUI_BIN_DIR}/shared CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) - install(FILES ${LIBONI_LIB_DIR}/libonidriver_ft600.dll DESTINATION ${GUI_BIN_DIR}/shared CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) -elseif(LINUX) - find_library(LIBONI_LIBRARIES oni liboni PATHS ${CMAKE_CURRENT_SOURCE_DIR}/libONI/linux) - target_link_libraries(${PLUGIN_NAME} ${LIBONI_LIBRARIES}) - install(DIRECTORY ${LIBONI_DIR}/linux/ DESTINATION ${GUI_BIN_DIR}/shared FILES_MATCHING PATTERN "*.so") -elseif(APPLE) - set(LIBONI_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libONI/osx) - target_link_libraries(${PLUGIN_NAME} "${LIBONI_LIB_DIR}/liboni.dylib") - target_link_libraries(${PLUGIN_NAME} "${LIBONI_LIB_DIR}/libonidriver_ft600.dylib") - install(FILES ${LIBONI_LIB_DIR}/liboni.dylib DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/shared-api10) - install(FILES ${LIBONI_LIB_DIR}/libonidriver_ft600.dylib DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/shared-api10) + # add liboni project + + set(LIBONI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/liboni/api/liboni") + set(LIBONI_NAME liboni) + set(LIBONI_PNAME "submodule_${LIBONI_NAME}") + + include_external_msproject ( + ${LIBONI_PNAME} + "${LIBONI_DIR}/liboni.vcxproj" + PLATFORM ${CMAKE_LIBRARY_ARCHITECTURE} + ) + + vs_set_all_configurations(${LIBONI_PNAME} "ReleaseStatic") + + add_library("${LIBONI_NAME}" STATIC IMPORTED) + set_target_properties("${LIBONI_NAME}" PROPERTIES + IMPORTED_LOCATION "${LIBONI_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/ReleaseStatic/liboni.lib" + INTERFACE_INCLUDE_DIRECTORIES "${LIBONI_DIR}") + + add_dependencies(${LIBONI_NAME} ${LIBONI_PNAME}) + target_link_libraries(${PLUGIN_NAME} "${LIBONI_NAME}") + + # Add onidriver_ft600 project + + set(ONIDRIVER_FT600_DIR "${LIBONI_DIR}/drivers/ft600") + set(ONIDRIVER_FT600_NAME libonidriver_ft600) + set(ONIDRIVER_FT600_PNAME "submodule_${ONIDRIVER_FT600_NAME}") + + include_external_msproject( + ${ONIDRIVER_FT600_PNAME} + "${ONIDRIVER_FT600_DIR}/onidriver_ft600.vcxproj" + PLATFORM ${CMAKE_LIBRARY_ARCHITECTURE} + ) + + vs_set_all_configurations(${ONIDRIVER_FT600_PNAME} "Release") + + add_dependencies(${ONIDRIVER_FT600_PNAME} ${LIBONI_PNAME}) + + # Ensure needed DLLs are installed to the shared folder + install(FILES "${CMAKE_BINARY_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/Release/${ONIDRIVER_FT600_NAME}.dll" DESTINATION ${GUI_BIN_DIR}/shared) +elseif(LINUX OR APPLE) + # Add liboni project + + set(LIBONI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/liboni/api/liboni") + set(LIBONI_NAME liboni) + set(LIBONI_PNAME "submodule_${LIBONI_NAME}") + + ExternalProject_Add( + ${LIBONI_PNAME} + SOURCE_DIR "${LIBONI_DIR}" + CONFIGURE_COMMAND "" + BUILD_COMMAND make "CFLAGS=-Wall -W -Werror -fPIC -O3" + BUILD_IN_SOURCE 1 + INSTALL_COMMAND "" + ) + + add_library("${LIBONI_NAME}" STATIC IMPORTED GLOBAL) + set_target_properties("${LIBONI_NAME}" PROPERTIES + IMPORTED_LOCATION "${LIBONI_DIR}/liboni.a" + INTERFACE_INCLUDE_DIRECTORIES "${LIBONI_DIR}") + + add_dependencies(${LIBONI_NAME} ${LIBONI_PNAME}) + target_link_libraries(${PLUGIN_NAME} "${LIBONI_NAME}") + + # Add onidriver_ft600 project + + set(ONIDRIVER_FT600_DIR "${LIBONI_DIR}/drivers/ft600") + set(ONIDRIVER_FT600_NAME libonidriver_ft600) + set(ONIDRIVER_FT600_PNAME "submodule_${ONIDRIVER_FT600_NAME}") + + set(INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Build/lib") + + if(APPLE) + set(ONIDRIVER_FT600_FILENAME "${ONIDRIVER_FT600_NAME}.dylib") + + ExternalProject_Add( + ${ONIDRIVER_FT600_PNAME} + SOURCE_DIR "${ONIDRIVER_FT600_DIR}" + CONFIGURE_COMMAND "" + BUILD_COMMAND make + BUILD_IN_SOURCE 1 + INSTALL_COMMAND + ${CMAKE_COMMAND} -E make_directory("${INSTALL_DIR}") + COMMAND ${CMAKE_COMMAND} -E copy + "${ONIDRIVER_FT600_DIR}/${ONIDRIVER_FT600_FILENAME}" + "${INSTALL_DIR}" + DEPENDS ${LIBONI_PNAME} + ) + + # Ensure needed shared libraries are installed to the shared folder + install(FILES "${ONIDRIVER_FT600_DIR}/${ONIDRIVER_FT600_FILENAME}" + DESTINATION "${MAC_SHARED_FOLDER}") + elseif(LINUX) + set(ONIDRIVER_FT600_FILENAME "${ONIDRIVER_FT600_NAME}.so") + + ExternalProject_Add( + ${ONIDRIVER_FT600_PNAME} + SOURCE_DIR "${ONIDRIVER_FT600_DIR}" + CONFIGURE_COMMAND "" + BUILD_COMMAND make + BUILD_IN_SOURCE 1 + INSTALL_COMMAND + ${CMAKE_COMMAND} -E make_directory("${INSTALL_DIR}") + COMMAND ${CMAKE_COMMAND} -E copy + "${ONIDRIVER_FT600_DIR}/${ONIDRIVER_FT600_FILENAME}.1" + "${INSTALL_DIR}/${ONIDRIVER_FT600_FILENAME}" + DEPENDS ${LIBONI_PNAME} + ) + + # Ensure needed shared libraries are installed to the shared folder + install(FILES "${ONIDRIVER_FT600_DIR}/${ONIDRIVER_FT600_FILENAME}.1" + DESTINATION ${GUI_BIN_DIR}/shared + RENAME "${ONIDRIVER_FT600_FILENAME}") + endif() endif() diff --git a/README.md b/README.md index 2519e40..d1e43ee 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,18 @@ A source that can stream data from any version of the Open Ephys Acquisition Board, plus a sink that can trigger board outputs. +## Installation + +This plugin can be added via the Open Ephys GUI Plugin Installer. To access the Plugin Installer, press **ctrl-P** or **⌘P** from inside the GUI. Once the installer is loaded, browse to the "Acquisition Board" plugin and click "Install." + +## Usage + +Instructions for using the Acquisition Board plugin are available [here](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/Acquisition-Board.html). + ## Building from source First, follow the instructions on [this page](https://open-ephys.github.io/gui-docs/Developer-Guide/Compiling-the-GUI.html) to build the Open Ephys GUI. -**Important:** This plugin is intended for use with a preview of GUI version 1.0. The GUI should be compiled from the [`development-juce8`](https://github.com/open-ephys/plugin-gui/tree/development-juce8) branch, rather than the `main` branch. - Then, clone this repository into a directory at the same level as the `plugin-GUI`, e.g.: ``` @@ -23,6 +29,12 @@ Code │ └── ... ``` +When first cloning the repository, use `git clone --recurse-submodules` to fetch +the `liboni` submodule as well. + +For existing clones of the repo, run `git submodule update --init --recursive` +to initialize the submodule and update it in the same command. + ### Windows **Requirements:** [Visual Studio](https://visualstudio.microsoft.com/) and [CMake](https://cmake.org/install/) diff --git a/Source/OpenEphysLib.cpp b/Source/OpenEphysLib.cpp index cb4e1a5..a0c4515 100644 --- a/Source/OpenEphysLib.cpp +++ b/Source/OpenEphysLib.cpp @@ -41,7 +41,7 @@ extern "C" EXPORT void getLibInfo(Plugin::LibraryInfo* info) { info->apiVersion = PLUGIN_API_VER; info->name = "Acquisition Board"; - info->libVersion = "1.1.6"; + info->libVersion = "2.0.0"; info->numPlugins = NUM_PLUGINS; } diff --git a/Source/devices/oni/AcqBoardONI.cpp b/Source/devices/oni/AcqBoardONI.cpp index 3e0da46..b5c557a 100644 --- a/Source/devices/oni/AcqBoardONI.cpp +++ b/Source/devices/oni/AcqBoardONI.cpp @@ -147,29 +147,15 @@ bool AcqBoardONI::detectBoard() { LOGC ("Open Ephys ECP5-ONI FPGA open. Gateware version v", major, ".", minor, ".", patch); } - hasI2cSupport = major >= 1 && minor >= 5; - hasMemoryMonitorSupport = major >= 1 && minor >= 5 && patch >= 1; + hasI2cSupport = CheckSemVer (major, minor, patch, 1, 5, 0); + hasMemoryMonitorSupport = CheckSemVer (major, minor, patch, 1, 5, 1); if (major == 0) { - AlertWindow alert ("Update Gateware Version", - "Warning: The detected version of the gateware is v" - + std::to_string (major) + "." + std::to_string (minor) + "." + std::to_string (patch) - + ", and should be updated to the latest version." - + "\n\nTo learn how to update the gateware, please click on the link below.", - MessageBoxIconType::WarningIcon); - - auto hyperlink = std::make_unique ("Update Gateware", URL ("https://open-ephys.github.io/acq-board-docs/User-Manual/Gateware-Update.html")); - hyperlink->setName (""); - hyperlink->setSize (127, 20); - hyperlink->setJustificationType (Justification::centred); - hyperlink->setColour (HyperlinkButton::ColourIds::textColourId, Colours::deepskyblue); - - alert.addCustomComponent (hyperlink.get()); - - alert.addButton ("Okay", 0); - - alert.runModalLoop(); + ShowFirmwareUpdateMessage ("Warning: The detected version of the gateware is v" + + std::to_string (major) + "." + std::to_string (minor) + "." + std::to_string (patch) + + ", and should be updated to the latest version." + + "\n\nTo learn how to update the gateware, please click on the link below."); } } oni_reg_val_t tmpId; @@ -204,6 +190,12 @@ bool AcqBoardONI::detectBoard() { LOGC ("No ONI Acquisition Board found."); } + else if (return_code == -3) + { + ShowFirmwareUpdateMessage ("Warning: The gateware on the acquisition board is not compatible with" + " this version of the plugin and needs to be updated to version 2.0.0 or greater." + "\n\nTo learn how to update the gateware, please click on the link below."); + } deviceFound = false; return false; } @@ -2177,3 +2169,40 @@ bool AcqBoardONI::getMemoryMonitorSupport() const { return hasMemoryMonitorSupport; } + +bool AcqBoardONI::CheckSemVer (int major, int minor, int patch, int targetMajor, int targetMinor, int targetPatch) +{ + if (major > targetMajor) + return true; + else if (major < targetMajor) + return false; + + if (minor > targetMinor) + return true; + else if (minor < targetMinor) + return false; + + if(patch >= targetPatch) + return true; + + return false; +} + +void AcqBoardONI::ShowFirmwareUpdateMessage (std::string message) +{ + AlertWindow alert ("Update Gateware Version", + message, + MessageBoxIconType::WarningIcon); + + auto hyperlink = std::make_unique ("Update Gateware", URL ("https://open-ephys.github.io/acq-board-docs/User-Manual/Gateware-Update.html")); + hyperlink->setName (""); + hyperlink->setSize (127, 20); + hyperlink->setJustificationType (Justification::centred); + hyperlink->setColour (HyperlinkButton::ColourIds::textColourId, Colours::deepskyblue); + + alert.addCustomComponent (hyperlink.get()); + + alert.addButton ("Okay", 0); + + alert.runModalLoop(); +} \ No newline at end of file diff --git a/Source/devices/oni/AcqBoardONI.h b/Source/devices/oni/AcqBoardONI.h index dee2ce8..6e8d02b 100644 --- a/Source/devices/oni/AcqBoardONI.h +++ b/Source/devices/oni/AcqBoardONI.h @@ -364,6 +364,9 @@ class AcqBoardONI : public AcquisitionBoard DataBuffer* memBuffer = nullptr; Array bnoBuffers; + + static bool CheckSemVer (int major, int minor, int patch, int targetMajor, int targetMinor, int targetPatch); + static void ShowFirmwareUpdateMessage (std::string message); }; #endif diff --git a/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp b/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp index 8d0ac7a..f1ed1a6 100644 --- a/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp +++ b/Source/devices/oni/rhythm-api/rhd2000ONIboard.cpp @@ -43,11 +43,15 @@ int Rhd2000ONIBoard::open (const oni_driver_info_t** driverInfo) if (driverInfo) getONIDriverInfo (driverInfo); - if (oni_init_ctx (ctx, -1) != ONI_ESUCCESS) + int res = oni_init_ctx (ctx, -1); + if (res != ONI_ESUCCESS) { oni_destroy_ctx (ctx); ctx = nullptr; - return -2; + if (res == ONI_EBADCONTROLLER) + return -3; + else + return -2; } return 1; diff --git a/libONI/include/oni.h b/libONI/include/oni.h deleted file mode 100644 index 1890abc..0000000 --- a/libONI/include/oni.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef __ONI_H__ -#define __ONI_H__ - -// Version macros for compile-time API version detection -// NB: see https://semver.org/ -#define ONI_VERSION_MAJOR 4 -#define ONI_VERSION_MINOR 3 -#define ONI_VERSION_PATCH 12 - -#define ONI_MAKE_VERSION(major, minor, patch) \ - ((major) * 10000 + (minor) * 100 + (patch)) -#define ONI_VERSION \ - ONI_MAKE_VERSION(ONI_VERSION_MAJOR, ONI_VERSION_MINOR, ONI_VERSION_PATCH) - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -// OS-specific definitions -#ifdef _WIN32 -#ifdef LIBONI_EXPORTS -#define ONI_EXPORT __declspec(dllexport) -#else -#define ONI_EXPORT -#endif -#else -#define ONI_EXPORT -#endif - -#include "onidefs.h" - -// Acquisition context -typedef struct oni_ctx_impl *oni_ctx; - -// Device type -typedef struct { - // NB: Block read so don't change order - oni_size_t idx; // Complete rsv.rsv.hub.idx device table index - oni_dev_id_t id; // Device ID number - oni_size_t version; // Device firmware version - oni_size_t read_size; // Device data read size per frame in bytes - oni_size_t write_size; // Device data write size per frame in bytes - -} oni_device_t; - -// Frame type -typedef struct { - const oni_fifo_time_t time; // Frame time (ACQCLKHZ) - const oni_fifo_dat_t dev_idx; // Device index that produced or accepts the frame - const oni_fifo_dat_t data_sz; // Size in bytes of data buffer - char *data; // Raw data block - -} oni_frame_t; - -// Context management -ONI_EXPORT oni_ctx oni_create_ctx(const char *drv_name); -ONI_EXPORT int oni_init_ctx(oni_ctx ctx, int host_idx); -ONI_EXPORT int oni_destroy_ctx(oni_ctx ctx); - -// Context option getting/setting -ONI_EXPORT int oni_get_opt(const oni_ctx ctx, int ctx_opt, void *value, size_t *size); -ONI_EXPORT int oni_set_opt(oni_ctx ctx, int ctx_opt, const void *value, size_t size); - -// Driver option getting/setting -ONI_EXPORT int oni_get_driver_opt(const oni_ctx ctx, int drv_opt, void *value, size_t *size); -ONI_EXPORT int oni_set_driver_opt(oni_ctx ctx, int drv_opt, const void *value, size_t size); - -// Hardware inspection, manipulation, and IO -ONI_EXPORT int oni_read_reg(const oni_ctx ctx, oni_dev_idx_t dev_idx, oni_reg_addr_t addr, oni_reg_val_t *value); -ONI_EXPORT int oni_write_reg(const oni_ctx ctx, oni_dev_idx_t dev_idx, oni_reg_addr_t addr, oni_reg_val_t value); -ONI_EXPORT int oni_read_frame(const oni_ctx ctx, oni_frame_t **frame); -ONI_EXPORT int oni_create_frame(const oni_ctx ctx, oni_frame_t **frame, oni_dev_idx_t dev_idx, void *data, size_t data_sz); -ONI_EXPORT int oni_write_frame(const oni_ctx ctx, const oni_frame_t *frame); -ONI_EXPORT void oni_destroy_frame(oni_frame_t *frame); - -// Helpers -ONI_EXPORT void oni_version(int *major, int *minor, int *patch); -ONI_EXPORT const oni_driver_info_t* oni_get_driver_info(const oni_ctx ctx); -ONI_EXPORT const char *oni_error_str(int err); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libONI/include/onidefs.h b/libONI/include/onidefs.h deleted file mode 100644 index fb6eb7b..0000000 --- a/libONI/include/onidefs.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef __ONI_DEFS_H__ -#define __ONI_DEFS_H__ -#include - -// Frame header size in bytes -// NB: Header is [dev_idx, data_sz, time] -#define ONI_FRAMEHEADERSZ 2 * sizeof(oni_fifo_dat_t) + sizeof(oni_fifo_time_t) - -// Context options -enum { - ONI_OPT_DEVICETABLE = 0, - ONI_OPT_NUMDEVICES, - ONI_OPT_RUNNING, - ONI_OPT_RESET, - ONI_OPT_SYSCLKHZ, - ONI_OPT_ACQCLKHZ, - ONI_OPT_RESETACQCOUNTER, - ONI_OPT_HWADDRESS, - ONI_OPT_MAXREADFRAMESIZE, - ONI_OPT_MAXWRITEFRAMESIZE, - ONI_OPT_BLOCKREADSIZE, - ONI_OPT_BLOCKWRITESIZE, - ONI_OPT_CUSTOMBEGIN, -}; - -// NB: If you add an error here, make sure to update oni_error_str() in oni.c -enum { - ONI_ESUCCESS = 0, // Success - ONI_EPATHINVALID = -1, // Invalid stream path, fail on open - ONI_EDEVID = -2, // Invalid device ID - ONI_EDEVIDX = -3, // Invalid device index - ONI_EWRITESIZE = -4, // Data size is not an integer multiple of the write size for the designated device - ONI_EREADFAILURE = -5, // Failure to read from a stream/register - ONI_EWRITEFAILURE = -6, // Failure to write to a stream/register - ONI_ENULLCTX = -7, // Attempt to use a NULL context - ONI_ESEEKFAILURE = -8, // Failure to seek on stream - ONI_EINVALSTATE = -9, // Invalid operation for the current context run state - ONI_EINVALOPT = -10, // Invalid context option - ONI_EINVALARG = -11, // Invalid function arguments - ONI_ECOBSPACK = -12, // Invalid COBS packet - ONI_ERETRIG = -13, // Attempt to trigger an already triggered operation - ONI_EBUFFERSIZE = -14, // Supplied buffer is too small - ONI_EBADDEVTABLE = -15, // Badly formatted device table supplied by firmware - ONI_EBADALLOC = -16, // Bad dynamic memory allocation - ONI_ECLOSEFAIL = -17, // File descriptor close failure, check errno - ONI_EREADONLY = -18, // Attempted write to read only object (register, context option, etc) - ONI_EUNIMPL = -19, // Specified, but unimplemented, feature - ONI_EINVALREADSIZE = -20, // Block read size is smaller than the maximal read frame size - ONI_ENOREADDEV = -21, // Frame read attempted when there are no readable devices in the device table - ONI_EINIT = -22, // Hardware initialization failed - ONI_EWRITEONLY = -23, // Attempted to read from a write only object (register, context option, etc) - ONI_EINVALWRITESIZE = -24, // Write buffer pre-allocation size is smaller than the maximal write frame size - ONI_ENOTWRITEDEV = -25, // Frame allocation attempted for a non-writable device - ONI_EDEVIDXREPEAT = -26, // Device table contains repeated device indices - ONI_EPROTCONFIG = -27, // Attempted to directly read or write a protected configuration option - ONI_EBADFRAME = -28, // Received malformed frame - - // NB: Always at bottom - ONI_MINERRORNUM = -29 -}; - -// Registers available in the specification -typedef enum { - ONI_CONFIG_DEV_IDX = 0, - ONI_CONFIG_REG_ADDR, - ONI_CONFIG_REG_VALUE, - ONI_CONFIG_RW, - ONI_CONFIG_TRIG, - ONI_CONFIG_RUNNING, - ONI_CONFIG_RESET, - ONI_CONFIG_SYSCLKHZ, - ONI_CONFIG_ACQCLKHZ, - ONI_CONFIG_RESETACQCOUNTER, - ONI_CONFIG_HWADDRESS, - ONI_CONFIG_CUSTOMBEGIN, -} oni_config_t; - -// Fixed width device types -// TODO: I feel like oni.h and onidefs.h should only deal with standard signed -// or unsigned integer types and it should be the drivers' job to translate -// these to fixed width integers instead of having these typedefs -typedef uint32_t oni_size_t; -typedef uint32_t oni_dev_id_t; // Device IDs are 32-bit numbers -typedef uint32_t oni_dev_idx_t; // Device idx are 32-bit, byte.byte.btye.byte addresses -typedef uint32_t oni_reg_addr_t; // Registers use a 32-bit address -typedef uint32_t oni_reg_val_t; // Registers have 32-bit values -typedef uint32_t oni_fifo_dat_t; // FIFOs use 32-bit words; // TODO: find a way to remove -typedef uint64_t oni_fifo_time_t; // FIFO bound timers use 64-bit words; // TODO: find a way to remove - -#define BYTE_TO_FIFO_SHIFT 2; // TODO: find a way to remove - -// Register size -#define ONI_REGSZ sizeof(oni_reg_val_t) - -typedef struct { - const char *name; - const int major; - const int minor; - const int patch; - const char *pre_release; -} oni_driver_info_t; - -#endif diff --git a/libONI/linux/liboni.so b/libONI/linux/liboni.so deleted file mode 100755 index 27dc374..0000000 Binary files a/libONI/linux/liboni.so and /dev/null differ diff --git a/libONI/linux/libonidriver_ft600.so b/libONI/linux/libonidriver_ft600.so deleted file mode 100755 index d55b9b9..0000000 Binary files a/libONI/linux/libonidriver_ft600.so and /dev/null differ diff --git a/libONI/osx/liboni.dylib b/libONI/osx/liboni.dylib deleted file mode 100755 index f27bca0..0000000 Binary files a/libONI/osx/liboni.dylib and /dev/null differ diff --git a/libONI/osx/libonidriver_ft600.dylib b/libONI/osx/libonidriver_ft600.dylib deleted file mode 100755 index 3addfa0..0000000 Binary files a/libONI/osx/libonidriver_ft600.dylib and /dev/null differ diff --git a/libONI/win64/liboni.dll b/libONI/win64/liboni.dll deleted file mode 100644 index 0029027..0000000 Binary files a/libONI/win64/liboni.dll and /dev/null differ diff --git a/libONI/win64/liboni.lib b/libONI/win64/liboni.lib deleted file mode 100644 index 3115e1a..0000000 Binary files a/libONI/win64/liboni.lib and /dev/null differ diff --git a/libONI/win64/libonidriver_ft600.dll b/libONI/win64/libonidriver_ft600.dll deleted file mode 100644 index 8a50e4d..0000000 Binary files a/libONI/win64/libonidriver_ft600.dll and /dev/null differ diff --git a/liboni b/liboni new file mode 160000 index 0000000..5b7d755 --- /dev/null +++ b/liboni @@ -0,0 +1 @@ +Subproject commit 5b7d755962d0ef4a7b7b4017d1d020497537d054