77#include <string.h>
88#include "PABotBase2_StreamCoalescer.h"
99
10- #include <stdio.h> // REMOVE
11- #include "PABotBase2_ConnectionDebug.h" // REMOVE
10+ // #include <stdio.h> // REMOVE
11+ // #include "PABotBase2_ConnectionDebug.h" // REMOVE
1212
1313void pabb2_StreamCoalescer_init (pabb2_StreamCoalescer * self ){
14+ // printf("pabb2_StreamCoalescer_init(%p)\n", self);
1415 self -> slot_head = 0 ;
1516 self -> slot_tail = 0 ;
1617 self -> stream_head = 0 ;
@@ -64,8 +65,11 @@ void pabb2_StreamCoalescer_pop_leading_finished(pabb2_StreamCoalescer* self){
6465 uint8_t slot_head = self -> slot_head ;
6566 uint8_t slot_tail = self -> slot_tail ;
6667
68+ // printf("pabb2_StreamCoalescer_pop_leading_finished()\n");
69+
6770 while (slot_head != slot_tail ){
6871 uint8_t * slot = & self -> lengths [slot_head & PABB2_StreamCoalescer_SLOTS_MASK ];
72+ // printf("slot[%d] = %d\n", slot_head, *slot);
6973 if (* slot != 0xff ){
7074 break ;
7175 }
@@ -90,8 +94,11 @@ void pabb2_StreamCoalescer_push_packet(pabb2_StreamCoalescer* self, uint8_t seqn
9094// printf("enter ---------------------\n");
9195// pabb2_StreamCoalescer_print(self, false);
9296
97+ // printf("pabb2_StreamCoalescer_push_packet(%p): seqnum = %d, slot_head = %d\n", self, seqnum, slot_head);
98+
9399 // Either before (old retransmit) or too far in future.
94100 if ((uint8_t )(seqnum - slot_head ) >= PABB2_StreamCoalescer_SLOTS ){
101+ // printf("Device: Packet is out of range.\n");
95102 return ;
96103 }
97104
@@ -118,12 +125,14 @@ bool pabb2_StreamCoalescer_push_stream(pabb2_StreamCoalescer* self, const pabb2_
118125
119126 // Zero does not fall through cleanly. So handle it here.
120127 if (stream_size == 0 ){
128+ // printf("Device: stream_size == 0\n");
121129 pabb2_StreamCoalescer_push_packet (self , packet -> seqnum );
122130 return true;
123131 }
124132
125133 // Data is larger than the entire buffer.
126134 if (stream_size > PABB2_StreamCoalescer_BUFFER_SIZE ){
135+ // printf("Device: stream_size > PABB2_StreamCoalescer_BUFFER_SIZE\n");
127136 return false;
128137 }
129138
@@ -133,7 +142,9 @@ bool pabb2_StreamCoalescer_push_stream(pabb2_StreamCoalescer* self, const pabb2_
133142 // Either before (old retransmit) or too far in future.
134143 {
135144 uint8_t diff = seqnum - slot_head ;
145+ // printf("seqnum = %d, slot_head = %d\n", seqnum, slot_head);
136146 if (diff >= PABB2_StreamCoalescer_SLOTS ){
147+ // printf("Device: In the past.\n");
137148 // Negative means we're in the past and we can just ack.
138149 return diff & 0x80 ;
139150 }
@@ -146,6 +157,7 @@ bool pabb2_StreamCoalescer_push_stream(pabb2_StreamCoalescer* self, const pabb2_
146157
147158 // Too far ahead that it's beyond our window.
148159 if (stream_offset_e - self -> stream_head > PABB2_StreamCoalescer_BUFFER_SIZE ){
160+ // printf("Device: To far in future.\n");
149161 return false;
150162 }
151163
0 commit comments