Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UAVCAN UAVCAN_Subscriber
uc_generic_publisher.cpp
00001 /* 00002 * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com> 00003 */ 00004 00005 #include <uavcan/node/generic_publisher.hpp> 00006 00007 namespace uavcan 00008 { 00009 00010 bool GenericPublisherBase::isInited() const 00011 { 00012 return sender_.isInitialized(); 00013 } 00014 00015 int GenericPublisherBase::doInit(DataTypeKind dtkind, const char* dtname, CanTxQueue::Qos qos) 00016 { 00017 if (isInited()) 00018 { 00019 return 0; 00020 } 00021 00022 GlobalDataTypeRegistry::instance().freeze(); 00023 00024 const DataTypeDescriptor* const descr = GlobalDataTypeRegistry::instance().find(dtkind, dtname); 00025 if (descr == UAVCAN_NULLPTR) 00026 { 00027 UAVCAN_TRACE("GenericPublisher", "Type [%s] is not registered", dtname); 00028 return -ErrUnknownDataType; 00029 } 00030 00031 sender_.init(*descr, qos); 00032 00033 return 0; 00034 } 00035 00036 MonotonicTime GenericPublisherBase::getTxDeadline() const 00037 { 00038 return node_.getMonotonicTime() + tx_timeout_; 00039 } 00040 00041 int GenericPublisherBase::genericPublish(const StaticTransferBufferImpl& buffer, TransferType transfer_type, 00042 NodeID dst_node_id, TransferID* tid, MonotonicTime blocking_deadline) 00043 { 00044 if (tid) 00045 { 00046 return sender_.send(buffer.getRawPtr(), buffer.getMaxWritePos(), getTxDeadline(), 00047 blocking_deadline, transfer_type, dst_node_id, *tid); 00048 } 00049 else 00050 { 00051 return sender_.send(buffer.getRawPtr(), buffer.getMaxWritePos(), getTxDeadline(), 00052 blocking_deadline, transfer_type, dst_node_id); 00053 } 00054 } 00055 00056 void GenericPublisherBase::setTxTimeout(MonotonicDuration tx_timeout) 00057 { 00058 tx_timeout = max(tx_timeout, getMinTxTimeout()); 00059 tx_timeout = min(tx_timeout, getMaxTxTimeout()); 00060 tx_timeout_ = tx_timeout; 00061 } 00062 00063 }
Generated on Tue Jul 12 2022 17:17:35 by
