File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifdef HAVE_CONFIG_H
0013 #include "config.h"
0014 #endif
0015
0016 #include <stdio.h>
0017 #include <time.h>
0018
0019 #include <rtems.h>
0020 #include <rtems/shell.h>
0021 #include <rtems/stringto.h>
0022 #include "internal.h"
0023
0024 static int rtems_shell_main_sleep(
0025 int argc,
0026 char *argv[]
0027 )
0028 {
0029 struct timespec delay;
0030 unsigned long tmp;
0031
0032 if ((argc != 2) && (argc != 3)) {
0033 fprintf( stderr, "%s: Usage seconds [nanoseconds]\n", argv[0] );
0034 return -1;
0035 }
0036
0037
0038
0039
0040 if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
0041 printf( "Seconds argument (%s) is not a number\n", argv[1] );
0042 return -1;
0043 }
0044 delay.tv_sec = (time_t) tmp;
0045
0046
0047
0048
0049 delay.tv_nsec = 0;
0050 if (argc == 3) {
0051 if ( rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
0052 printf( "Seconds argument (%s) is not a number\n", argv[1] );
0053 return -1;
0054 }
0055 delay.tv_nsec = tmp;
0056 }
0057
0058
0059
0060
0061 nanosleep( &delay, NULL );
0062 return 0;
0063 }
0064
0065 rtems_shell_cmd_t rtems_shell_SLEEP_Command = {
0066 "sleep",
0067 "sleep seconds [nanoseconds]",
0068 "misc",
0069 rtems_shell_main_sleep,
0070 NULL,
0071 NULL
0072 };