rtems command line shells

Fernando RUIZ CASAS correo at fernando-ruiz.com
Fri Sep 7 17:12:12 UTC 2001


-----Mensaje original-----
>De: Hennenfent, Nick {AVL~Roswell} [mailto:NICK.HENNENFENT at ROCHE.COM]
>Enviado el: viernes, 07 de septiembre de 2001 16:21
>Para: rtems-users at OARcorp.com
>Asunto: rtems command line shells
>
>
>Does anyone have a simple command line shell for RTEMS,
>that can read a command e.g. and start a new task,

Yes.

>maybe with command line editing and history?

Too many resources used. Sorry.
My board is a low memory CPU. (I can implement it. Very easy...)

>Thanks
>
>

Of course.
    With the last snapshot (It exists since four snapshots) you can make it
giving only a tty device termios.
 /dev/console is a very good candidate for this.
With this, you can start one session in every device that you have like with
the unix/linux getty.

You have two users. 'root' and 'rtems'. No password by the moment (crypt.c
missing)
The superuser and the user. All the file protection in the rtems tree
directory are active.

A lot of command are availiable in the first implementaton.
Of course a very very short implementation.

    But if you have tcp/ip started you can start telnetd that gives you 16
(Default) pseusoterminals
ready for remote console.

In your appplication module only you need to make your programs with
the standard header

int main_userprog1(int argc,char*argv[]) {
}

and make anything like this.

shell_add_cmd("userprog1","user_topic","userprog1 arg1 arg1 # make a
beautiful report",main_userprog1);

                        cmd name, topic help, help, main_function

In this moment you can start new task if your main_userprog1 starts new
task.

In the prompt you writes the command like in the linux bash.

'r' is an alias to repeat the last command and 'e' to edit the last command.

In your programs you can use printf(), scanf(), putchar() getchar() but ever
with
stdin,stdout and stderr and NEVER read(0,  because only a fildes 0 is
possible in the rtems environment
and fileno(stdin) != 0 is true always in the user environment.

You can think in a real multiuser envronment but with limitations.
You have a reduced environment but every user connected has a shell
independent. Think Linux.

Interested?
Can I help you?
Examples?
Sources?
Comments?
Sugges.?

Don't hesitate ask me if you have any question of this concern.

Only a little patch (write one asterisk) in tasks.c (rtems kernel) is
necesary but Joel has it in quarantine.

Regards.

Fernando RUIZ CASAS
home: correo at fernando-ruiz.com
work: fernando.ruiz at ctv.es

An example compilable in pc386 BSP here

========================= EXAMPLE ==================================
#undef __STRICT_ANSI__  /* fileno() */
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <pwd.h>
#include <bsp.h>
#include <rtems/shell.h>
#include <rtems/monitor.h>
#include <rtems/stackchk.h>
#include <rtems/cpuuse.h>

#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER

#define CONFIGURE_MAXIMUM_TASKS           20
#define CONFIGURE_MAXIMUM_TIMERS           2
#define CONFIGURE_MAXIMUM_SEMAPHORES      50
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES      0
/*
 * #define CONFIGURE_MAXIMUM_USER_EXTENSIONS    2
 */
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 80

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM

#define CONFIGURE_MEMORY_OVERHEAD   16384
#define CONFIGURE_EXTRA_TASK_STACKS
(CONFIGURE_MAXIMUM_TASKS*4*RTEMS_MINIMUM_STACK_SIZE)

#define CONFIGURE_INIT


rtems_task Init (rtems_task_argument argument);

#include <tty_drv.h>
#include <console.h>
#include <clockdrv.h>
#include <timerdrv.h>

rtems_driver_address_table Device_drivers[] = {
 CONSOLE_DRIVER_TABLE_ENTRY,
 TTY1_DRIVER_TABLE_ENTRY,
 TTY2_DRIVER_TABLE_ENTRY,
 CLOCK_DRIVER_TABLE_ENTRY,
        {NULL,NULL,NULL,NULL,NULL,NULL},
};

#include <confdefs.h>

/*---------------------------------------*/
int main_malloc(int argc,char * argv[]) {
 int malloc_dump();
 malloc_dump();
 return 0;
}
/*---------------------------------------*/
int main_cpu(int argc,char * argv[]) {
 CPU_usage_Dump();
 return 0;
}
/*---------------------------------------*/
/*
 * RTEMS Startup Task
 */
rtems_task
Init (rtems_task_argument ignored)
{
  Stack_check_Initialize();  /* To start CPU_usage_dump only */
  shell_init("shc",16384,8,"/dev/console",B38400|CS8,TRUE);
  shell_init("sh1",16384,8,"/dev/ttyS0"  ,B38400|CS8,TRUE);
  shell_init("sh2",16384,8,"/dev/ttyS1"  ,B38400|CS8,TRUE);
  shell_add_cmd("malloc","misc","show malloc dump",main_malloc);
  shell_add_cmd("cpuuse","misc","show cpu usage"  ,main_cpu   );
  rtems_task_delete(RTEMS_SELF);
}




More information about the users mailing list