| 211 | | // compare control data |
| 212 | | if ( true ) |
| 213 | | { |
| 214 | | packet_id = 0; |
| 215 | | // std::cout << "DataComparator: control: "; |
| 216 | | /* |
| 217 | | for (i=0; i<M; i++) |
| 218 | | std::cout << " " << (int) (*control_bits_in)[i]; |
| 219 | | std::cout << std::endl; |
| 220 | | */ |
| 221 | | |
| 222 | | // control data represent a 5-bit packet ID, viz |
| 223 | | // packet_id = [b4 b3 b2 b1 b0] |
| 224 | | // repeated 3 timesl; take best of 3 bits |
| 225 | | |
| 226 | | packet_id |= ( ( |
| 227 | | (*control_bits_in)[0] + |
| 228 | | (*control_bits_in)[5] + |
| 229 | | (*control_bits_in)[10] |
| 230 | | ) >= 2 ) ? 0x0001 : 0x0000; |
| 231 | | packet_id <<= 1; |
| 232 | | |
| 233 | | packet_id |= ( ( |
| 234 | | (*control_bits_in)[1] + |
| 235 | | (*control_bits_in)[6] + |
| 236 | | (*control_bits_in)[11] |
| 237 | | ) >= 2 ) ? 0x0001 : 0x0000; |
| 238 | | packet_id <<= 1; |
| 239 | | |
| 240 | | packet_id |= ( ( |
| 241 | | (*control_bits_in)[2] + |
| 242 | | (*control_bits_in)[7] + |
| 243 | | (*control_bits_in)[12] |
| 244 | | ) >= 2 ) ? 0x0001 : 0x0000; |
| 245 | | packet_id <<= 1; |
| 246 | | |
| 247 | | packet_id |= ( ( |
| 248 | | (*control_bits_in)[3] + |
| 249 | | (*control_bits_in)[8] + |
| 250 | | (*control_bits_in)[13] |
| 251 | | ) >= 2 ) ? 0x0001 : 0x0000; |
| 252 | | packet_id <<= 1; |
| 253 | | |
| 254 | | packet_id |= ( ( |
| 255 | | (*control_bits_in)[4] + |
| 256 | | (*control_bits_in)[9] + |
| 257 | | (*control_bits_in)[14] |
| 258 | | ) > 2 ) ? 0x0001 : 0x0000; |
| 259 | | |
| 260 | | DEBUG(5, DataComparator, "packet id : " << packet_id); |
| 261 | | |
| 262 | | if ( first_packet ) |
| 263 | | first_packet = false; |
| 264 | | else |
| 265 | | { |
| 266 | | // determine if packets have been dropped |
| 267 | | if ( packet_id == 0 ) |
| 268 | | packet_index_diff = 31 - prev_packet_id; |
| 269 | | else |
| 270 | | packet_index_diff = packet_id - prev_packet_id - 1; |
| 271 | | |
| 272 | | while (packet_index_diff<0) |
| 273 | | packet_index_diff += 31; |
| 274 | | |
| 275 | | num_dropped_packets += (unsigned int) packet_index_diff; |
| 276 | | } |
| 277 | | |
| 278 | | num_received_packets++; |
| 279 | | prev_packet_id = packet_id; |
| | 219 | // determine if packets have been dropped |
| | 220 | if ( packet_id == 0 ) |
| | 221 | packet_index_diff = 127 - prev_packet_id; |
| | 222 | else |
| | 223 | packet_index_diff = packet_id - prev_packet_id - 1; |
| | 224 | |
| | 225 | while (packet_index_diff<0) |
| | 226 | packet_index_diff += 127; |
| | 227 | |
| | 228 | num_dropped_packets += (unsigned int) packet_index_diff; |
| | 229 | } |
| | 230 | |
| | 231 | num_received_packets++; |
| | 232 | prev_packet_id = packet_id; |
| 281 | | } |
| 282 | | num_errors = 0; |
| 283 | | |
| 284 | | // compare data values |
| 285 | | for (i=0; i<N; i++) |
| 286 | | num_errors += ( (signed char) (*data_bits_in)[i]==packet_tmp[i]) |
| 287 | | ? 0 : 1; |
| 288 | | |
| 289 | | DEBUG(2, DataComparator, "data errors : " << num_errors << " / " << N) |
| 290 | | |
| 291 | | if ( (num_received_packets+num_dropped_packets) >= num_packets_to_observe ) |
| 292 | | { |
| 293 | | DEBUG(1, DataComparator, "------------------ dropped packets : " << num_dropped_packets << " / " << num_received_packets + num_dropped_packets) |
| 294 | | num_received_packets = 0; |
| 295 | | num_dropped_packets = 0; |
| 296 | | } |
| 297 | | #ifdef LOGGING |
| 298 | | if ( log_size_counter < LOG_SIZE_MAX ) |
| 299 | | { |
| 300 | | packet_log << packet_id << " " << num_errors << std::endl; |
| 301 | | log_size_counter++; |
| 302 | | } |
| 303 | | #endif |
| 304 | | } |
| 305 | | dataIn_0->bufferEmptied(); |
| 306 | | dataIn_1->bufferEmptied(); |
| | 234 | num_errors = 0; |
| | 235 | |
| | 236 | // compare data values |
| | 237 | for (i=0; i<N; i++) { |
| | 238 | if ( (signed char) (*data_bits_in)[i] != packet_tmp[i] ) |
| | 239 | num_errors += 1; |
| | 240 | } |
| | 241 | |
| | 242 | DEBUG(2, DataComparator, "data errors [" << packet_id << "] : " << num_errors << " / " << N) |
| | 243 | |
| | 244 | if ( (num_received_packets+num_dropped_packets) >= num_packets_to_observe ) { |
| | 245 | DEBUG(1, DataComparator, "------------------ dropped packets : " << num_dropped_packets << " / " << num_received_packets + num_dropped_packets) |
| | 246 | num_total_errors += num_errors; |
| | 247 | DEBUG(1, DataComparator, "------------------ error rate : " << float(num_total_errors)/float(num_received_packets) << " %") |
| | 248 | num_received_packets = 0; |
| | 249 | num_dropped_packets = 0; |
| | 250 | num_total_errors = 0; |
| | 251 | } |
| | 252 | |
| | 253 | #ifdef LOGGING |
| | 254 | if ( log_size_counter < LOG_SIZE_MAX ) |
| | 255 | { |
| | 256 | packet_log << packet_id << " " << num_errors << std::endl; |
| | 257 | log_size_counter++; |
| | 258 | } |
| | 259 | #endif |