Changeset a2597f3 in rtems


Ignore:
Timestamp:
Jun 2, 2016, 11:29:45 AM (4 years ago)
Author:
Alexander Krutwig <alexander.krutwig@…>
Branches:
5, master
Children:
15f0f9b
Parents:
214156d
git-author:
Alexander Krutwig <alexander.krutwig@…> (06/02/16 11:29:45)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/06/16 10:57:07)
Message:

shell: Add rtems_shell_wait_for_explicit_input()

Location:
cpukit/libmisc/shell
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/shell/shell-wait-for-input.c

    r214156d ra2597f3  
    5454}
    5555
    56 rtems_status_code rtems_shell_wait_for_input(
     56rtems_status_code rtems_shell_wait_for_explicit_input(
    5757  int fd,
    5858  int timeout_in_seconds,
    5959  rtems_shell_wait_for_input_notification notification,
    60   void *notification_arg
     60  void *notification_arg,
     61  int desired_input
    6162)
    6263{
     
    6970
    7071    for (i = 0; i < timeout_in_seconds && !input_detected; ++i) {
    71       char c;
     72      unsigned char c;
    7273
    7374      (*notification)(fd, timeout_in_seconds - i, notification_arg);
    7475
    75       input_detected = read(fd, &c, sizeof(c)) > 0;
     76      input_detected = read(fd, &c, sizeof(c)) > 0
     77        && (desired_input == -1 || desired_input == c);
    7678    }
    7779
     
    8486  return sc;
    8587}
     88
     89rtems_status_code rtems_shell_wait_for_input(
     90  int fd,
     91  int timeout_in_seconds,
     92  rtems_shell_wait_for_input_notification notification,
     93  void *notification_arg
     94)
     95{
     96  return rtems_shell_wait_for_explicit_input(
     97    fd,
     98    timeout_in_seconds,
     99    notification,
     100    notification_arg,
     101    -1
     102  );
     103}
  • cpukit/libmisc/shell/shell.h

    r214156d ra2597f3  
    323323);
    324324
     325/**
     326 * @brief Waits for explicit input.
     327 *
     328 * @param desired_input An explicit unsigned character to wait for or -1 to
     329 *   accept any input.
     330 *
     331 * @retval RTEMS_SUCCESSFUL Input detected.
     332 * @retval RTEMS_TIMEOUT Timeout expired.
     333 * @retval RTEMS_UNSATISFIED Cannot change or restore termios attributes.
     334 */
     335extern rtems_status_code rtems_shell_wait_for_explicit_input(
     336  int fd,
     337  int timeout_in_seconds,
     338  rtems_shell_wait_for_input_notification notification,
     339  void *notification_arg,
     340  int desired_input
     341);
     342
    325343extern int rtems_shell_main_monitor(int argc, char **argv);
    326344
Note: See TracChangeset for help on using the changeset viewer.