Forum > Debugger
Raspbian: running a program using PascalIO from the IDE
GuidoJ:
Hello!
I'm a very experienced Delphi developer and I'm taking first steps on a Raspberry PI 4 with Raspbian and FPC+Lazarus. Of course, I have next to no knowledge about LINUX. My current task: Switch an LED on and off.
I downloaded the PascalIO package, then wrote some simple code that should turn an IO port on/off.
var
IOvalue : boolean;
procedure TForm1.Button1Click(Sender:TObject);
var
pin: TGpioLinuxPin;
begin
IOvalue := not IOvalue;
pin := TGpioLinuxPin.Create(12);
pin.Direction := gdOut;
pin.Value := IOvalue;
pin.Destroy;
end.
If I start the program from the IDE, nothing happens on pushing the button.
Setting a breakpoint and stepping through the code makes the LED flash.
From the console I need to use
sudo ./MyGPIOtest
to start the program and get a response from the LED.
The code seems to be OK.
Any suggestions, how to make the program run correctly from within the IDE?
Thank you for your help!
MarkMLl:
Without having tried it, my suspicion is that when you destroy the pin you're setting it to be an input again so it stops driving the LED.
BTW, it's "Linux", and is named after its initial developer rather than being an initialism.
MarkMLl
GuidoJ:
Everything works fine, outside the IDE or during singlestepping. The LED even stays on after terminating the program.
MarkMLl:
--- Quote from: GuidoJ on March 02, 2021, 05:13:26 pm ---Everything works fine, outside the IDE or during singlestepping. The LED even stays on after terminating the program.
--- End quote ---
If you're running it in the IDE, how are you giving it sudo? Have you made sure that your normal user ID is a member of the gpio group?
MarkMLl
GuidoJ:
Hi Mark!
Four cases:
1. console -> "sudo ./MyGPIOtest" - result OK
2. start in IDE [F9] - LED does not react to button
3. start in IDE [F9], singlestepping [F8] - result OK
4. start in IDE without debugger [ctrl][shift][F9] - LED does not react to button
Cases 2 and 4 - running inside the IDE but not singlestepping [F8] through the code - are the problem.
GPIO group? Ah... "sudo adduser pi gpio" -> the user "pi" is already in the group "gpio"
So the answere is "yes".
Thanks, Guido
Navigation
[0] Message Index
[#] Next page