Recent

Author Topic: fpsystem - linux  (Read 2834 times)

Mi-Ki

  • Jr. Member
  • **
  • Posts: 74
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

  • Sr. Member
  • ****
  • Posts: 305
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.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

Mi-Ki

  • Jr. Member
  • **
  • Posts: 74
Re: fpsystem - linux
« Reply #2 on: June 14, 2018, 06:55:28 pm »
It works, thank you  :D

 

TinyPortal © 2005-2018