vendredi 3 décembre 2021

u-boot how to call command via "if" or "echo"

Problem description:

When I'm reading a register of my device via i2c all is fine and is showing status as expected:

*HOSTMCU> i2c md 0x52 0x32 1
0032: 10    .
STM32MP>* 

My target is to use this information in if statement, but I'm not able to do it. I tried to construct this statement in different ways by without success:

*HOSTMCU> if test i2c md 0x52 0x32 1 = 31; then; echo "TRUE"; else echo "FALSE"; fi; 
TRUE

HOSTMCU> if test `i2c md 0x52 0x32 1` = 31; then; echo "TRUE"; else echo "FALSE"; fi; 
TRUE

HOSTMCU> if test `i2c md 0x52 0x32 1` == 31; then; echo "TRUE"; else echo "FALSE"; fi; 
TRUE

HOSTMCU> if test i2c md 0x52 0x32 1 == 31; then; echo "TRUE"; else echo "FALSE"; fi;   
TRUE

HOSTMCU> if test 'i2c md 0x52 0x32 1' == 31; then; echo "TRUE"; else echo "FALSE"; fi; 
TRUE

HOSTMCU> if 'i2c md 0x52 0x32 1' == 31; then; echo "TRUE"; else echo "FALSE"; fi;

Unknown command 'i2c md 0x52 0x32 1' - try 'help'
FALSE

HOSTMCU> if 'i2c md 0x52 0x32 1' == 31; then; echo "TRUE"; else echo "FALSE"; fi; 

Unknown command 'i2c md 0x52 0x32 1' - try 'help'
FALSE

HOSTMCU> if i2c md 0x52 0x32 1 == 31; then; echo "TRUE"; else echo "FALSE"; fi;   
0037: 10    .
TRUE

HOSTMCU> if 'i2c md 0x52 0x32 1' == 31; then; echo "TRUE"; else echo "FALSE"; fi; 
Unknown command 'i2c md 0x52 0x32 1' - try 'help'
FALSE

HOSTMCU> if `i2c md 0x52 0x32 1` == 31; then; echo "TRUE"; else echo "FALSE"; fi; 
Unknown command '`i2c' - try 'help'
FALSE

HOSTMCU> if $(i2c md 0x52 0x32 1) == 31; then; echo "TRUE"; else echo "FALSE"; fi; 
Unknown command '$(i2c' - try 'help'
FALSE

HOSTMCU> if $(i2c md 0x52 0x32 1) == 10; then; echo "TRUE"; else echo "FALSE"; fi; 
Unknown command '$(i2c' - try 'help'
FALSE

HOSTMCU> if $(i2c md 0x52 0x32 1) -eq 10; then; echo "TRUE"; else echo "FALSE"; fi; 
Unknown command '$(i2c' - try 'help'
FALSE

HOSTMCU> if i2c md 0x52 0x32 1 -eq 10; then; echo "TRUE"; else echo "FALSE"; fi;    
0037: 10    .
TRUE

HOSTMCU> if i2c md 0x52 0x32 1 -eq 1e; then; echo "TRUE"; else echo "FALSE"; fi; 
0037: 10    .
TRUE

HOSTMCU> if i2c md 0x52 0x32 1 -eq 13; then; echo "TRUE"; else echo "FALSE"; fi; 
0037: 10    .
TRUE

HOSTMCU> if $(i2c md 0x52 0x32 1) -eq 13; then; echo "TRUE"; else echo "FALSE"; fi; 
Unknown command '$(i2c' - try 'help'
FALSE

HOSTMCU>*

Question: As I mentioned above, my target is to compare this read value from i2c register with the second value. What I'm doing wrong in this IF statement?

Aucun commentaire:

Enregistrer un commentaire