Skip to content

Commit

Permalink
fix #30
Browse files Browse the repository at this point in the history
  • Loading branch information
tmori committed Mar 8, 2024
1 parent efe120f commit 657d1f6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/hako/hako_asset_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,27 @@ bool hako::HakoAssetControllerImpl::read_pdu(const std::string& asset_name, cons
return this->master_data_->get_pdu_data()->read_pdu(asset->id, channel_id, pdu_data, len);
}
}
bool hako::HakoAssetControllerImpl::write_pdu_nolock(const std::string& robo_name, HakoPduChannelIdType channel_id, const char *pdu_data, size_t len)
{
HakoPduChannelIdType real_id = this->master_data_->get_pdu_data()->get_pdu_channel(robo_name, channel_id);
if (real_id >= 0) {
return this->master_data_->get_pdu_data()->write_pdu_nolock(real_id, pdu_data, len);
}
else {
return false;
}
}

bool hako::HakoAssetControllerImpl::read_pdu_nolock(const std::string& robo_name, HakoPduChannelIdType channel_id, char *pdu_data, size_t len)
{
HakoPduChannelIdType real_id = this->master_data_->get_pdu_data()->get_pdu_channel(robo_name, channel_id);
if (real_id >= 0) {
return this->master_data_->get_pdu_data()->read_pdu_nolock(real_id, pdu_data, len);
}
else {
return false;
}
}

void hako::HakoAssetControllerImpl::notify_read_pdu_done(const std::string& asset_name)
{
Expand Down
3 changes: 3 additions & 0 deletions src/hako/hako_asset_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ namespace hako {
bool is_simulation_mode();
bool is_pdu_created();

bool write_pdu_nolock(const std::string& robo_name, HakoPduChannelIdType channel_id, const char *pdu_data, size_t len);
bool read_pdu_nolock(const std::string& robo_name, HakoPduChannelIdType channel_id, char *pdu_data, size_t len);

private:
HakoAssetControllerImpl() {}
bool feedback(const std::string& asset_name, bool isOk, HakoSimulationStateType exp_state);
Expand Down
2 changes: 2 additions & 0 deletions src/include/hako_asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ namespace hako {
virtual bool is_simulation_mode() = 0;
virtual bool is_pdu_created() = 0;

virtual bool write_pdu_nolock(const std::string& robo_name, HakoPduChannelIdType channel_id, const char *pdu_data, size_t len) = 0;
virtual bool read_pdu_nolock(const std::string& robo_name, HakoPduChannelIdType channel_id, char *pdu_data, size_t len) = 0;
//TODO
//get asset lists

Expand Down

0 comments on commit 657d1f6

Please sign in to comment.