Recent

Author Topic: fpsystem - linux  (Read 981 times)

Mi-Ki

  • New member
  • *
  • Posts: 17
fpsystem - linux
« 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;        


mig-31

  • Full Member
  • ***
  • Posts: 244
Re: fpsystem - linux
« Reply #1 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
« Last Edit: June 14, 2018, 01:09:03 pm by mig-31 »
Lazarus 2.0.0 - CentOS 7.x, Mageia 6.1

Mi-Ki

  • New member
  • *
  • Posts: 17
Re: fpsystem - linux
« Reply #2 on: June 14, 2018, 06:55:28 pm »
It works, thank you  :D