@@ -91,7 +91,7 @@ typedef struct {
9191 void * app_send_sync_lock ; /* avoid app send concurrency, out of sequence */
9292 int acked ;
9393 CommSequence sequence ;
94- CommSequence current_acked_seq ; /* current received sequence */
94+ short current_acked_seq ; /* current received sequence */
9595 char * protocol_buffer ;
9696 InterruptHandle interrupt_handle ;
9797 int sem_hooks_registered ;
@@ -259,11 +259,11 @@ static void _unregister_write_handler() {
259259 g_comm_protocol_business .on_write = NULL ;
260260}
261261
262- static void _set_current_acked_seq (CommSequence seq ) {
262+ static void _set_current_acked_seq (short seq ) {
263263 g_comm_protocol_business .current_acked_seq = seq ;
264264}
265265
266- static CommSequence _get_current_acked_seq () {
266+ static short _get_current_acked_seq () {
267267 return g_comm_protocol_business .current_acked_seq ;
268268}
269269
@@ -621,6 +621,11 @@ static int _is_duplicate_frame(CommProtocolPacket *protocol_packet) {
621621 return duplicate ;
622622}
623623
624+ static int _is_udp_packet (CommProtocolPacket * protocol_packet ) {
625+ return (_byte2_big_endian_2_u16 (protocol_packet -> cmd ) != 0 &&
626+ !_is_ack_set (protocol_packet -> control ));
627+ }
628+
624629static void _one_protocol_frame_process (char * protocol_buffer ) {
625630 CommProtocolPacket * protocol_packet = (CommProtocolPacket * )protocol_buffer ;
626631
@@ -633,7 +638,7 @@ static void _one_protocol_frame_process(char *protocol_buffer) {
633638 if (_is_acked_packet (protocol_packet )) {
634639 /* one sequence can only break once */
635640 if (protocol_packet -> sequence == _current_sequence_get () &&
636- protocol_packet -> sequence != _get_current_acked_seq ()) {
641+ ( short ) protocol_packet -> sequence != _get_current_acked_seq ()) {
637642 _set_acked_sync_flag ();
638643 _set_current_acked_seq (protocol_packet -> sequence );
639644 InterruptableBreak (g_comm_protocol_business .interrupt_handle );
@@ -660,6 +665,11 @@ static void _one_protocol_frame_process(char *protocol_buffer) {
660665 /* ack automatically when ack attribute set */
661666 _do_ack (protocol_packet );
662667
668+ /* udp frame reset current acked seq -1 */
669+ if (_get_current_acked_seq () != -1 && _is_udp_packet (protocol_packet )) {
670+ _set_current_acked_seq (-1 );
671+ }
672+
663673 /* notify application when not ack frame nor duplicate frame */
664674 if (!_is_duplicate_frame (protocol_packet )) {
665675 g_comm_protocol_business .on_recv_frame (& packet );
0 commit comments