Skip to content

Commit

Permalink
Merge pull request IntelRealSense#5043 from ev-mp/raspbian_buster_wip
Browse files Browse the repository at this point in the history
Raspbian buster - Cleanup
  • Loading branch information
dorodnic authored Oct 23, 2019
2 parents 79acc57 + a68ded7 commit fb5dfec
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 190 deletions.
2 changes: 1 addition & 1 deletion CMake/android_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ macro(os_set_flags)
set(BUILD_WITH_OPENMP OFF)
set(BUILD_GRAPHICAL_EXAMPLES OFF)
set(ANDROID_STL "c++_static")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pedantic -g -D_BSD_SOURCE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pedantic -g -D_DEFAULT_SOURCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pedantic -g -Wno-missing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-multichar")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
Expand Down
6 changes: 3 additions & 3 deletions CMake/unix_config.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
message(STATUS "Setting Unix configurations")

macro(os_set_flags)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pedantic -g -D_BSD_SOURCE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pedantic -g -D_DEFAULT_SOURCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pedantic -g -Wno-missing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-multichar -Wsequence-point -Wformat -Wformat-security")

execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE MACHINE)
if(${MACHINE} MATCHES "arm-linux-gnueabihf")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -mfloat-abi=hard -ftree-vectorize")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -mfloat-abi=hard -ftree-vectorize")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -mfloat-abi=hard -ftree-vectorize -latomic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -mfloat-abi=hard -ftree-vectorize -latomic")
elseif(${MACHINE} MATCHES "aarch64-linux-gnu")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mstrict-align -ftree-vectorize")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstrict-align -ftree-vectorize")
Expand Down
2 changes: 1 addition & 1 deletion examples/C/depth/rs-depth.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int main()
exit(EXIT_FAILURE);
}

const rs2_stream_profile* stream_profile = rs2_get_stream_profile(stream_profile_list, 0, &e);
rs2_stream_profile* stream_profile = (rs2_stream_profile*)rs2_get_stream_profile(stream_profile_list, 0, &e);
if (e)
{
printf("Failed to create stream profile!\n");
Expand Down
2 changes: 1 addition & 1 deletion src/ds5/ds5-motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ namespace librealsense
auto hid_ep = create_hid_device(ctx, group.hid_devices, _fw_version);
if (hid_ep)
{
_motion_module_device_idx = add_sensor(hid_ep);
_motion_module_device_idx = static_cast<uint8_t>(add_sensor(hid_ep));

std::function<void(rs2_stream stream, frame_interface* fr, callback_invocation_holder callback)> align_imu_axes = nullptr;

Expand Down
14 changes: 7 additions & 7 deletions src/hid/hid-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace librealsense
if(info.cls != RS2_USB_CLASS_HID)
continue;
platform::hid_device_info device_info;
device_info.vid = info.vid;
device_info.pid = info.pid;
device_info.vid = hexify(info.vid);
device_info.pid = hexify(info.pid);
device_info.unique_id = info.unique_id;
device_info.device_path = info.unique_id;//the device unique_id is the USB port

Expand Down Expand Up @@ -117,15 +117,15 @@ namespace librealsense

void rs_hid_device::poll_for_interrupt()
{
unsigned char buffer[SIZE_OF_FRAME];
unsigned char buffer[SIZE_OF_HID_IMU_FRAME];
uint32_t bytesRead;

auto ep = get_hid_endpoint();
auto res = _messenger->bulk_transfer(ep, buffer, sizeof(buffer), bytesRead, 10);

if (res == RS2_USB_STATUS_SUCCESS)
{
REALSENSE_HID_REPORT report = *(REALSENSE_HID_REPORT*)buffer;
REALSENSE_HID_REPORT report = *(reinterpret_cast<REALSENSE_HID_REPORT*>(buffer));
_queue.enqueue(std::move(report));
}
}
Expand All @@ -142,10 +142,10 @@ namespace librealsense

})!= _configured_profiles.end())
{
sensor_data data;
sensor_data data{};
data.sensor = {_id_to_sensor[report.reportId]};

hid_data hid;
hid_data hid{};
hid.x = report.x;
hid.y = report.y;
hid.z = report.z;
Expand Down Expand Up @@ -253,4 +253,4 @@ namespace librealsense
return ep;
}
}
}
}
91 changes: 47 additions & 44 deletions src/hid/hid-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define REPORT_ID_GYROMETER_3D 2
#define REPORT_ID_CUSTOM 3

#define SIZE_OF_FRAME 32
const size_t SIZE_OF_HID_IMU_FRAME = 32;

