Lazarus

Programming => General => Topic started by: Mi-Ki on June 14, 2018, 09:18:15 am

Title: fpsystem - linux
Post by: Mi-Ki on June 14, 2018, 09:18:15 am
Hello.

I have an MCP23017 expander.

This works
fpsystem('sudo i2cset -y 1 0x21 0x13 0x00');
fpsystem('sudo i2cset -y 1 0x21 0x13 0xFF');

How to read the expander status?

This does not work
Code: Pascal  [Select]
  1.  Var
  2.    S: Integer;
  3.  begin
  4.    S:= fpsystem('sudo i2cget -y 1 0x21 0x13');
  5.    Label1.Caption:= IntToStr(S);
  6.  end;        

Title: Re: fpsystem - linux
Post by: mig-31 on June 14, 2018, 01:06:35 pm
If i2cget return result to the pipe, use TProcess to read pipe output.

http://wiki.freepascal.org/Executing_External_Programs#TProcess (http://wiki.freepascal.org/Executing_External_Programs#TProcess)
Title: Re: fpsystem - linux
Post by: Mi-Ki on June 14, 2018, 06:55:28 pm
It works, thank you  :D