@@ -103,43 +103,43 @@ BoardConfigurationProtocol::TransmissionResult BoardConfigurationProtocol::sendA
103
103
104
104
for (int i = 0 ; i < receivedDataLen; i++) {
105
105
PacketManager::ReceivingState res;
106
- PacketManager::ReceivedData receivedData;
107
106
uint8_t val = readByte ();
108
107
109
- res = PacketManager::getInstance ().handleReceivedByte (receivedData , val);
108
+ res = PacketManager::PacketReceiver:: getInstance ().handleReceivedByte (_packet , val);
110
109
if (res == PacketManager::ReceivingState::ERROR) {
111
110
DEBUG_DEBUG (" BoardConfigurationProtocol::%s Malformed packet" , __FUNCTION__);
112
111
sendNak ();
113
112
clearInputBuffer ();
114
113
transmissionRes = TransmissionResult::INVALID_DATA;
115
114
break ;
116
115
} else if (res == PacketManager::ReceivingState::RECEIVED) {
117
- switch (receivedData. type ) {
116
+ switch (_packet. Type ) {
118
117
case PacketManager::MessageType::DATA:
119
118
{
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 ());
122
121
#endif
123
- _inputMessagesList.push_back (receivedData. payload );
122
+ _inputMessagesList.push_back (_packet. Payload );
124
123
// Consider all sent data as received
125
124
_outputMessagesList.clear ();
126
125
transmissionRes = TransmissionResult::DATA_RECEIVED;
127
126
}
128
127
break ;
129
128
case PacketManager::MessageType::TRANSMISSION_CONTROL:
130
129
{
131
- if (receivedData. payload .len () == 1 && receivedData. payload [0 ] == 0x03 ) {
130
+ if (_packet. Payload .len () == 1 && _packet. Payload [0 ] == 0x03 ) {
132
131
for (std::list<OutputPacketBuffer>::iterator packet = _outputMessagesList.begin (); packet != _outputMessagesList.end (); ++packet) {
133
132
packet->startProgress ();
134
133
}
135
- } else if (receivedData. payload .len () == 1 && receivedData. payload [0 ] == 0x02 ) {
134
+ } else if (_packet. Payload .len () == 1 && _packet. Payload [0 ] == 0x02 ) {
136
135
handleDisconnectRequest ();
137
136
}
138
137
}
139
138
break ;
140
139
default :
141
140
break ;
142
141
}
142
+ PacketManager::PacketReceiver::getInstance ().clear (_packet);
143
143
}
144
144
}
145
145
@@ -159,7 +159,7 @@ bool BoardConfigurationProtocol::sendData(PacketManager::MessageType type, const
159
159
return false ;
160
160
}
161
161
162
- #ifdef BCP_DEBUG_PACKET
162
+ #if BCP_DEBUG_PACKET == 1
163
163
printPacket (" output message" , outputMsg.get_ptr (), outputMsg.len ());
164
164
#endif
165
165
@@ -177,7 +177,7 @@ bool BoardConfigurationProtocol::sendData(PacketManager::MessageType type, const
177
177
}
178
178
179
179
void BoardConfigurationProtocol::clear () {
180
- PacketManager::getInstance ().clear ();
180
+ PacketManager::PacketReceiver:: getInstance ().clear (_packet );
181
181
_outputMessagesList.clear ();
182
182
_inputMessagesList.clear ();
183
183
}
@@ -346,7 +346,9 @@ BoardConfigurationProtocol::TransmissionResult BoardConfigurationProtocol::trans
346
346
if (packet->hasBytesToSend ()) {
347
347
res = TransmissionResult::NOT_COMPLETED;
348
348
packet->incrementBytesSent (writeBytes (packet->get_ptrAt (packet->bytesSent ()), packet->bytesToSend ()));
349
+ #if BCP_DEBUG_PACKET == 1
349
350
DEBUG_DEBUG (" BoardConfigurationProtocol::%s transferred: %d of %d" , __FUNCTION__, packet->bytesSent (), packet->len ());
351
+ #endif
350
352
break ;
351
353
}
352
354
}
0 commit comments