Recent

Author Topic: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library  (Read 88946 times)

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #90 on: March 19, 2017, 03:21:31 am »
Sorry if it is off topic.

I know Raspberry Pi isn't expensive, I want to join the fun. But before I buy one, I wonder what you guys do with your Raspberry Pi?

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #91 on: March 19, 2017, 04:46:53 am »
How about making your own smartphone? https://hackaday.io/project/19035-zerophone-a-raspberry-pi-smartphone

Idea is tempting and I have put some thought on it.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #92 on: March 19, 2017, 05:39:39 am »
- I have used a RPi3 - a a bet - as my main computer for almost 8 months.... And it did not disappoint.
- Build server consists of 4 RPi3's for a total of 16 threads. Builds kernels and FPC-Lazarus
- My daughter (almost 9) uses one for all kinds of stuff and MineCraft.
- My RPi -1 and 2's are used for robotics and home automation and what not.
- I also tried an OrangePi. (Really cheap but NOT recommended: bad user experience, functions as door-opener)
- There must be about 9 in total in the house + one broken. And one camera.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1739
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #93 on: March 19, 2017, 10:44:05 am »
50+ in use for rechargeable battery testing: running 24/7 for 2 years !
Arch Linux + FPC/Laz app, cross-compiled from Windows.
Not a single failure with read-only Linux file system.

sky_khan

  • Guest
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #94 on: March 19, 2017, 11:37:38 am »
I know Raspberry Pi isn't expensive, I want to join the fun. But before I buy one, I wonder what you guys do with your Raspberry Pi?

I have a RPi2 attached to 2TB external disk. Its my low cost, low power 7/24 personal network server.  File server + scm server + dlna server.

ertank

  • Sr. Member
  • ****
  • Posts: 274
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #95 on: March 19, 2017, 01:13:24 pm »
The most known advantage of Raspberry Pi is having access to sensors, camera and alike hardware. On the other hand, you can use expensive industrial sensors, too.

I am trying to earn money with Raspberry Pi 3. Working on a software project for a device using Raspberry Pi with sensors. Device is targeted for a health sector which will count wasted material after surgeries and save some information into a database.

Just be informed that sensors Raspberry Pi uses are need to be digital for the best practice. They also need to be at certain voltage levels or else you may burn GPIO port of your Raspberry Pi.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #96 on: March 19, 2017, 01:22:42 pm »
Name the voltage level: 3.3V.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

sfischer

  • New Member
  • *
  • Posts: 37
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #97 on: March 19, 2017, 02:28:01 pm »
@mark,

pls. use SPI_Transfer. The SPI BufferSize is limited to 64Byte (pls. see SPI_BUF_SIZE_c). If you want to transfer more bytes, you have to split the IO into several 64Byte chunks. Your question about BaseReg. This is legacy and it comes from the idea, to address the register within a spi device. e.g write 2Bytes (e.g. 0x1234) to controlregister (0x01). in general it's a 3Byte transfer. SPI_Transfer is more basic and just transfers all at once. e.g SPI_Transfer(<bus>,<adr>,<cmdstring>); e.g SPI_Transfer($00,$00,#$01+#$12+#$34); or SPI_Transfer($00,$00,char($01)+char($12)+char($34)); This will transfer the data 0x011234 to an SPI-Device with ChipEnable0 (HW-Pin CE0) which is connected to SPI-Bus 0. The maximal length of <cmdstring> is SPI_BUF_SIZE_c=64.
If you want to see examples, pls. look for procedures/functions '_test' e.g. SPI_Loop_Test within rpi_hal.

hope this helps,
Stefan

enko

  • New Member
  • *
  • Posts: 21
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #98 on: July 20, 2017, 06:57:38 pm »
Hello, I'm try to understand how to use Raspberry GPIO.
I've installed last release of Lazarus on a Rasperry Pi3 Model B
Create a project with Form + 2 TButton + TMemo
Project -> Project Options ... -> Compiler Options -> Other add: -dUseCThreads 
uses sequence : cthreads, rpi_hal, pfio, ecc
First Button execute this code without errors
  Memo1.Lines.Add('SERIAL NUMBER : ' + rpi_snr);
  Memo1.Lines.Add('HW            : ' + RPI_hw); // BCM2708
  Memo1.Lines.Add('PROCESSOR     : ' + RPI_proc); // ARMv6-compatible processor rev 7 (v6l)
  Memo1.Lines.Add('MIPS          : ' + RPI_mips); // 697.95
  Memo1.Lines.Add('REVISION      : ' + RPI_rev); // rev1;256MB;1000002
  Memo1.Lines.Add('FREQUENCY     : ' + RPI_freq); // 700000;700000;900000;Hz   

Second Button execute this code quitting from the app
 if RPI_HW_Start([InitHaltOnError,InitGPIO]) then
  begin   
  // NOTHING 
  end
  else
  Memo1.Lines.Add('ERROR, something went wrong with RPI_HW_Start');

