void VtoRouter::OnVtoDataReceived(const VtoData& arData) { LOG_BLOCK(LEV_DEBUG, "GotRemoteData: " << arData.GetSize() << " Type: " << ToString(arData.GetType())); if(this->CheckIncomingVtoData(arData)) { /* * Each physical layer action is processed serially, so we can take * advantage of the FIFO structure to keep things simple. */ this->mPhysLayerTxBuffer.push(arData); this->CheckForPhysWrite(); } }
bool EnhancedVtoRouter::CheckIncomingVtoData(const VtoData& arData) { switch(arData.GetType()) { case(VTODT_DATA): if(mInstRemoteConnected) return true; else { LOG_BLOCK(LEV_WARNING, "Discarding received data, because remote side is offline"); this->HandleReceivingDataWhenRemoteClosed(); return false; } case(VTODT_REMOTE_OPENED): if(mInstRemoteConnected) { LOG_BLOCK(LEV_WARNING, "Remote side opened, but it was already open"); this->HandleDuplicateOpen(); return false; } else { mInstRemoteConnected = true; return true; } case(VTODT_REMOTE_CLOSED): if(mInstRemoteConnected) { mInstRemoteConnected = false; return true; } else { LOG_BLOCK(LEV_WARNING, "Remote side closed, but it was already closed"); this->HandleDuplicateClose(); return false; } default: throw ArgumentException(LOCATION, "Unknown VtoData type"); } }
void VtoCallbackTest::OnVtoDataReceived(const VtoData& arData) { size_t aLength = arData.GetSize(); assert(this->size + aLength <= sizeof(received)); memcpy(&this->received[this->size], arData.mpData, aLength); this->size += aLength; this->lastOnVtoDataReceived = aLength; ++this->numOnVtoDataReceived; }
void ResponseLoader::ReadVto(HeaderReadIterator& arIter, SizeByVariationObject* apObj) { /* Get an iterator to the object data */ ObjectReadIterator objIter = arIter.BeginRead(); /* Copy the object data to a VtoData instance */ VtoData data; data.Copy(*objIter, arIter->GetVariation()); /* Determine the Virtual Terminal port/channel number */ size_t index = objIter->Index(); if(index > std::numeric_limits<boost::uint8_t>::max()) { LOG_BLOCK(LEV_WARNING, "Ignoring VTO index that exceeds bit width of uint8_t: " << index); } else { boost::uint8_t channel = static_cast<boost::uint8_t>(index); Transaction t(mpVtoReader); this->mpVtoReader->Update(data, channel); } }
void EnhancedVto::ReadVtoData(const VtoData& arData, bool& arLocalVtoConnectionOpened, boost::uint8_t& arChannelId) { if(arData.GetSize() != (2 + MAGIC_BYTES_SIZE)) throw Exception(LOCATION, "Unexpected size in enhanced vto frame"); if(memcmp(arData.mpData + 2, MAGIC_BYTES, MAGIC_BYTES_SIZE) != 0) throw Exception(LOCATION, "Enhanced vto frame did not include the control sequence"); arChannelId = arData.mpData[0]; arLocalVtoConnectionOpened = (arData.mpData[1] == 0); }
void VtoRouter::OnVtoDataReceived(const VtoData& arData) { // this callback may be coming from another strand (i.e. a stack) and therefore must be synchronized mpPhys->GetExecutor()->Post([this, arData]() { LOG_BLOCK(LEV_DEBUG, "GotRemoteData: " << arData.GetSize() << " Type: " << ToString(arData.GetType())); if(this->CheckIncomingVtoData(arData)) { /* * Each physical layer action is processed serially, so we can take * advantage of the FIFO structure to keep things simple. */ this->mPhysLayerTxBuffer.push(arData); this->CheckForPhysWrite(); } }); }