mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* redirect stdout
@ 2014-06-04  9:25 Thibaut Dambry
  2014-06-04 10:19 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Thibaut Dambry @ 2014-06-04  9:25 UTC (permalink / raw)
  To: barebox

Hello

I'm sorry if it is a dummy question, but I don't find a answer.
I would like do that in a barebox hush shell:

value=`i2c_read -a 0x52 -b 0 -r 0x01 -c 1`

But the shell don't interpret the ``.

Is there a method to do that ?

Thank you for this exciting software, I would contribute but I'm a 
little intimidate by the great quality of hackers in this list.

-- 
---------------------------------------------------------
---------------------------------------------------------
Thibaut DAMBRY

ATYSMEDICAL			mailto:rd@atysmedical.com
17 Parc d'Arbora
69510 Soucieu en Jarrest
FRANCE

Phone:(33)4-78-05-69-69
Fax:  (33)4-78-05-69-60

---------------------------------------------------------


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: redirect stdout
  2014-06-04  9:25 redirect stdout Thibaut Dambry
@ 2014-06-04 10:19 ` Sascha Hauer
  2014-06-04 16:11   ` Thibaut Dambry
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2014-06-04 10:19 UTC (permalink / raw)
  To: Thibaut Dambry; +Cc: barebox

On Wed, Jun 04, 2014 at 11:25:38AM +0200, Thibaut Dambry wrote:
> Hello
> 
> I'm sorry if it is a dummy question, but I don't find a answer.
> I would like do that in a barebox hush shell:
> 
> value=`i2c_read -a 0x52 -b 0 -r 0x01 -c 1`
> 
> But the shell don't interpret the ``.
> 
> Is there a method to do that ?

There is no redirection of any kind in barebox and this is not trivial
to implement.

You are trying to read a i2c register into a variable. This is not
possible with the current implementation of the i2c command. Some
commands work around this by adding a commandline parameter which lets
you specify a variable in which the result is written, see for example
the readline command. The i2c_read command could be extended similarly.

OTOH most of the time this comes up it is better to implement a proper
driver for the device. In case it's an EEPROM you're trying to access
here you also better write C Code to interpret its content. This kind
of shell parsing is often very fragile.

> 
> Thank you for this exciting software, I would contribute but I'm a
> little intimidate by the great quality of hackers in this list.

C'mon, we do not bite ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: redirect stdout
  2014-06-04 10:19 ` Sascha Hauer
@ 2014-06-04 16:11   ` Thibaut Dambry
  2014-06-05  5:47     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Thibaut Dambry @ 2014-06-04 16:11 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Thank you for your answer

I would use the eeprom to change linux bootargs parameters.
So the best way is to create a command isUsbDevice (where I read eeprom 
value and return 0 if OK )
and add this in a boot shell script:

#!/bin/sh
isUsbDevice
if [ $? -ne 0 ]; then
     bootargs="$bootargs pcm043_otg_mode=host"
else
     bootargs="$bootargs pcm043_otg_mode=device"
fi



Le 04/06/2014 12:19, Sascha Hauer a écrit :
> On Wed, Jun 04, 2014 at 11:25:38AM +0200, Thibaut Dambry wrote:
>> Hello
>>
>> I'm sorry if it is a dummy question, but I don't find a answer.
>> I would like do that in a barebox hush shell:
>>
>> value=`i2c_read -a 0x52 -b 0 -r 0x01 -c 1`
>>
>> But the shell don't interpret the ``.
>>
>> Is there a method to do that ?
> There is no redirection of any kind in barebox and this is not trivial
> to implement.
>
> You are trying to read a i2c register into a variable. This is not
> possible with the current implementation of the i2c command. Some
> commands work around this by adding a commandline parameter which lets
> you specify a variable in which the result is written, see for example
> the readline command. The i2c_read command could be extended similarly.
>
> OTOH most of the time this comes up it is better to implement a proper
> driver for the device. In case it's an EEPROM you're trying to access
> here you also better write C Code to interpret its content. This kind
> of shell parsing is often very fragile.
>
>> Thank you for this exciting software, I would contribute but I'm a
>> little intimidate by the great quality of hackers in this list.
> C'mon, we do not bite ;)
>
> Sascha
>


-- 
---------------------------------------------------------
---------------------------------------------------------
Thibaut DAMBRY

ATYSMEDICAL			mailto:rd@atysmedical.com
17 Parc d'Arbora
69510 Soucieu en Jarrest
FRANCE

Phone:(33)4-78-05-69-69
Fax:  (33)4-78-05-69-60

---------------------------------------------------------


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: redirect stdout
  2014-06-04 16:11   ` Thibaut Dambry
@ 2014-06-05  5:47     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-06-05  5:47 UTC (permalink / raw)
  To: Thibaut Dambry; +Cc: barebox

On Wed, Jun 04, 2014 at 06:11:00PM +0200, Thibaut Dambry wrote:
> Thank you for your answer
> 
> I would use the eeprom to change linux bootargs parameters.
> So the best way is to create a command isUsbDevice (where I read
> eeprom value and return 0 if OK )
> and add this in a boot shell script:
> 
> #!/bin/sh
> isUsbDevice
> if [ $? -ne 0 ]; then
>     bootargs="$bootargs pcm043_otg_mode=host"
> else
>     bootargs="$bootargs pcm043_otg_mode=device"
> fi

I would use a variable instead of a command. Then you don't have to
create a new command for each piece of information from the EEPROM.
See globalvar_add_simple() and friends.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-05  5:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-04  9:25 redirect stdout Thibaut Dambry
2014-06-04 10:19 ` Sascha Hauer
2014-06-04 16:11   ` Thibaut Dambry
2014-06-05  5:47     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox