* [U-Boot] help: how get last command result using scripting @ 2018-06-19 10:22 Michael Nazzareno Trimarchi 2018-06-22 7:10 ` Lukasz Majewski 0 siblings, 1 reply; 5+ messages in thread From: Michael Nazzareno Trimarchi @ 2018-06-19 10:22 UTC (permalink / raw) To: u-boot 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 Now I need to have the last output of the last command to compare in one script. Any idea? Michael ^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] help: how get last command result using scripting 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 0 siblings, 1 reply; 5+ messages in thread From: Lukasz Majewski @ 2018-06-22 7:10 UTC (permalink / raw) To: u-boot 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 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 -------------- 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/de9a1aaa/attachment.sig> ^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] help: how get last command result using scripting 2018-06-22 7:10 ` Lukasz Majewski @ 2018-06-22 7:11 ` Michael Nazzareno Trimarchi 2018-06-22 8:32 ` Lukasz Majewski 0 siblings, 1 reply; 5+ messages in thread From: Michael Nazzareno Trimarchi @ 2018-06-22 7:11 UTC (permalink / raw) To: u-boot 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 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 -- | Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com | ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] help: how get last command result using scripting 2018-06-22 7:11 ` Michael Nazzareno Trimarchi @ 2018-06-22 8:32 ` Lukasz Majewski 2018-06-22 8:42 ` Michael Nazzareno Trimarchi 0 siblings, 1 reply; 5+ messages in thread From: Lukasz Majewski @ 2018-06-22 8:32 UTC (permalink / raw) To: u-boot 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> ^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] help: how get last command result using scripting 2018-06-22 8:32 ` Lukasz Majewski @ 2018-06-22 8:42 ` Michael Nazzareno Trimarchi 0 siblings, 0 replies; 5+ messages in thread From: Michael Nazzareno Trimarchi @ 2018-06-22 8:42 UTC (permalink / raw) To: u-boot Hi On Fri, Jun 22, 2018 at 10:32 AM, Lukasz Majewski <lukma@denx.de> wrote: > 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. > My general idea is to provide an our variable to stdout to all the command that give some result or exptend command interface to something like do_xxxx() { redirect-stdout -> enviroment do somenthing return } Michael >> >> 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 -- | Michael Nazzareno Trimarchi Amarula Solutions BV | | COO - Founder Cruquiuskade 47 | | +31(0)851119172 Amsterdam 1018 AM NL | | [`as] http://www.amarulasolutions.com | ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-22 8:42 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2018-06-22 8:42 ` Michael Nazzareno Trimarchi
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.