echo on shell
This commit is contained in:
parent
23e2b56a70
commit
1938cfbd7e
@ -44,17 +44,19 @@ static void parse(const char *buffer, unsigned int len)
|
||||
|
||||
static void rx_func(void *arg)
|
||||
{
|
||||
char buffer[80];
|
||||
char buffer[81];
|
||||
unsigned int index = 0;
|
||||
int ret = 0;
|
||||
open(shell_object.shell_device);
|
||||
while(1) {
|
||||
ret = read(shell_object.shell_device, &buffer[index],
|
||||
sizeof(buffer) / sizeof(buffer[0]) - index);
|
||||
sizeof(buffer) / sizeof(buffer[0]) - index - 1);
|
||||
if(ret) {
|
||||
write(shell_object.shell_device, &buffer[index], ret); // echo
|
||||
if((buffer[index + ret - 1] == '\n') || (buffer[index + ret - 1] == '\r')) {
|
||||
buffer[index + ret - 1] = '\n';
|
||||
parse(buffer, index + ret);
|
||||
buffer[index + ret] = '\0';
|
||||
index = 0;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user