1 /*******************************************************************
2 Components for embedded applications builded for
3 laboratory and medical instruments firmware
5 cmd_proc.c - text command processor
6 enables to define multilevel tables of commands
7 which can be received from more inputs and send reply
8 to respective I/O stream output
10 Copyright (C) 2001-2009 by Pavel Pisa pisa@cmp.felk.cvut.cz
11 (C) 2002-2009 by PiKRON Ltd. http://www.pikron.com
12 (C) 2007 by Michal Sojka <sojkam1@fel.cvut.cz>
14 This file can be used and copied according to next
16 - MPL - Mozilla Public License
17 - GPL - GNU Public License
18 - other license provided by project originators
19 *******************************************************************/
22 #include "cmd_proc_priv.h"
25 * Executes command processor. This function is usually called from
26 * application's main loop.
28 int cmd_processor_run(cmd_io_t *cmd_io, cmd_des_t const **commands)
32 if(cmd_io_line_out(cmd_io))
33 return 1; /* Not all the output has been sent. */
35 if(cmd_io_line_in(cmd_io)<=0)
36 return 0; /* Input line not finished or error. */
39 val=proc_cmd_line(cmd_io, commands, cmd_io->priv.ed_line.in->buf);
44 if(cmd_io->priv.ed_line.out->inbuf){
45 cmd_io_putc(cmd_io,'\r');
46 cmd_io_putc(cmd_io,'\n');
49 cmd_io_puts(cmd_io,"ERROR ");
51 cmd_io_puts(cmd_io,s);
52 cmd_io_putc(cmd_io,'\r');
53 cmd_io_putc(cmd_io,'\n');
55 return 1; /* Command line processed */
59 /* Local Variables: */
60 /* c-basic-offset: 2 */