🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.delphi
Article #345427

Re: Jeszcze raz DLL, tym razem tylko na RPi

#345427
From: krolikbest
Date: Sat, 10 Dec 2016 18:36
73 lines
3439 bytes
W dniu 2016-12-09 o 11:17, stchebel@gmail.com pisze:
> Witam,
> Jeszcze raz dzięki za sugestie w siostrzanych wątkach Lazarus/RPi/DLL/FTDI..
> Zgodnie z Waszymi sugestiami zrobiłem programik na RPi. Jak zwykle forma, na niej Button i Label. Cały program wygląda tak:
>
> unit Unit1;
>
> {$mode objfpc}{$H+}
>
> interface
>
> uses
>   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,Messages
>   ,ComCtrls,Variants,DynLibs;
>
> type
>
>   { TForm1 }
>
>   TForm1 = class(TForm)
>     Button1: TButton;
>     Label1: TLabel;
>     procedure Button1Click(Sender: TObject);
>     procedure FormCreate(Sender: TObject);
>   private
>     { private declarations }
>   public
>     { public declarations }
>   end;
>
> var
>   Form1: TForm1;
>   FT_HANDLE: Dword=0;
>   ftresult: integer;
>   DLL_Handle:THandle;
>   FT_Open_Fun:function (PVDevice:Integer; ftHandle:Pointer ) : integer ; stdcall ;
> implementation
>
> {$R *.lfm}
>
> { TForm1 }
>
> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   if Assigned(FT_Open_Fun) then
>   ftresult:=FT_Open_Fun(0,@FT_HANDLE)
>   else
>   ShowMessage('Dupa blada');
>   Label1.Caption:=IntToStr(ftresult);
>
> end;
>
> procedure TForm1.FormCreate(Sender: TObject);
> begin
>   DLL_Handle:=LoadLibrary('/home/pi/Lazarus_Projects/Open_Port/lib/arm-linux/libftd2xx.so.1.3.6');
>   Pointer(FT_Open_Fun):=GetProcAddress(DLL_Handle,'FT_Open');
> end;
>
> end.
>
> Program działa, ale niestety zwraca mi nieprawidłową wartość z funkcji FT_Open_Fun (skojarzona z funkcją FT_Open z biblioteki). Zwraca mi wartość 2, co jest kodem błędu FT_DEVICE_NOT_FOUND.Powinno zwrócić wartość 0. Pierwsze co pomyślałem,to jest jakiś problem z moim HW. Nic podobnego, odpalam program z examples/EEPROM/read (załączony do bibliotek FTDI) i wszystko jest OK. Elegancko otwiera port i prawidłowo odczytuje zawartość EEPROM'a. Biblioteki do RPi pobieram stąd:
>
> http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-arm-v6-hf-1.3.6.tgz
>
> Jest tam trochę opisów jak to zainstalować i takie tam..
>
> Macie Koledzy jakiś pomysł?
>
>
A z jakimi uprawnieniami to robisz? Zalecam root (na użytkowniku pi mam 
wiele ograniczeń co do np. dostępności do GPIO). Lazarusa jak 
uruchamiasz, bo ja sudo starlazarus z basha. Biblioteke jak instalowałeś 
jako root czy pi czy jeszcze coś innego?
Technical Details
Message-ID: <584c4b28$0$5155$65785112@news.neostrada.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-b-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
References: <9eea4c55-87ef-4f37-a515-edd26cd7e7ea@googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-b-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Subject: Re: Jeszcze raz DLL, tym razem tylko na RPi
Newsgroups: pl.comp.lang.delphi
References: <9eea4c55-87ef-4f37-a515-edd26cd7e7ea@googlegroups.com>
From: krolikbest <krolikbest@wp.pl>
Date: Sat, 10 Dec 2016 19:36:22 +0100
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:45.0) Gecko/20100101 Thunderbird/45.5.1
MIME-Version: 1.0
In-Reply-To: <9eea4c55-87ef-4f37-a515-edd26cd7e7ea@googlegroups.com>
Lines: 73
Message-ID: <584c4b28$0$5155$65785112@news.neostrada.pl>
Organization: Telekomunikacja Polska
NNTP-Posting-Host: 178-37-27-189.adsl.inetia.pl
X-Trace: 1481394984 unt-rea-a-01.news.neostrada.pl 5155 178.37.27.189:11167
X-Complaints-To: abuse@news.neostrada.pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit