From 52cc18a15b13ea5d549a8fac35cd7a0fba16b225 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 29 Jun 2022 11:27:13 +0800 Subject: [PATCH] Add CAT_STATUS_AGAIN to report io::[write|read] can't send or receive more data Signed-off-by: Xiang Xiao Change-Id: I1e4d69dc32ef94dd2d6d64086528096340f5c74a --- src/cat.c | 18 +++++++++--------- src/cat.h | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cat.c b/src/cat.c index 8b5496f..5c3aa57 100644 --- a/src/cat.c +++ b/src/cat.c @@ -495,7 +495,7 @@ static cat_status error_state(struct cat_object *self) assert(self != NULL); if (read_cmd_char(self) == 0) - return CAT_STATUS_OK; + return CAT_STATUS_AGAIN; switch (self->current_char) { case '\n': @@ -529,7 +529,7 @@ static cat_status parse_prefix(struct cat_object *self) assert(self != NULL); if (read_cmd_char(self) == 0) - return CAT_STATUS_OK; + return CAT_STATUS_AGAIN; switch (self->current_char) { case 'T': @@ -695,7 +695,7 @@ static cat_status parse_command(struct cat_object *self) assert(self != NULL); if (read_cmd_char(self) == 0) - return CAT_STATUS_OK; + return CAT_STATUS_AGAIN; switch (self->current_char) { case '\n': @@ -831,7 +831,7 @@ static cat_status wait_read_acknowledge(struct cat_object *self) assert(self != NULL); if (read_cmd_char(self) == 0) - return CAT_STATUS_OK; + return CAT_STATUS_AGAIN; switch (self->current_char) { case '\n': @@ -896,7 +896,7 @@ static cat_status wait_test_acknowledge(struct cat_object *self) assert(self != NULL); if (read_cmd_char(self) == 0) - return CAT_STATUS_OK; + return CAT_STATUS_AGAIN; switch (self->current_char) { case '\n': @@ -1862,7 +1862,7 @@ static cat_status parse_command_args(struct cat_object *self) assert(self != NULL); if (read_cmd_char(self) == 0) - return CAT_STATUS_OK; + return CAT_STATUS_AGAIN; switch (self->current_char) { case '\n': @@ -1968,7 +1968,7 @@ static cat_status process_idle_state(struct cat_object *self) assert(self != NULL); if (read_cmd_char(self) == 0) - return CAT_STATUS_OK; + return CAT_STATUS_AGAIN; switch (self->current_char) { case 'A': @@ -2463,7 +2463,7 @@ static cat_status process_io_write(struct cat_object *self) } if (self->io->write(ch) != 1) - return CAT_STATUS_BUSY; + return CAT_STATUS_AGAIN; self->position++; return CAT_STATUS_BUSY; @@ -2493,7 +2493,7 @@ static cat_status unsolicited_process_io_write(struct cat_object *self) } if (self->io->write(ch) != 1) - return CAT_STATUS_BUSY; + return CAT_STATUS_AGAIN; self->unsolicited_fsm.position++; return CAT_STATUS_BUSY; diff --git a/src/cat.h b/src/cat.h index f05bde5..4866880 100644 --- a/src/cat.h +++ b/src/cat.h @@ -69,7 +69,8 @@ typedef enum { CAT_STATUS_ERROR = -1, CAT_STATUS_OK = 0, CAT_STATUS_BUSY = 1, - CAT_STATUS_HOLD = 2 + CAT_STATUS_HOLD = 2, + CAT_STATUS_AGAIN = 3 } cat_status; /**