Can anyone help me ?
I need set some compiling directive ?
I net configure hardware ?
I'm newbie on linux and raspberry

Can anyone provide to me a working example ?
Thanks for all.
Enrico
Simply a Italian Programmer

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #99 on: July 21, 2017, 11:32:23 am »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #100 on: July 21, 2017, 01:25:59 pm »
Can anyone help me ?
Is it the same if run as root?

You can find more info at http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#Accessing_external_hardware
No that's not the same as root.. Why is everybody spreading that rumor over and over again.
Linux allows to create a user for a specific piece of hardware or software that requires elevation or that can be accessed and run by or through a normal user.

You don't need root. You need an update on access rights. I hate that. People may start to believe it....

Anyway @ OP Give me some compilable code. I am on an RPi for half a day's time or more.
« Last Edit: July 21, 2017, 01:28:04 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

enko

  • New Member
  • *
  • Posts: 21
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #101 on: July 21, 2017, 03:25:08 pm »
Hi, I do not have many skills in the linux world and certain things considered simple are not for me
To solve my problem if I have my application named TEST in  /home/pi/Desktop/TEST path i need input in terminal
sudo chown root /home/pi/Desktop/TEST/TEST
sudo chmod +s /home/pi/Desktop/TEST/TEST

is right, or iI misses something ?
E.
Simply a Italian Programmer

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #102 on: July 22, 2017, 08:14:05 pm »
No that's not the same as root.. Why is everybody spreading that rumor over and over again.
Linux allows to create a user for a specific piece of hardware or software that requires elevation or that can be accessed and run by or through a normal user.
You don't need root. You need an update on access rights.
A little more attention could be appreciated when reading. My question "Is it the same if run as root?" was just to do basic troubleshooting and to determine if executable would run without problems if started as root. If this simple troubleshooting succeeded then, and only then we would discuss what is the best way to do it. And wiki has a lot about proper way of handling this situation.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

polikarp87

  • Newbie
  • Posts: 1
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #103 on: October 05, 2017, 08:49:27 am »
Hello all,
first - I'm sorry for my english ;)
I just started to use RPI 3 about two weeks ago. I add rpi_hal to my program in Lazarus and after trying to compile I have still a SIGABRT error (raise.c). Without rpi_hal in uses everything is OK. Somebody could help me with that?

kris

  • Jr. Member
  • **
  • Posts: 59
Re: Lazarus / RaspberyPi rpi_hal Hardware Abstraction Library
« Reply #104 on: October 13, 2017, 09:33:40 am »
Stefan, I found your unit when I was trying to use pseudo terminals.
I wanted to run 'sudo whoami' using TProcess but sudo checks if it is ran in an interactive terminal or not, so if I just use TProcess normally, the sudo will never print any prompt. I spent lots of time trying to use forkpty like so in my code:

Code: Pascal  [Select][+][-]
  1. //(...)
  2.   function forkpty(__amaster:Plongint; __name:Pchar; __termp:Ptermios; __winp:Pwinsize):longint; cdecl; external 'libutil' name 'forkpty';
  3. //(..)
  4.  
  5.   Procedure TForm1.Button1Click(Sender: TObject);
  6.    var
  7.      stdout,stderr : string;
  8.      WS       : TWinSize;
  9.      ChildPid : Longint;
  10.      term     : termios;
  11.      Fpty     : Longint;
  12.      tName    : string;
  13.    begin
  14.      WS.ws_row:= 25;
  15.      WS.ws_col:= 80;
  16.      WS.ws_xpixel:= 0;
  17.      WS.ws_ypixel:= 0;
  18.      tName := 'xterm'#0;
  19.      //ChildPid := forkpty(@Fpty, @tName[1], @term, @WS);
  20.      ChildPid := forkpty(@Fpty, nil, nil, nil);
  21.      if ChildPid < 0 then
  22.        begin
  23.          //Result:= -1;
  24.          Exit;
  25.        end;
  26.      if ChildPid = 0 then
  27.        begin
  28.          //Child
  29.          //libUbuntu.ParseCommand('script', ['-qfc', 'sudo whoami'], @OnStdout, @OnStderr);
  30.          StdoutMemo.Lines.Add('Child!');
  31.          exit;
  32.        end;
  33.      StdoutMemo.Lines.Add('Parent!');  
  34.   //(...)
  35.   end;
  36.  

but I really get all sorts of weird behaviors. Sometimes I see "child!' and sometimes 'parent!' printed into the memo, and either way I cannot get the RunCommand (I use my own modified version that also tests for certain prompts) to work in an interactive way.

I see that you use pseudo terminals via /dev/ptmx approach. Could you please tell me, if you think I could use your approach to achieve my goal? I want to be able to use TProcess to call sudo in such a way that it would print its prompts to the stdout as if it was ran in a terminal.

 

TinyPortal © 2005-2018