/*---------------------------------------------------------------------------- Line Editor *----------------------------------------------------------------------------*/ void getline (char *line, int n) { int cnt = 0; char c; do { if ((c = SER_GetChar()) == CR) c = LF; /* read character */ if (c == BACKSPACE || c == DEL) { /* process backspace */ if (cnt != 0) { cnt--; /* decrement count */ line--; /* and line pointer */ putchar (BACKSPACE); /* echo backspace */ putchar (' '); putchar (BACKSPACE); } } else if (c != CNTLQ && c != CNTLS) { /* ignore Control S/Q */ putchar (*line = c); /* echo and store character */ line++; /* increment line pointer */ cnt++; /* and count */ } #ifdef __USE_FFLUSH fflush (stdout); #endif } while (cnt < n - 1 && c != LF); /* check limit and line feed */ *(line - 1) = 0; /* mark end of string */ }
/*---------------------------------------------------------------------------- Thread 5 'get_escape': check if ESC (escape character) was entered *---------------------------------------------------------------------------*/ void get_escape (void const *argument) { while (1) { /* endless loop */ if (SER_GetChar () == ESC) { /* If ESC entered, set flag */ escape = true; /* 'escape', set event flag of */ osSignalSet(tid_command, 0x0002); /* thread 'command' */ } } }
/*----------------------------------------------------------------------------- Read character from the Serial Port *----------------------------------------------------------------------------*/ int getkey (void) { int ch = SER_GetChar(); #if defined (HAVE_KEIL_RTX) os_itv_wait (); #endif if (ch < 0) { return 0; } return ch; }
int _read (int file, char * ptr, int len) { char c; int i; for (i = 0; i < len; i++) { c = SER_GetChar(); if (c == '\r') break; *ptr++ = c; SER_PutChar(c); } return (len - i); }
size_t __read(int handle, unsigned char *buf, size_t size) { size_t nChars = 0; int c; /* This template only reads from "standard in", for all other file * handles it returns failure. */ if (handle != _LLIO_STDIN) { return _LLIO_ERROR; } for (/* Empty */; size > 0; --size) { c = SER_GetChar(); if (c == '\r') break; *buf++ = c; ++nChars; } return nChars; }
int fgetc(FILE *f) { return (SER_GetChar()); }
/*----------------------------------------------------------------------------- Read character from the Serial Port *----------------------------------------------------------------------------*/ int getkey (void) { return (SER_GetChar ()); }
int fgetc(FILE *f) { //return (getkey()); return (SER_GetChar()); }