11 static const unsigned int ID_MASK = (1u << 29)-1;
12 static const unsigned int EXTENDED_MASK = (1u << 29);
13 static const unsigned int NO_RTR_MASK = (1u << 30);
14 static const unsigned int INVALID_MASK = (1u << 31);
20 return can::Header(value_ & ID_MASK, value_ & EXTENDED_MASK, fill_rtr && !(value_ & NO_RTR_MASK),
false);
22 bool isInvalid()
const {
return value_ & INVALID_MASK; }
31 sub_index((val>>8) & 0xFF),
52 bool com_changed =
false;
55 for(uint8_t sub = 0; sub <=6 ; ++sub){
57 if(!dict(com_id,sub).init_val.is_empty()){
62 catch (std::out_of_range) {}
68 bool map_changed =
false;
72 for(uint8_t sub = 1; sub <=num ; ++sub){
74 if(!dict(map_index,sub).init_val.is_empty()){
79 catch (std::out_of_range) {}
82 map_changed = dict( map_index ,0 ).init_val.is_empty();
108 if((map_changed || com_changed) && cob_id.
desc().
writable){
111 if(map_num > 0 && map_num <= 0x40){
117 for(uint8_t sub = 1; sub <=map_num; ++sub){
119 storage->entry(mapentry, map_index, sub);
120 const HoldAny init = dict(map_index ,sub).init_val;
121 if(!
init.is_empty()) mapentry.
set(
init.get<uint32_t>());
125 if(param.
index < 0x1000){
132 rd = std::bind<void(Buffer::*)(const canopen::ObjectDict::Entry&, String&)>(&
Buffer::read, b.get(), std::placeholders::_1, std::placeholders::_2);
136 wd = std::bind<void(Buffer::*)(const canopen::ObjectDict::Entry&, const String&)>(&
Buffer::write, b.get(), std::placeholders::_1, std::placeholders::_2);
138 assert(l == param.
length/8);
149 uint8_t subs = dict(com_index,
SUB_COM_NUM).value().
get<uint8_t>();
155 catch (
const std::out_of_range &){
161 num_entry.
set(map_num);
163 if((com_changed || map_changed) && cob_id.
desc().
writable){
176 boost::mutex::scoped_lock lock(
mutex_);
205 catch(
const std::out_of_range &e){
206 status.
error(std::string(
"PDO error: ") + e.what());
213 boost::mutex::scoped_lock lock(
mutex);
234 boost::mutex::scoped_lock lock(mutex);
241 parse_and_set_mapping(storage, com_index, map_index,
false,
true);
242 if(buffers.empty() || pdoid.
isInvalid()){
249 if(transmission_type != 1 && transmission_type <=240){
256 boost::mutex::scoped_lock lock(mutex);
258 bool updated =
false;
259 size_t len = frame.dlc;
261 for(std::vector< BufferSharedPtr >::iterator b_it = buffers.begin(); b_it != buffers.end(); ++b_it){
264 updated = b.
read(dest, len) || updated;
283 boost::mutex::scoped_lock lock(mutex);
284 if((transmission_type >= 1 && transmission_type <= 240) || transmission_type == 0xFC){
287 }
else if(timeout == 0) {
288 status.
warn(
"RPDO timeout");
291 if(transmission_type == 0xFC || transmission_type == 0xFD){
300 const uint8_t * src = msg.
data.data();
301 for(std::vector<BufferSharedPtr >::iterator it = buffers.begin(); it != buffers.end(); ++it){
304 if( offset + b.
size <= msg.
dlc ){
311 if( offset != msg.
dlc ){
315 boost::mutex::scoped_lock lock(mutex);
316 if(transmission_type >= 1 && transmission_type <= 240){
317 timeout = transmission_type + 2;
318 }
else if(transmission_type == 0xFC || transmission_type == 0xFD){
327 boost::mutex::scoped_lock lock(
mutex_);
328 for(std::unordered_set<RPDO::RPDOSharedPtr >::iterator it =
rpdos_.begin(); it !=
rpdos_.end(); ++it){
333 boost::mutex::scoped_lock lock(
mutex_);
334 for(std::unordered_set<TPDO::TPDOSharedPtr >::iterator it =
tpdos_.begin(); it !=
tpdos_.end(); ++it){
341 boost::mutex::scoped_lock lock(mutex);
343 BOOST_THROW_EXCEPTION( std::bad_cast() );
345 if(empty)
return false;
347 memcpy(b,&buffer[0], size);
348 bool was_dirty = dirty;
353 boost::mutex::scoped_lock lock(mutex);
355 BOOST_THROW_EXCEPTION( std::bad_cast() );
359 memcpy(&buffer[0], b, size);
362 boost::mutex::scoped_lock lock(mutex);
364 if(size != data.size()){
371 data.assign(buffer.begin(), buffer.end());
376 boost::mutex::scoped_lock lock(mutex);
377 if(size != data.size()){
382 buffer.assign(data.begin(),data.end());