X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=app%2Ftriface%2Fprotocol.c;h=08910d0426e26b85b0caaaf6c7efa11f34bb9068;hb=cb475c2071d6be7048f8c5c06485b3cd8530708c;hp=e659888b3d9c820c7b734cbd6dc287e4ff69e97d;hpb=91bbddad1da23825fefd07447d841ba7d6b8365a;p=bertos.git diff --git a/app/triface/protocol.c b/app/triface/protocol.c old mode 100755 new mode 100644 index e659888b..08910d04 --- a/app/triface/protocol.c +++ b/app/triface/protocol.c @@ -1,6 +1,31 @@ /** * \file * * @@ -14,25 +39,6 @@ * \author Bernardo Innocenti */ -/*#* - *#* $Log$ - *#* Revision 1.5 2006/06/14 01:03:01 marco - *#* Add response code. Add command ping. - *#* - *#* Revision 1.4 2006/06/14 00:26:48 marco - *#* Use new macros for defining commands. - *#* - *#* Revision 1.3 2006/06/13 19:07:31 marco - *#* Fixed a bug in protocol_reply. Simplified rpc. - *#* - *#* Revision 1.2 2006/06/12 21:37:02 marco - *#* implemented some commands (ver and sleep) - *#* - *#* Revision 1.1 2006/06/01 12:29:21 marco - *#* Add first simple protocol command (version request). - *#* - *#*/ - #include "protocol.h" #include @@ -46,7 +52,7 @@ #include #include -#include +//#include #include "cmd_ctor.h" // MAKE_CMD, REGISTER_CMD @@ -69,6 +75,7 @@ static struct RLContext rl_ctx; /** * Send a NAK asking the host to send the current message again. * + * \param ser serial port handle to output to. * \param err human-readable description of the error for debug purposes. */ INLINE void NAK(Serial *ser, const char *err) @@ -218,14 +225,15 @@ void protocol_run(Serial *ser) * */ -/* Version. */ -MAKE_CMD(ver, "", "s", -({ - args[1].s = VERS_TAG; - 0; -})) +/* Version. Example of declaring function and passing it to MAKE_CMD. */ +static int ver_fn(const char **str) +{ + *str = VERS_TAG; + return 0; +} +MAKE_CMD(ver, "", "s", ver_fn(&args[1].s)) -/* Sleep. */ +/* Sleep. Example of declaring function body directly in macro call. */ MAKE_CMD(sleep, "d", "", ({ timer_delay((mtime_t)args[1].l);