All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] help: how get last command result using scripting
Date: Fri, 22 Jun 2018 10:32:18 +0200	[thread overview]
Message-ID: <20180622103218.633324b8@jawa> (raw)
In-Reply-To: <CAOf5uwmcw--Lje64KViosWtsHPqo_T0DbLuBZVOc5ernzyDvhQ@mail.gmail.com>

Hi Michael,

> Hi
> 
> On Fri, Jun 22, 2018 at 9:10 AM, Lukasz Majewski <lukma@denx.de>
> wrote:
> > Hi Michael,
> >  
> >> Hi all
> >>
> >> Trying to understand how to get the last result. For example:
> >> sspi 1:0.3 24 700002; sspi 1:1.3 24 730000  
> >
> > The $? shall do the job.
> >  
> > => true
> > => echo $?  
> > 0  
> > => false
> > => echo $?  
> > 1  
> 
> commit d7fc57cf5637416d23adb2e5fd1e6ec8fbed6a63
> Author: Michael Trimarchi <michael@amarulasolutions.com>
> Date:   Wed Jun 20 13:46:50 2018 +0200
> 
>     cmd: spi: Export sspi command result in an enviroment variable
> 
>     We would like to export sspi result in enviroment variable to use
>     it later in any scripts

Now I do see about what you were asking for. I've misunderstood you.

> 
>     Change-Id: Iad92455630e3ef8042b2a9fe02f8995c0d8974c9
>     Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> 
> diff --git a/cmd/spi.c b/cmd/spi.c
> index 9a2edcf..00a9c15 100644
> --- a/cmd/spi.c
> +++ b/cmd/spi.c
> @@ -37,13 +37,18 @@ static unsigned int cs;
>  static unsigned int    mode;
>  static int             bitlen;
>  static uchar           dout[MAX_SPI_BYTES];
> -static uchar           din[MAX_SPI_BYTES];
> +static uchar           din[MAX_SPI_BYTES + 1];
> +
> +/* enviroment variable used to export the result */
> +static char            env_din[2 * MAX_SPI_BYTES];
> 
>  static int do_spi_xfer(int bus, int cs)
>  {
>         struct spi_slave *slave;
>         int ret = 0;
> 
> +       env_set("spiout", "");
> +
>  #ifdef CONFIG_DM_SPI
>         char name[30], *str;
>         struct udevice *dev;
> @@ -79,9 +84,13 @@ static int do_spi_xfer(int bus, int cs)
>         } else {
>                 int j;
> 
> -               for (j = 0; j < ((bitlen + 7) / 8); j++)
> +               for (j = 0; j < ((bitlen + 7) / 8); j++) {
>                         printf("%02X", din[j]);
> +                       sprintf(&env_din[2 * j], "%02x", din[j]);
> +               }
>                 printf("\n");
> +               env_din[2 * j] = 0;
> +               env_set("spiout", env_din);
> :
> 
> Michael
> >
> > Or have I misunderstood something?
> >  
> >>
> >> Now I need to have the last output of the last command to compare
> >> in one script. Any idea?
> >>
> >> Michael
> >> _______________________________________________
> >> U-Boot mailing list
> >> U-Boot at lists.denx.de
> >> https://lists.denx.de/listinfo/u-boot  
> >
> >
> >
> >
> > Best regards,
> >
> > Lukasz Majewski
> >
> > --
> >
> > DENX Software Engineering GmbH,      Managing Director: Wolfgang
> > Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
> > Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email:
> > wd at denx.de  
> 
> 
> 




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180622/eeae31a7/attachment.sig>

  reply	other threads:[~2018-06-22  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 10:22 [U-Boot] help: how get last command result using scripting Michael Nazzareno Trimarchi
2018-06-22  7:10 ` Lukasz Majewski
2018-06-22  7:11   ` Michael Nazzareno Trimarchi
2018-06-22  8:32     ` Lukasz Majewski [this message]
2018-06-22  8:42       ` Michael Nazzareno Trimarchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180622103218.633324b8@jawa \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.