Everything works fine, outside the IDE or during singlestepping. The LED even stays on after terminating the program.
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".
1. console -> "sudo ./MyGPIOtest" - result OKDoes "./MyGPIOtest" without sudo works? If not, then sudo gives some permissions that debugger already has, but IDE and simple command line do not have? Normally, gpio group should be enough, so you should investigate why sudo makes the difference in your case.
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
Without sudo the LED does not react, so sudo (root rights) are needed. That is also stated in the documentation of the PascalIO Package.
I did some tracing an added some more code. The error occurs at FpOpen('/sys/class/gpio//gpio12/direction', O_WRONLY); Error 9: Bad file number.
I checked UserID, GroupID and ProcessID with and without debugging, but they where the same.
Is there a way to run the program from the IDE with root privileges? Maybe via "run"->"run parameters"->"launching application"?
Does that actually exist?root@raspberrypi:/home/pi# ls -l /sys/class/gpio
That's quite a handful... but looking into remote debugging is on my list anyway 8)
PascalIO does exactly what you suggested, only encapsulated in a lot of functions. They create and destroy the files in every call, therefore the file ../gpio12 is visible only if you stop the program at the correct moment. I did this and...
If I start the lazarus IDE as root my program works from within the IDE! Not a nice thing to do, but is does the trick.
That's lousy design IMO.My thought exactly!
I'm sorry to say, but the remote debugging stuff is way out of my league right now. Too many unknown concepts and conventions.
I'll stick with the root rights for the IDE and continue learning about Linux and the Raspi hardware. I'll revisit remote debugging much later.
Does is work, when you are not singlestepping? That's where my problem started.
tunnelling Lazarus through the link
tunnelling Lazarus through the link
What do you mean by that?
Just to give you an update: I spend the last few days figuring out, how to install FPC 3.2.0 and Lazarus 2.0.12 on my Raspberry PI 4. It turned out, I had to compile from the sources.
For now, apart from one minor error, Lazarus 2.0.12 seems to work.