Skip to content

Commit 52cc18a

Browse files
Add CAT_STATUS_AGAIN to report io::[write|read] can't send or receive more data
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I1e4d69dc32ef94dd2d6d64086528096340f5c74a
1 parent 2f8929a commit 52cc18a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/cat.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static cat_status error_state(struct cat_object *self)
495495
assert(self != NULL);
496496

497497
if (read_cmd_char(self) == 0)
498-
return CAT_STATUS_OK;
498+
return CAT_STATUS_AGAIN;
499499

500500
switch (self->current_char) {
501501
case '\n':
@@ -529,7 +529,7 @@ static cat_status parse_prefix(struct cat_object *self)
529529
assert(self != NULL);
530530

531531
if (read_cmd_char(self) == 0)
532-
return CAT_STATUS_OK;
532+
return CAT_STATUS_AGAIN;
533533

534534
switch (self->current_char) {
535535
case 'T':
@@ -695,7 +695,7 @@ static cat_status parse_command(struct cat_object *self)
695695
assert(self != NULL);
696696

697697
if (read_cmd_char(self) == 0)
698-
return CAT_STATUS_OK;
698+
return CAT_STATUS_AGAIN;
699699

700700
switch (self->current_char) {
701701
case '\n':
@@ -831,7 +831,7 @@ static cat_status wait_read_acknowledge(struct cat_object *self)
831831
assert(self != NULL);
832832

833833
if (read_cmd_char(self) == 0)
834-
return CAT_STATUS_OK;
834+
return CAT_STATUS_AGAIN;
835835

836836
switch (self->current_char) {
837837
case '\n':
@@ -896,7 +896,7 @@ static cat_status wait_test_acknowledge(struct cat_object *self)
896896
assert(self != NULL);
897897

898898
if (read_cmd_char(self) == 0)
899-
return CAT_STATUS_OK;
899+
return CAT_STATUS_AGAIN;
900900

901901
switch (self->current_char) {
902902
case '\n':
@@ -1862,7 +1862,7 @@ static cat_status parse_command_args(struct cat_object *self)
18621862
assert(self != NULL);
18631863

18641864
if (read_cmd_char(self) == 0)
1865-
return CAT_STATUS_OK;
1865+
return CAT_STATUS_AGAIN;
18661866

18671867
switch (self->current_char) {
18681868
case '\n':
@@ -1968,7 +1968,7 @@ static cat_status process_idle_state(struct cat_object *self)
19681968
assert(self != NULL);
19691969

19701970
if (read_cmd_char(self) == 0)
1971-
return CAT_STATUS_OK;
1971+
return CAT_STATUS_AGAIN;
19721972

19731973
switch (self->current_char) {
19741974
case 'A':
@@ -2463,7 +2463,7 @@ static cat_status process_io_write(struct cat_object *self)
24632463
}
24642464

24652465
if (self->io->write(ch) != 1)
2466-
return CAT_STATUS_BUSY;
2466+
return CAT_STATUS_AGAIN;
24672467

24682468
self->position++;
24692469
return CAT_STATUS_BUSY;
@@ -2493,7 +2493,7 @@ static cat_status unsolicited_process_io_write(struct cat_object *self)
24932493
}
24942494

24952495
if (self->io->write(ch) != 1)
2496-
return CAT_STATUS_BUSY;
2496+
return CAT_STATUS_AGAIN;
24972497

24982498
self->unsolicited_fsm.position++;
24992499
return CAT_STATUS_BUSY;

src/cat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ typedef enum {
6969
CAT_STATUS_ERROR = -1,
7070
CAT_STATUS_OK = 0,
7171
CAT_STATUS_BUSY = 1,
72-
CAT_STATUS_HOLD = 2
72+
CAT_STATUS_HOLD = 2,
73+
CAT_STATUS_AGAIN = 3
7374
} cat_status;
7475

7576
/**

0 commit comments

Comments
 (0)