@@ -103,43 +103,43 @@ BoardConfigurationProtocol::TransmissionResult BoardConfigurationProtocol::sendA
103103
104104 for (int i = 0 ; i < receivedDataLen; i++) {
105105 PacketManager::ReceivingState res;
106- PacketManager::ReceivedData receivedData;
107106 uint8_t val = readByte ();
108107
109- res = PacketManager::getInstance ().handleReceivedByte (receivedData , val);
108+ res = PacketManager::PacketReceiver:: getInstance ().handleReceivedByte (_packet , val);
110109 if (res == PacketManager::ReceivingState::ERROR) {
111110 DEBUG_DEBUG (" BoardConfigurationProtocol::%s Malformed packet" , __FUNCTION__);
112111 sendNak ();
113112 clearInputBuffer ();
114113 transmissionRes = TransmissionResult::INVALID_DATA;
115114 break ;
116115 } else if (res == PacketManager::ReceivingState::RECEIVED) {
117- switch (receivedData. type ) {
116+ switch (_packet. Type ) {
118117 case PacketManager::MessageType::DATA:
119118 {
120- #ifdef BCP_DEBUG_PACKET
121- printPacket (" payload" , receivedData. payload .get_ptr (), receivedData. payload .len ());
119+ #if BCP_DEBUG_PACKET == 1
120+ printPacket (" payload" , _packet. Payload .get_ptr (), _packet. Payload .len ());
122121 #endif
123- _inputMessagesList.push_back (receivedData. payload );
122+ _inputMessagesList.push_back (_packet. Payload );
124123 // Consider all sent data as received
125124 _outputMessagesList.clear ();
126125 transmissionRes = TransmissionResult::DATA_RECEIVED;
127126 }
128127 break ;
129128 case PacketManager::MessageType::TRANSMISSION_CONTROL:
130129 {
131- if (receivedData. payload .len () == 1 && receivedData. payload [0 ] == 0x03 ) {
130+ if (_packet. Payload .len () == 1 && _packet. Payload [0 ] == 0x03 ) {
132131 for (std::list<OutputPacketBuffer>::iterator packet = _outputMessagesList.begin (); packet != _outputMessagesList.end (); ++packet) {
133132 packet->startProgress ();
134133 }
135- } else if (receivedData. payload .len () == 1 && receivedData. payload [0 ] == 0x02 ) {
134+ } else if (_packet. Payload .len () == 1 && _packet. Payload [0 ] == 0x02 ) {
136135 handleDisconnectRequest ();
137136 }
138137 }
139138 break ;
140139 default :
141140 break ;
142141 }
142+ PacketManager::PacketReceiver::getInstance ().clear (_packet);
143143 }
144144 }
145145
@@ -159,7 +159,7 @@ bool BoardConfigurationProtocol::sendData(PacketManager::MessageType type, const
159159 return false ;
160160 }
161161
162- #ifdef BCP_DEBUG_PACKET
162+ #if BCP_DEBUG_PACKET == 1
163163 printPacket (" output message" , outputMsg.get_ptr (), outputMsg.len ());
164164 #endif
165165
@@ -177,7 +177,7 @@ bool BoardConfigurationProtocol::sendData(PacketManager::MessageType type, const
177177}
178178
179179void BoardConfigurationProtocol::clear () {
180- PacketManager::getInstance ().clear ();
180+ PacketManager::PacketReceiver:: getInstance ().clear (_packet );
181181 _outputMessagesList.clear ();
182182 _inputMessagesList.clear ();
183183}
@@ -346,7 +346,9 @@ BoardConfigurationProtocol::TransmissionResult BoardConfigurationProtocol::trans
346346 if (packet->hasBytesToSend ()) {
347347 res = TransmissionResult::NOT_COMPLETED;
348348 packet->incrementBytesSent (writeBytes (packet->get_ptrAt (packet->bytesSent ()), packet->bytesToSend ()));
349+ #if BCP_DEBUG_PACKET == 1
349350 DEBUG_DEBUG (" BoardConfigurationProtocol::%s transferred: %d of %d" , __FUNCTION__, packet->bytesSent (), packet->len ());
351+ #endif
350352 break ;
351353 }
352354 }
0 commit comments