add missing grading_getchar and grading_putchar calls
This commit is contained in:
parent
e0272d15e8
commit
eeaf50cf04
@ -18,12 +18,12 @@ void grading_rpc_handler_string(const char* string)
|
|||||||
|
|
||||||
void grading_rpc_handler_serial_getchar(void)
|
void grading_rpc_handler_serial_getchar(void)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF("grading_rpc_handler_serial_getchar()\n");
|
// DEBUG_PRINTF("grading_rpc_handler_serial_getchar()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void grading_rpc_handler_serial_putchar(char c)
|
void grading_rpc_handler_serial_putchar(char c)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF("grading_rpc_handler_serial_putchar(0x%"PRIx8")\n", c);
|
// DEBUG_PRINTF("grading_rpc_handler_serial_putchar(0x%"PRIx8")\n", c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void grading_rpc_handler_ram_cap(size_t bytes, size_t alignment)
|
void grading_rpc_handler_ram_cap(size_t bytes, size_t alignment)
|
||||||
|
|||||||
@ -185,14 +185,18 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1 && !strncmp(argv[1], HELLO_CMD_IO, sizeof(HELLO_CMD_IO))) {
|
if (argc > 1 && !strncmp(argv[1], HELLO_CMD_IO, sizeof(HELLO_CMD_IO))) {
|
||||||
int testInteger;
|
char input[256];
|
||||||
printf("Hi! Please enter an integer: ");
|
printf("Hi! Please enter an input: \n\r");
|
||||||
scanf("%d", &testInteger);
|
fflush(stdout);
|
||||||
printf("number = %d",testInteger);
|
input[0] = fgetc(stdin);
|
||||||
char name_input[20];
|
fflush(stdin);
|
||||||
printf("Please enter your name: ");
|
printf("input = %s\n\r", input);
|
||||||
scanf("%s", name_input);
|
printf("Please enter your name: \n\r");
|
||||||
printf("why hello there, %s", name_input);
|
fflush(stdout);
|
||||||
|
input[1] = fgetc(stdin);
|
||||||
|
fflush(stdin);
|
||||||
|
printf("why hello there, %s\n\r", input);
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
@ -14,6 +14,6 @@
|
|||||||
{
|
{
|
||||||
target = "shelly",
|
target = "shelly",
|
||||||
cFiles = [ "shelly.c" ],
|
cFiles = [ "shelly.c" ],
|
||||||
addLibraries = [ "lpuart", "gic_dist", "fs" ]
|
addLibraries = [ "lpuart", "gic_dist", "fs", "grading" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include <aos/shelly_client.h>
|
#include <aos/shelly_client.h>
|
||||||
#include <aos/aos_rpc.h>
|
#include <aos/aos_rpc.h>
|
||||||
#include <fs/fs.h>
|
#include <fs/fs.h>
|
||||||
|
#include <grading.h>
|
||||||
|
|
||||||
#include "shelly.h"
|
#include "shelly.h"
|
||||||
|
|
||||||
@ -91,18 +92,6 @@ static void handle_lpuart_interrupt(void * arg) {
|
|||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to put character");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to put character");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global_state->current_getchar_request != NULL) {
|
|
||||||
// a client is waiting for a getchar request, forward it.
|
|
||||||
if (is_newline(input_char)) {
|
|
||||||
input_char = '\0';
|
|
||||||
}
|
|
||||||
send_response(global_state->current_getchar_request, SYS_ERR_OK, input_char, 0, NULL);
|
|
||||||
global_state->current_getchar_request = NULL;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(global_state->current_getchar_request == NULL);
|
|
||||||
//handle as shell input
|
|
||||||
if (is_newline(input_char)) {
|
if (is_newline(input_char)) {
|
||||||
global_state->buf[global_state->buffer_i] = '\0';
|
global_state->buf[global_state->buffer_i] = '\0';
|
||||||
global_state->buffer_i += 1;
|
global_state->buffer_i += 1;
|
||||||
@ -110,6 +99,15 @@ static void handle_lpuart_interrupt(void * arg) {
|
|||||||
err = shelly_write_str("\n\r");
|
err = shelly_write_str("\n\r");
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
||||||
|
|
||||||
|
if (global_state->current_getchar_request != NULL) {
|
||||||
|
//send to client
|
||||||
|
for (int i = 0; i < global_state->buffer_i; ++i) {
|
||||||
|
send_response(global_state->current_getchar_request, SYS_ERR_OK, global_state->buf[i], 0, NULL);
|
||||||
|
}
|
||||||
|
global_state->current_getchar_request = NULL;
|
||||||
|
shelly_reset_buffer();
|
||||||
|
} else {
|
||||||
|
//treat as command
|
||||||
err = handle_shelly_cmd(global_state->buf, global_state->buffer_i);
|
err = handle_shelly_cmd(global_state->buf, global_state->buffer_i);
|
||||||
if (err_is_fail(err)) shelly_write_str("failed to run command :(\n\r");
|
if (err_is_fail(err)) shelly_write_str("failed to run command :(\n\r");
|
||||||
|
|
||||||
@ -117,6 +115,7 @@ static void handle_lpuart_interrupt(void * arg) {
|
|||||||
|
|
||||||
err = shelly_write_str("\n\ryou@windows me > ");
|
err = shelly_write_str("\n\ryou@windows me > ");
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write string");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
err = shelly_buffer_append(input_char);
|
err = shelly_buffer_append(input_char);
|
||||||
if (err_is_fail(err)) {
|
if (err_is_fail(err)) {
|
||||||
@ -179,8 +178,11 @@ static void handle_client_request(void *arg, size_t header_size, void *header_bu
|
|||||||
struct shelly_header * header = (struct shelly_header *) header_buf;
|
struct shelly_header * header = (struct shelly_header *) header_buf;
|
||||||
|
|
||||||
if (header->type == SHELLY_MSG_GETCHAR) {
|
if (header->type == SHELLY_MSG_GETCHAR) {
|
||||||
|
grading_rpc_handler_serial_getchar();
|
||||||
|
shelly_reset_buffer();
|
||||||
global_state->current_getchar_request = local_state;
|
global_state->current_getchar_request = local_state;
|
||||||
} else if (header->type == SHELLY_MSG_PUTCHAR) {
|
} else if (header->type == SHELLY_MSG_PUTCHAR) {
|
||||||
|
grading_rpc_handler_serial_putchar(header->character);
|
||||||
err = lpuart_putchar(global_state->uart_s, header->character);
|
err = lpuart_putchar(global_state->uart_s, header->character);
|
||||||
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to put character");
|
if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to put character");
|
||||||
if (is_newline(header->character)) {
|
if (is_newline(header->character)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user