static std::string gyro = "gyro_3d";
static std::string accel = "accel_3d";
Expand Down Expand Up @@ -56,10 +56,10 @@ namespace librealsense
struct REALSENSE_HID_REPORT {
unsigned char reportId;
unsigned char unknown;
unsigned long timeStamp;
unsigned short x;
unsigned short y;
unsigned short z;
unsigned long long timeStamp;
short x;
short y;
short z;
unsigned int customValue1;
unsigned int customValue2;
unsigned short customValue3;
Expand All @@ -68,50 +68,53 @@ namespace librealsense
unsigned char customValue6;
unsigned char customValue7;
};

#pragma pack(pop)
static_assert(sizeof(REALSENSE_HID_REPORT) == SIZE_OF_HID_IMU_FRAME, "HID IMU Frame struct expected size is 32 bytes");

struct hid_device_info
{
std::string id;
std::string vid;
std::string pid;
std::string unique_id;
std::string device_path;
std::string serial_number;

operator std::string()
{
std::stringstream s;
s << "id- " << id <<
"\nvid- " << std::hex << vid <<
"\npid- " << std::hex << pid <<
"\nunique_id- " << unique_id <<
"\npath- " << device_path;

return s.str();
}
};

inline bool operator==(const hid_device_info& a,
const hid_device_info& b)
struct hid_device_info
{
std::string id;
std::string vid;
std::string pid;
std::string unique_id;
std::string device_path;
std::string serial_number;

operator std::string()
{
return (a.id == b.id) &&
(a.vid == b.vid) &&
(a.pid == b.pid) &&
(a.unique_id == b.unique_id) &&
(a.device_path == b.device_path);
std::stringstream s;
s << "id- " << id <<
"\nvid- " << std::hex << vid <<
"\npid- " << std::hex << pid <<
"\nunique_id- " << unique_id <<
"\npath- " << device_path;

return s.str();
}
};

inline bool operator==(const hid_device_info& a,
const hid_device_info& b)
{
return (a.id == b.id) &&
(a.vid == b.vid) &&
(a.pid == b.pid) &&
(a.unique_id == b.unique_id) &&
(a.device_path == b.device_path);
}

#pragma pack(push, 1)
struct FEATURE_REPORT
{
unsigned char reportId;
unsigned char connectionType;
unsigned char sensorState;
unsigned char power;
unsigned char minReport;
unsigned short report;
unsigned short unknown;
};
struct FEATURE_REPORT
{
unsigned char reportId;
unsigned char connectionType;
unsigned char sensorState;
unsigned char power;
unsigned char minReport;
unsigned short report;
unsigned short unknown;
};
#pragma pack(pop)
}
}
28 changes: 13 additions & 15 deletions src/libusb/device-libusb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
// Copyright(c) 2015 Intel Corporation. All Rights Reserved.

#include "device-libusb.h"
#include "endpoint-libusb.h"
#include "interface-libusb.h"
#include "types.h"

#include <string>
#include <regex>
#include <sstream>
#include <mutex>

namespace librealsense
{
Expand All @@ -18,18 +12,22 @@ namespace librealsense
usb_device_libusb::usb_device_libusb(libusb_device* device, const libusb_device_descriptor& desc, const usb_device_info& info) :
_device(device), _usb_device_descriptor(desc), _info(info)
{
for (ssize_t c = 0; c < desc.bNumConfigurations; ++c)
for (uint8_t c = 0; c < desc.bNumConfigurations; ++c)
{
libusb_config_descriptor *config;
auto rc = libusb_get_config_descriptor(device, c, &config);

for (ssize_t i = 0; i < config->bNumInterfaces; ++i)
libusb_config_descriptor *config{};
auto ret = libusb_get_config_descriptor(device, c, &config);
if (LIBUSB_SUCCESS==ret)
{
auto inf = config->interface[i];
_interfaces.push_back(std::make_shared<usb_interface_libusb>(inf));
}
for (uint8_t i = 0; i < config->bNumInterfaces; ++i)
{
auto inf = config->interface[i];
_interfaces.push_back(std::make_shared<usb_interface_libusb>(inf));
}

libusb_free_config_descriptor(config);
libusb_free_config_descriptor(config);
}
else
LOG_WARNING("failed to read USB config descriptor: error = " << std::dec << ret);
}
}

Expand Down
9 changes: 0 additions & 9 deletions src/libusb/device-libusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@

#pragma once

#include "usb/usb-types.h"
#include "messenger-libusb.h"
#include "usb/usb-device.h"

#include <string>
#include <regex>
#include <sstream>
#include <mutex>

#include <libusb.h>

namespace librealsense
{
Expand Down
Loading

0 comments on commit fb5dfec

Please sign in to comment.