Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aangerma committed Feb 6, 2020
1 parent 04ad58f commit 82fa70e
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 17 deletions.
2 changes: 1 addition & 1 deletion common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace rs400;
using namespace nlohmann;


rs2_sensor_mode resolution_from_width_height(int width, int height)
static rs2_sensor_mode resolution_from_width_height(int width, int height)
{
if ((width == 640 && height == 480) || (height == 640 && width == 480))
return RS2_SENSOR_MODE_VGA;
Expand Down
2 changes: 1 addition & 1 deletion include/librealsense2/h/rs_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void rs2_set_calibration_table(const rs2_device* device, const void* calibration
rs2_raw_data_buffer* rs2_serialize_json(rs2_device* dev, rs2_error** error);

/* Load JSON and apply advanced-mode controls */
void rs2_load_json(rs2_device* dev, const void* json_content, unsigned content_size, rs2_error** error);
void rs2_load_json(rs2_device* dev, const char* json_content, unsigned content_size, rs2_error** error);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ extern "C" {
RS2_OPTION_ZERO_ORDER_ENABLED, /**< Toggle Zero-Order mode */
RS2_OPTION_ENABLE_MAP_PRESERVATION, /**< Preserve previous map when starting */
RS2_OPTION_FREEFALL_DETECTION_ENABLED, /**< Enable/disable sensor shutdown when a free-fall is detected (on by default) */
RS2_OPTION_AVALANCHE_PHOTO_DIODE, /**< Changes the exposure time of Avalanche Photo Diode in the receiver */
RS2_OPTION_POST_PROCESSING_SHARPENING, /**< Changes the amount of sharpening in the post-processed image */
RS2_OPTION_PRE_PROCESSING_SHARPENING, /**< Changes the amount of sharpening in the pre-processed image */
RS2_OPTION_NOISE_FILTERING, /**< Control edges and background noise */
Expand Down
2 changes: 1 addition & 1 deletion src/l500/l500-depth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ namespace librealsense
if (preset_option.query() == RS2_L500_VISUAL_PRESET_CUSTOM)
{
if(sensor_mode_option.query() != get_resolution_from_width_height(vs->get_width(), vs->get_height()))
throw std::runtime_error(to_string() << "sensor mode option ("<< sensor_mode_option.query()<<") is incompatible with requsted resolution ("
throw std::runtime_error(to_string() << "sensor mode option ("<< sensor_mode_option.query()<<") is incompatible with requested resolution ("
<< get_resolution_from_width_height(vs->get_width(), vs->get_height())<<")");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/l500/l500-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace librealsense
public l500_options,
public l500_color,
public l500_motion,
public l500_serializable_base
public l500_serializable
{
public:
rs515_device(std::shared_ptr<context> ctx,
Expand All @@ -39,7 +39,7 @@ namespace librealsense
l500_options(ctx, group),
l500_color(ctx, group),
l500_motion(ctx, group),
l500_serializable_base(_hw_monitor, get_depth_sensor())
l500_serializable(_hw_monitor, get_depth_sensor())
{}

std::shared_ptr<matcher> create_matcher(const frame_holder& frame) const override;
Expand Down
23 changes: 19 additions & 4 deletions src/l500/l500-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ namespace librealsense

auto def = query(_resolution->query());

_range = option_range{ float(*(reinterpret_cast<int*>(min.data()))),
float(*(reinterpret_cast<int*>(max.data()))),
float(*(reinterpret_cast<int*>(step.data()))),
if (min.size() < sizeof(int32_t) || max.size() < sizeof(int32_t) || step.size() < sizeof(int32_t))
{
std::stringstream s;
s << "Size of data returned is not valid min size = " << min.size() << ", max size = " << max.size() << ", step size = " << step.size();
throw std::runtime_error(s.str());
}

_range = option_range{ float(*(reinterpret_cast<int32_t*>(min.data()))),
float(*(reinterpret_cast<int32_t*>(max.data()))),
float(*(reinterpret_cast<int32_t*>(step.data()))),
def };
}

Expand All @@ -49,7 +56,15 @@ namespace librealsense
float l500_hw_options::query(int mode) const
{
auto res = _hw_monitor->send(command{ AMCGET, _type, get_current, mode });
auto val = *(reinterpret_cast<int*>((void*)res.data()));

if (res.size() < sizeof(int32_t))
{
std::stringstream s;
s << "Size of data returned is not valid min size = " << res.size();
throw std::runtime_error(s.str());
}

auto val = *(reinterpret_cast<int32_t*>((void*)res.data()));
return val;
}

Expand Down
6 changes: 3 additions & 3 deletions src/l500/l500-serializable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace librealsense
{
using json = nlohmann::json;

l500_serializable_base::l500_serializable_base(std::shared_ptr<hw_monitor> hw_monitor, synthetic_sensor & depth_sensor)
l500_serializable::l500_serializable(std::shared_ptr<hw_monitor> hw_monitor, synthetic_sensor & depth_sensor)
:_hw_monitor_ptr(hw_monitor),
_depth_sensor(depth_sensor)
{
}

std::vector<uint8_t> l500_serializable_base::serialize_json() const
std::vector<uint8_t> l500_serializable::serialize_json() const
{
json j;
auto options = _depth_sensor.get_supported_options();
Expand All @@ -30,7 +30,7 @@ namespace librealsense
return std::vector<uint8_t>(str.begin(), str.end());
}

void l500_serializable_base::load_json(const std::string& json_content)
void l500_serializable::load_json(const std::string& json_content)
{
json j = json::parse(json_content);

Expand Down
4 changes: 2 additions & 2 deletions src/l500/l500-serializable.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace librealsense
{
class l500_serializable_base : public serializable_interface
class l500_serializable : public serializable_interface
{
public:
l500_serializable_base(std::shared_ptr<hw_monitor> hw_monitor, synthetic_sensor& depth_sensor);
l500_serializable(std::shared_ptr<hw_monitor> hw_monitor, synthetic_sensor& depth_sensor);
std::vector<uint8_t> serialize_json() const override;
void load_json(const std::string& json_content) override;

Expand Down
4 changes: 2 additions & 2 deletions src/rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2834,11 +2834,11 @@ rs2_raw_data_buffer* rs2_serialize_json(rs2_device* dev, rs2_error** error) BEGI
}
HANDLE_EXCEPTIONS_AND_RETURN(nullptr, dev)

void rs2_load_json(rs2_device* dev, const void* json_content, unsigned content_size, rs2_error** error) BEGIN_API_CALL
void rs2_load_json(rs2_device* dev, const char* json_content, unsigned content_size, rs2_error** error) BEGIN_API_CALL
{
VALIDATE_NOT_NULL(dev);
VALIDATE_NOT_NULL(json_content);
auto serializable = VALIDATE_INTERFACE(dev->device, librealsense::serializable_interface);
serializable->load_json(std::string(static_cast<const char*>(json_content), content_size));
serializable->load_json(json_content);
}
HANDLE_EXCEPTIONS_AND_RETURN(, dev, json_content, content_size)
2 changes: 1 addition & 1 deletion src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ namespace librealsense
CASE(LED_POWER)
CASE(ZERO_ORDER_ENABLED)
CASE(ENABLE_MAP_PRESERVATION)
CASE(FREEFALL_DETECTION_ENABLED)
CASE(FREEFALL_DETECTION_ENABLED)
CASE(AVALANCHE_PHOTO_DIODE)
CASE(POST_PROCESSING_SHARPENING)
CASE(PRE_PROCESSING_SHARPENING)
Expand Down

0 comments on commit 82fa70e

Please sign in to comment.