2021-09-26 08:29:30 +02:00
|
|
|
#include "VirtualChannel.h"
|
2021-09-22 16:54:55 +02:00
|
|
|
|
2023-03-09 17:44:05 +01:00
|
|
|
VirtualChannel::VirtualChannel(object_id_t objectId, uint8_t vcId, const char* vcName, PtmeIF& ptme,
|
|
|
|
const std::atomic_bool& linkStateProvider)
|
|
|
|
: SystemObject(objectId),
|
2023-03-09 19:42:20 +01:00
|
|
|
ptme(ptme),
|
2023-03-09 17:44:05 +01:00
|
|
|
vcId(vcId),
|
|
|
|
vcName(vcName),
|
|
|
|
linkStateProvider(linkStateProvider) {}
|
|
|
|
|
|
|
|
ReturnValue_t VirtualChannel::initialize() { return returnvalue::OK; }
|
|
|
|
|
|
|
|
ReturnValue_t VirtualChannel::sendNextTm(const uint8_t* data, size_t size) {
|
|
|
|
return write(data, size);
|
2021-09-22 16:54:55 +02:00
|
|
|
}
|
|
|
|
|
2023-03-09 17:44:05 +01:00
|
|
|
ReturnValue_t VirtualChannel::write(const uint8_t* data, size_t size) {
|
|
|
|
if (linkStateProvider.load()) {
|
|
|
|
return ptme.writeToVc(vcId, data, size);
|
2022-01-17 15:58:27 +01:00
|
|
|
}
|
2022-08-24 17:27:47 +02:00
|
|
|
return returnvalue::OK;
|
2021-09-22 16:54:55 +02:00
|
|
|
}
|
|
|
|
|
2023-03-09 17:44:05 +01:00
|
|
|
uint8_t VirtualChannel::getVcid() const { return vcId; }
|
2022-09-16 11:43:11 +02:00
|
|
|
|
|
|
|
const char* VirtualChannel::getName() const { return vcName.c_str(); }
|
2023-03-10 18:04:04 +01:00
|
|
|
|
2023-03-23 18:31:47 +01:00
|
|
|
bool VirtualChannel::isBusy() const {
|
|
|
|
// Data is discarded, so channel is not busy.
|
|
|
|
if (linkStateProvider.load()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return ptme.isBusy(vcId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualChannel::cancelTransfer() { ptme.cancelTransfer(vcId); }
|