Skip to content

Commit

Permalink
Refactor Picoscope implementation (#147)
Browse files Browse the repository at this point in the history
Refactor Picoscope implementation

* Restrict Picoscope types to a few selected types. This restricts the possible output types to:
- std::int16_t
- float
- gr::UncertainValue<float>

* Generalize Picoscope interface. This allows the Block to be extended with support for various Picoscope
models. Furthermore, this ports the custom work implementation to processBulk()
and implements the inclusion of timing messages received over the
message port.

* Update to latest graph-prototype

* Picoscope: Redefine property_map constructor
This is needed as a workaround for very fishy behaviour, where GNURadio
tries to use an ill-formed copy-constructor.
Alternatively the BlockWrapper constructor could be patched to use
_block{{std::move(initParameter)}}, which forces direct
list-initialization.


---------

Signed-off-by: Magnus Groß <[email protected]>
Co-authored-by: drslebedev <[email protected]>
  • Loading branch information
vimpostor and drslebedev authored Jun 19, 2024
1 parent 0ad25d0 commit ba28ef2
Show file tree
Hide file tree
Showing 8 changed files with 1,006 additions and 597 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set(ENABLE_TESTING OFF)
FetchContent_Declare(
graph-prototype
GIT_REPOSITORY https://github.com/fair-acc/graph-prototype.git
GIT_TAG 5e15e8478d267a5e74fdd3b310a7483a690fe1b4 # main as of 2024-04-25
GIT_TAG 4b05d3059335d14e9fa2eb44b43bb37a4881409c # main as of 2024-06-18
)

FetchContent_Declare(
Expand Down
13 changes: 0 additions & 13 deletions blocklib/helpers/HelperBlocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,9 @@ struct VectorSink : public gr::Block<VectorSink<T>> {
}
};

template<typename T>
struct CountSink : public gr::Block<CountSink<T>> {
gr::PortIn<T> in;
std::size_t samples_seen = 0;

gr::work::Status
processBulk(std::span<const T> input) noexcept {
samples_seen += input.size();
return gr::work::Status::OK;
}
};

} // namespace fair::helpers

ENABLE_REFLECTION_FOR_TEMPLATE(fair::helpers::VectorSource, out, data);
ENABLE_REFLECTION_FOR_TEMPLATE(fair::helpers::VectorSink, in, data);
ENABLE_REFLECTION_FOR_TEMPLATE(fair::helpers::CountSink, in);

#endif
8 changes: 7 additions & 1 deletion blocklib/picoscope/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ set_property(TARGET ps4000a PROPERTY
target_link_libraries(ps4000a INTERFACE PkgConfig::zlib PkgConfig::libusb)
target_include_directories(ps4000a INTERFACE ${PICOSCOPE_PREFIX}/include/libps4000a ${PICOSCOPE_PREFIX}/include/libps5000a) # Hack: PicoCallback.h is missing in libps4000a/

add_library(ps5000a SHARED IMPORTED GLOBAL)
set_property(TARGET ps5000a PROPERTY
IMPORTED_LOCATION ${PICOSCOPE_PREFIX}/lib/libps5000a.so)
target_link_libraries(ps5000a INTERFACE PkgConfig::zlib PkgConfig::libusb)
target_include_directories(ps5000a INTERFACE ${PICOSCOPE_PREFIX}/include/libps5000a)

add_library(fair-picoscope INTERFACE)
target_include_directories(fair-picoscope INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/>)

target_link_libraries(fair-picoscope INTERFACE ps4000a gr-digitizers-options gnuradio-core refl-cpp fmt)
target_link_libraries(fair-picoscope INTERFACE ps4000a ps5000a gr-digitizers-options gnuradio-core refl-cpp fmt)
set_target_properties(gr-digitizers PROPERTIES PUBLIC_HEADER "Picoscope.hpp;Picoscope4000a.hpp;StatusMessages.hpp")

if (ENABLE_GR_DIGITIZERS_TESTING)
Expand Down
Loading

0 comments on commit ba28ef2

Please sign in to comment.