Per-task file descriptors and eventually a "real" shell
Ian Caddy
ianc at goanna.iinet.net.au
Tue Oct 6 01:23:35 UTC 2015
Chris, we are using 4.10, and this redirector does not appear in that.
Isaac, our system is a bit more complicated than just a shell, as we
have a menu driven maintenance system on top of the shell.
Basically we create a task with the device name (such as "/dev/com1" or
/dev/usb" or "/dev/pty0"), which we use for the in and out directions
for our IO, then when we drill down to the shell we use the following
commands to start the shell:
The device name is stored in the structure "ptUsrApp->devname"
FILE *ostd[3];
/* Save old environment */
ostd[0] = stdin;
ostd[1] = stdout;
ostd[2] = stderr;
stdin = fopen(ptUserApp->devname, "r");
stdout = fopen(ptUserApp->devname, "w");
stderr = fopen(ptUserApp->devname, "w");
rtems_shell_main_loop( &ptDispShell->env );
/* Upon exit from the shell */
fclose(stdin);
fclose(stdout);
fclose(stderr);
stderr = ostd[2];
stdout = ostd[1];
stdin = ostd[0];
This works fine for us on 4.10.
regards,
Ian Caddy
On 5/10/2015 9:20 PM, Isaac Gutekunst wrote:
> Hi Ian,
>
> That's exciting! I clearly should have looked a bit harder before
> posting. Is there any special config? Or is it sufficient to instantiate
> another shell with a different file descriptor for IO?
>
> Isaac
>
> On 10/04/2015 09:22 PM, Ian Caddy wrote:
>> Hi Isaac,
>>
>> On 3/10/2015 4:24 AM, Isaac Gutekunst wrote:
>>> Hey,
>>>
>>>
>>> The hack would be that file descriptors 0,1 and 2 are not part of a
>>> global namespace of file descriptors, and potentially refer to different
>>> actual IO devices on a per task basis.
>>>
>>> The motivation here would be creating a more functional shell and
>>> support easy IO redirection for logging, and running multiple shell
>>> instances, perhaps via multiple telnet and serial sessions.
>>>
>>
>> Maybe I am missing something, but we do all this currently with the
>> shell.
>>
>> We have a serial port access, and we have multiple telnet / ssh access
>> to our devices providing
>> multiple shells with no problems.
>>
>> We also redirect the stdio for all the application tasks to print to
>> an application log instead
>> on the shell. This is all completely doable now, as as far as I know
>> newlib provides a per
>> task stdin, etc.
>>
>> Just start your task and point them where you want them to go.
>>
>> regards,
>>
>> Ian Caddy
>>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
--
Ian Caddy
Goanna Technologies Pty Ltd
+61 8 9444 2634
More information about the devel
mailing list