Recent

Author Topic: Raspbian: running a program using PascalIO from the IDE  (Read 9175 times)

GuidoJ

  • New Member
  • *
  • Posts: 14
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #15 on: March 04, 2021, 09:02:51 am »
Quote
That's lousy design IMO.
My thought exactly!

GuidoJ

  • New Member
  • *
  • Posts: 14
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #16 on: March 04, 2021, 02:20:29 pm »
Hi Mark!

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.

Thank you for your help!

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #17 on: March 04, 2021, 02:47:47 pm »
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.

You DEFINITELY do not need to run the IDE as root. I've now got Lazarus/FPC on a test RPi, and I'm successfully single-stepping through code that reads/writes GPIO bits using the sysfs API (i.e. the pseudo-files in /sys/class/gpio). My usual user ID is a member of the gpio group, apart from that nothing special.

In my case I'm SSHing into the RPi and tunnelling Lazarus through the link, but I'd certainly not expect that to be the magic factor that got something working.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

GuidoJ

  • New Member
  • *
  • Posts: 14
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #18 on: March 04, 2021, 04:26:38 pm »
Does is work, when you are not singlestepping? That's where my problem started.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #19 on: March 04, 2021, 04:50:12 pm »
Does is work, when you are not singlestepping? That's where my problem started.

Most if not all of the time :-)

I /might/, /possibly/, have seen it falling straight through (i.e. no GUI display) on one or perhaps two occasions. My suspicion is that not all of the function keys etc. are getting through to the IDE, i.e. Raspbian (or whatever it's called these days) might be intercepting some of them for its own use.

I've got a note in my source that some of the GPIO manipulation failed to work using gdbserver and that I ended up running the program (not the IDE) as root to check one final detail... I mention that for completeness.

I've got occasional lockups when setting a breakpoint inside button handlers etc., but that's unconnected.

MarkMLl
« Last Edit: March 04, 2021, 05:07:48 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dseligo

  • Hero Member
  • *****
  • Posts: 1196
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #20 on: March 04, 2021, 11:25:36 pm »
tunnelling Lazarus through the link

What do you mean by that?

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #21 on: March 05, 2021, 08:53:07 am »
tunnelling Lazarus through the link

What do you mean by that?

SSH has the capability of tunnelling X11 network traffic, you need this in ssh_config


Host *
#   ForwardAgent no
ForwardX11 yes
...


Then all you have to do is type in the name of the IDE (I usually go via a shell script which has both the Lazarus and FPC version numbers in it) and it will appear on your local screen.

Not very efficient particularly if an X11 program generates excessive input device (mouse etc.) traffic, but it's fine for headless development systems.

MarkMLl
« Last Edit: March 05, 2021, 09:47:10 am by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

GuidoJ

  • New Member
  • *
  • Posts: 14
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #22 on: March 07, 2021, 01:35:06 pm »
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.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #23 on: March 07, 2021, 03:22:33 pm »
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.

I admit that that's normally how I do it, I normally start off with the FPC project's tarball (rather than whatever comes with the distro) and was only able to find 3.0.2 the other day.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

GuidoJ

  • New Member
  • *
  • Posts: 14
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #24 on: March 07, 2021, 04:48:20 pm »
Another strange concept - at least after 35 years of windows. I started with turbo pascal for windows  ;)

Amazon have delivered a Raspberry PI zero w to me. Now I can start looking into remote debugging. I plan on using the PI zero for my heating project.
« Last Edit: March 07, 2021, 04:52:27 pm by GuidoJ »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #25 on: March 07, 2021, 05:19:38 pm »
Remember that if you can run Linux on it, you can run Lazarus/FPC/gdb on it. At that point if you can SSH into it you can effectively do /local/ debugging.

I can't speak for gdbserver to a non-local process, so suggest that you try it locally first. The major gotchas are (a) do not modify or rebuild your program between starting the program using gdbserver and using the IDE to start debugging and (b) the command line parameters are applied to gdbserver+program: not in the IDE.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

GuidoJ

  • New Member
  • *
  • Posts: 14
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #26 on: March 08, 2021, 09:20:21 am »
Hi Mark!
I build three installation files for FPC 3.2.0 and Lazarus 2.0.12
  fpc-laz_3.2.0_armhf.deb
  fpc-src_3.2.0_armhf.deb
  lazarus-project_2.0.12-0_armhf.deb

see -> https://wiki.freepascal.org/Build_current_FPC_and_Lazarus_for_Raspbian
I you like, I can prepare a download for you.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #27 on: March 08, 2021, 10:07:06 am »
I'm fine thanks. Been doing it since something like Lazarus 0.9.24.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

GuidoJ

  • New Member
  • *
  • Posts: 14
Re: Raspbian: running a program using PascalIO from the IDE
« Reply #28 on: March 18, 2021, 04:41:41 pm »
Another update:
I have a basic webserver running that reads out and displays some (currently 4) 1-wire temperature sensors, is able to switch a relay, and handles some configuration settings.
My PI zero now has Raspbian Light installed - very compact; I don't really need the GUI for my application.

I switched from PascalIO to Raspbians pigpio package and now handle the GPIO pins via shell calls:

Code: Pascal  [Select][+][-]
  1. uses ..., Unix, ...;
  2. [..]
  3. function SetPin(pinNo, State:integer):longint;
  4. var
  5.   st : string;
  6. begin
  7.   st:=format('pigs w %d %d', [pinNo, State]);
  8.   result:=fpSystem(st);
  9. end;
  10. [..]

That may be much slower, but - as I want to react to a weather forecast - split second timing is not an issue. The function above can do about 130 changes per second on a Pi4; more than adequate.
The calls to "pigs" do not require root privileges and debugging from within the IDE works fine.
« Last Edit: March 18, 2021, 05:02:36 pm by GuidoJ »

 

TinyPortal © 2005-2018