User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
code:sub2r-lib [2022/08/22 20:16] – [Windows] Igor Yefmovcode:sub2r-lib [2022/08/30 18:42] – [byte_span] Igor Yefmov
Line 10: Line 10:
 The library is built using MSVC 2022 version ''17.3.1'' with Windows SDK ''10.0.19041.0'' for use with ''UNICODE'' and ''multi-threaded'' CRT in ''64-bit'' and ''32-bit'' mode. The library requires a C++20 toolchain to be built. The library is built using MSVC 2022 version ''17.3.1'' with Windows SDK ''10.0.19041.0'' for use with ''UNICODE'' and ''multi-threaded'' CRT in ''64-bit'' and ''32-bit'' mode. The library requires a C++20 toolchain to be built.
  
-===== byte_span ===== +===== Basic "vendor request" call =====
-Beginning with version ''2018-09-05'' the code relies on [[https://github.com/Microsoft/GSL|Guidelines Support Library]] (GSL). Part of that change is to use ''gsl::span<std::byte>'' to represent raw byte buffers. +
- +
-Quite often a need arises to represent "simple" data types (like ''uint32_t'') as a byte buffer when using hardware API. To reduce the potential for stupid bugs and make code more readable it is recommended to use the provided <code c++>template<class T> gsl::span<std::byte> byte_span(T& _x) noexcept;</code> function when such a buffer's address is needed. +
- +
-All the library's methods were updated to conform to this calling convention.+
  
 Sample usage: Sample usage:
Line 21: Line 16:
 using S2R::FX3; using S2R::FX3;
 FX3 fx3; // by default opens device #0 FX3 fx3; // by default opens device #0
-if(fx3){ +if(fx3.isValid()){ 
-    uint32_t vi{};+    array<std::byte, 4> vi{};
     const auto rc{m_fx3.vrCmd(Fx3Cmd::fx3_version // vendor request command     const auto rc{m_fx3.vrCmd(Fx3Cmd::fx3_version // vendor request command
                               , VrCmdOpType::read // read from device                               , VrCmdOpType::read // read from device
                               , 0                 // "value"                               , 0                 // "value"
                               , 0                 // "index"                               , 0                 // "index"
-                              , byte_span(vi))};  // buffer to read into+                              , vi)};             // buffer to read into
     return vi;                                    // 32 bits of the "version info" (4 bytes)     return vi;                                    // 32 bits of the "version info" (4 bytes)
 } }

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information