/************************************************************************** * SDMDisplay::ANT_eventNotification * * Process ANT channel event * * ucEventCode_: code of ANT channel event * pucEventBuffer_: pointer to buffer containing data received from ANT, * or a pointer to the transmit buffer in the case of an EVENT_TX * * returns: N/A * **************************************************************************/ void SDMDisplay::ANT_eventNotification(UCHAR ucEventCode_, UCHAR* pucEventBuffer_) { switch(ucEventCode_) { case EVENT_RX_ACKNOWLEDGED: case EVENT_RX_BURST_PACKET: // intentional fall thru case EVENT_RX_BROADCAST: HandleReceive((UCHAR*) pucEventBuffer_); break; case EVENT_TRANSFER_TX_COMPLETED: ucAckRetryCount = 0; // Reset retransmission counter ucMsgExpectingAck = 0; // Clear pending msg code UpdateDisplayAckStatus(ACK_SUCCESS); // Tx successful break; case EVENT_TRANSFER_TX_FAILED: case EVENT_ACK_TIMEOUT: // Intentional fall thru if(ucMsgExpectingAck) { if(HandleRetransmit()) UpdateDisplayAckStatus(ACK_RETRY); // Data was retransmitted else UpdateDisplayAckStatus(ACK_FAIL); // Maximum number of retries exceeded, Tx failed } break; default: break; } }
void CTcpAgent::HandleIo(CONNID dwConnID, TSocketObj* pSocketObj, TBufferObj* pBufferObj, DWORD dwBytes, DWORD dwErrorCode) { ASSERT(pBufferObj != nullptr); ASSERT(pSocketObj != nullptr); if(dwErrorCode != NO_ERROR) { HandleError(dwConnID, pBufferObj, dwErrorCode); return; } if(dwBytes == 0 && pBufferObj->operation != SO_CONNECT) { AddFreeSocketObj(dwConnID, SCF_CLOSE); AddFreeBufferObj(pBufferObj); return; } pBufferObj->buff.len = dwBytes; switch(pBufferObj->operation) { case SO_CONNECT: HandleConnect(dwConnID, pSocketObj, pBufferObj); break; case SO_SEND: HandleSend(dwConnID, pSocketObj, pBufferObj); break; case SO_RECEIVE: HandleReceive(dwConnID, pSocketObj, pBufferObj); break; default: ASSERT(FALSE); } }
void CUdpServer::HandleIo(CONNID dwConnID, TUdpBufferObj* pBufferObj, DWORD dwBytes, DWORD dwErrorCode) { ASSERT(pBufferObj != nullptr); if(dwErrorCode != NO_ERROR) { HandleError(dwConnID, pBufferObj, dwErrorCode); return; } if(dwBytes == 0) { HandleZeroBytes(dwConnID, pBufferObj); return; } pBufferObj->buff.len = dwBytes; switch(pBufferObj->operation) { case SO_SEND: HandleSend(dwConnID, pBufferObj); break; case SO_RECEIVE: HandleReceive(dwConnID, pBufferObj); break; default: ASSERT(FALSE); } }
void Server::StartReceive() { mSocket.async_receive_from( boost::asio::buffer(mCommand->GetData()), mRemoteEndpoint, [this] (const boost::system::error_code& error, std::size_t) { if(!error) HandleReceive(); }); }
/************************************************************************** * BikeSpeedeDisplay::ANT_eventNotification * * Process ANT channel event * * ucEventCode_: code of ANT channel event * pucEventBuffer_: pointer to buffer containing data received from ANT, * or a pointer to the transmit buffer in the case of an EVENT_TX * * returns: N/A * **************************************************************************/ void BikeSpeedDisplayDummy::ANT_eventNotification(UCHAR ucEventCode_, UCHAR* pucEventBuffer_) { switch(ucEventCode_) { case EVENT_RX_ACKNOWLEDGED: case EVENT_RX_BURST_PACKET: // intentional fall thru case EVENT_RX_BROADCAST: HandleReceive((UCHAR*) pucEventBuffer_); break; default: break; } }
void WorldSession::HandleHeader(const boost::system::error_code& Error) { Packet.ReadHeader(); // Header only packet or perhaps an error receiving the header? if (Packet.GetSizeWithoutHeader() < 1 || Error) { HandleReceive(Error); } else { boost::asio::async_read(Socket, boost::asio::buffer(Packet.GetDataWithoutHeader(), Packet.GetSizeWithoutHeader()), boost::bind(&WorldSession::HandleReceive, shared_from_this(), boost::asio::placeholders::error)); } }
void CIocpServer::HandleIo(TSocketObj* pSocketObj, TBufferObj* pBufferObj, DWORD dwBytes, DWORD dwErrorCode) { ASSERT(pBufferObj != NULL); ASSERT(pSocketObj != NULL); //判断是否已经标记失败 if(dwErrorCode != NO_ERROR) { if(pBufferObj->operation != SO_ACCEPT) { FireError(pSocketObj->connID, pBufferObj->operation, dwErrorCode); AddFreeSocketObj(pSocketObj->connID); } else { DeleteAcceptSocket(pBufferObj->client, TRUE); } AddFreeBufferObj(pBufferObj); return; } if(dwBytes == 0 && pBufferObj->operation != SO_ACCEPT) { FireClose(pSocketObj->connID); AddFreeSocketObj(pSocketObj->connID); AddFreeBufferObj(pBufferObj); return; } pBufferObj->buff.len = dwBytes; switch(pBufferObj->operation) { case SO_ACCEPT: HandleAccept((SOCKET)pSocketObj, pBufferObj); break; case SO_SEND: HandleSend(pSocketObj, pBufferObj); break; case SO_RECEIVE: HandleReceive(pSocketObj, pBufferObj); break; default: ASSERT(FALSE); } }
void NcpSpi::HandleRxFrame(void) { SpiFrame recvFrame(mReceiveFrame); SpiFrame sendFrame(mSendFrame); // Pass the received frame to base class to process. HandleReceive(recvFrame.GetData(), recvFrame.GetHeaderDataLen()); // The order of operations below is important. We should clear // the `mHandlingRxFrame` before checking `mTxState` and possibly // preparing the next transaction. Note that the callback // `SpiTransactionComplete()` can be invoked from ISR at any point. // // If we switch the order, we have the following race situation: // We check `mTxState` and it is in `kTxStateSending`, so we skip // preparing the transaction here. But before we set the // `mHandlingRxFrame` to `false`, the `SpiTransactionComplete()` // happens and prepares the next transaction and sets the accept // length to zero on `mSendFrame` (since it assumes we are still // handling the previous received frame). mHandlingRxFrame = false; // If tx state is in `kTxStateSending`, we wait for the callback // `SpiTransactionComplete()` which will then set up everything // and prepare the next transaction. if (mTxState != kTxStateSending) { sendFrame.SetHeaderAcceptLen(kSpiBufferSize - kSpiHeaderSize); otPlatSpiSlavePrepareTransaction(mEmptySendFrameFullAccept, kSpiHeaderSize, mReceiveFrame, kSpiBufferSize, /* aRequestTrans */ false); // No need to check the error status. Getting `OT_ERROR_BUSY` // is OK as everything will be set up properly from callback when // the current transaction is completed. } }