From 736189f855f519037cc0fa6ba0d84e0ca2db5106 Mon Sep 17 00:00:00 2001 From: Jiacheng Shi Date: Tue, 14 Jun 2022 19:35:32 +0800 Subject: [PATCH] powerlink: implement console-xiuos.c --- .../contrib/console/console-xiuos.c | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/contrib/console/console-xiuos.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/contrib/console/console-xiuos.c index 394f6fda4..151ac9008 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/contrib/console/console-xiuos.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/contrib/console/console-xiuos.c @@ -40,12 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //------------------------------------------------------------------------------ // includes //------------------------------------------------------------------------------ -#include -#include -#include -// #include - -#include +#include //============================================================================// // P U B L I C F U N C T I O N S // @@ -65,7 +60,15 @@ termios library. //------------------------------------------------------------------------------ int console_getch(void) { - return 'p'; + char ch, len; + + extern char userShellRead(char *data); + + do { + len = userShellRead(&ch); + } while (!len); + + return ch; } //------------------------------------------------------------------------------ @@ -82,5 +85,16 @@ The function checks the console for a keystroke. //------------------------------------------------------------------------------ int console_kbhit(void) { - return 0; + extern HardwareDevType console; + struct SerialHardwareDevice *serial_dev = (struct SerialHardwareDevice *)console; + int ret; + + ret = KSemaphoreObtain(serial_dev->haldev.dev_sem, 0); + + if (ret == EOK) { + KSemaphoreAbandon(serial_dev->haldev.dev_sem); + return 1; + } else { + return 0; + } }