-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 609c1f9
Showing
6 changed files
with
568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.lps | ||
/demo | ||
/lib | ||
/backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Ubuntu & Debian Lazarus Kurulumu | ||
Lazarus Kurulumu için | ||
https://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20amd64%20DEB/Lazarus%202.0.8/ | ||
adresinden ilgili 3 adet .deb paketini indirin bunlar... | ||
|
||
-> lazarus-project_2.0.8-0_amd64.deb | ||
-> fpc-src_3.0.4-2_amd64.deb | ||
-> fpc-laz_3.0.4-1_amd64.deb | ||
|
||
Sonra paketlerin indirildiği dizine giderek terminale sırasıyla ilgili komutları yazın | ||
|
||
sudo dpkg -i fpc-src_3.0.4-2_amd64.deb | ||
sudo dpkg -i fpc-laz_3.0.4-1_amd64.deb | ||
sudo dpkg -i lazarus-project_2.0.8-0_amd64.deb | ||
|
||
önce fpc-* paketlerinin kurulumu yapılmalı en sonunda lazarus-project_2.0.8-0_amd64.deb paketi kurulmalı. | ||
|
||
|
||
## Linux İçin İlgili HID kütüphanesinin Kurulumu | ||
Aşşağıdaki komutu terminale girerek kütüphaneyi indir. | ||
https://packages.debian.org/sid/libhidapi-dev adresinden manuel olarak indirebilirsiniz fakat. aşşağıdaki komut otomatik olarak yükleyecektir. | ||
|
||
sudo apt-get install libhidapi-dev | ||
|
||
## Örnek Kullanım | ||
|
||
Öncelikle Cihazın VendorId'si ve ProductID'sinin tespit edilmesi gerekiyor, aşşağıdadki komut bağlı usb cihazlarının listesini döndürür... | ||
|
||
lsusb | ||
|
||
Veya cihazı bilgisayara çıkartıp taktıktan hemen sonra aşşağıdaki komutla cihazın ilgili bilgileri bulunabilir. | ||
|
||
dmesg | ||
|
||
komutu ile son takılan cihazın bilgilerine ulaşabilirsiniz | ||
|
||
### Örnek Kod | ||
|
||
// Burada ilgili VendorID ve ProductID değerleri DEMO Sabitleriyle değiştirilir. | ||
const | ||
DEMO_VID = $16d0; | ||
DEMO_PID = $0949; | ||
|
||
var | ||
Device: PHidDevice; | ||
I, J, Num: Integer; | ||
Buffer: array[0..63] of Byte; | ||
|
||
begin | ||
WriteLn(Format('Cihaza Bağlanıyor %0.4x:%0.4x', [DEMO_VID, DEMO_PID])); | ||
WriteLn(); | ||
Device := THidDevice.Open(DEMO_VID, DEMO_PID, ''); | ||
if not Assigned(Device) then begin | ||
WriteLn('Cihaza Bağlanılamadı!'); | ||
WriteLn('Doğru parametreleri girdiğinizden yada Cihaz izinlerini verdiğinizden emin olun') | ||
end | ||
else begin | ||
WriteLn('Cihaza Bağlanıldı!'); | ||
WriteLn('Manufacturer: ', Device.GetManufacturerString); | ||
WriteLn('Product: ', Device.GetProductString); | ||
for I := 1 to 1000 do begin | ||
Num := Device.Read(Buffer, SizeOf(Buffer)); | ||
for J := 0 to Num - 1 do begin | ||
Write(Format('%0.2x ', [Buffer[J]])); | ||
end; | ||
Write(#13); | ||
end; | ||
WriteLn(); | ||
WriteLn('Cihaz Kapatılıyor.'); | ||
Device.Close; | ||
end; | ||
end; | ||
|
||
hidapi.pas kodlarında kütüphane fonksiyonları, örnek uygulama ise demo dosyalarında mevcut | ||
|
||
## Demo'yu Çalıştırma | ||
Uygulama derlendikten sonra | ||
Cihaza Erişebilmek için ilgili izinlerin verilmesi gerekiyor. | ||
İzinler için kalıcı değişiklik sağlamak adına udev kurallarının değiştirilmesi gerekiyor (burası daha sonra Production ortamında.. test için gerekli değil..) | ||
|
||
Basitce ilk test için aşşağıdaki komut izinlerin verilmesi için yeterli olacaktır. | ||
|
||
sudo chmod 777 /dev/hidraw4 | ||
|
||
Sonra direkt olarak programı admin olarak çalıştırın. | ||
|
||
sudo ./demo | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CONFIG> | ||
<ProjectOptions> | ||
<Version Value="9"/> | ||
<General> | ||
<Flags> | ||
<MainUnitHasCreateFormStatements Value="False"/> | ||
<MainUnitHasTitleStatement Value="False"/> | ||
</Flags> | ||
<SessionStorage Value="InProjectDir"/> | ||
<MainUnit Value="0"/> | ||
<Title Value="demo"/> | ||
<UseAppBundle Value="False"/> | ||
<ResourceType Value="res"/> | ||
</General> | ||
<i18n> | ||
<EnableI18N LFM="False"/> | ||
</i18n> | ||
<VersionInfo> | ||
<StringTable ProductVersion=""/> | ||
</VersionInfo> | ||
<BuildModes Count="1"> | ||
<Item1 Name="Default" Default="True"/> | ||
</BuildModes> | ||
<PublishOptions> | ||
<Version Value="2"/> | ||
</PublishOptions> | ||
<RunParams> | ||
<local> | ||
<FormatVersion Value="1"/> | ||
</local> | ||
</RunParams> | ||
<Units Count="1"> | ||
<Unit0> | ||
<Filename Value="demo.lpr"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit0> | ||
</Units> | ||
</ProjectOptions> | ||
<CompilerOptions> | ||
<Version Value="11"/> | ||
<Target> | ||
<Filename Value="demo"/> | ||
</Target> | ||
<SearchPaths> | ||
<IncludeFiles Value="$(ProjOutDir)"/> | ||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
</SearchPaths> | ||
</CompilerOptions> | ||
<Debugging> | ||
<Exceptions Count="3"> | ||
<Item1> | ||
<Name Value="EAbort"/> | ||
</Item1> | ||
<Item2> | ||
<Name Value="ECodetoolError"/> | ||
</Item2> | ||
<Item3> | ||
<Name Value="EFOpenError"/> | ||
</Item3> | ||
</Exceptions> | ||
</Debugging> | ||
</CONFIG> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
program cidlinux; | ||
|
||
|
||
// 'sudo apt-get install libhidapi-dev' komutu gerekli hid kütüphanesini indirmek için! | ||
// 'https://packages.debian.org/sid/libhidapi-dev' | ||
|
||
// modeswitch | ||
{$modeswitch autoderef} | ||
|
||
uses | ||
sysutils, hidapi; | ||
|
||
|
||
procedure EnumerationDemo; | ||
var | ||
EnumList, EnumItem: PHidDeviceInfo; | ||
Path: String; | ||
Vid, Pid: Word; | ||
ProductName: UnicodeString; | ||
|
||
begin | ||
WriteLn('Cihaza Erişebilmek için ilgili izinlerin verilmesi gerekiyor'); | ||
WriteLn('İzinler için kalıcı değişiklik sağlamak adına udev kurallarının değiştirilmesi gerekiyor'); | ||
WriteLn('Yada Basitce { sudo chmod 777 /dev/hidraw4 } komutuyla yada direkt olarak programı { sudo ./demo } olarak çalıştırın.'); | ||
WriteLn(); | ||
|
||
// hidapi'den bütün cihazların listesini getirir | ||
EnumList := THidDeviceInfo.Enumerate(0, 0); | ||
|
||
EnumItem := EnumList; | ||
while Assigned(EnumItem) do begin | ||
Path := EnumItem.Path; | ||
Vid := EnumItem.VendorID; | ||
Pid := EnumItem.ProductID; | ||
ProductName := PCWCharToUnicodeString(EnumItem.ProductString); | ||
WriteLn(Format('Found: %s (%0.4x:%0.4x) at: %s', [ProductName, Vid, Pid, Path])); | ||
EnumItem := EnumItem.Next; | ||
end; | ||
WriteLn(); | ||
EnumList.Free; | ||
end; | ||
|
||
|
||
procedure OpenAndReadDemo; | ||
const | ||
// Burada ilgili VendorID ve ProductID değerleri DEMO Sabitleriyle değiştirilir. | ||
DEMO_VID = $16d0; | ||
DEMO_PID = $0949; | ||
|
||
var | ||
Device: PHidDevice; | ||
I, J, Num: Integer; | ||
Buffer: array[0..63] of Byte; | ||
|
||
begin | ||
WriteLn(Format('Cihaza Bağlanıyor %0.4x:%0.4x', [DEMO_VID, DEMO_PID])); | ||
WriteLn(); | ||
// Device := THidDevice.OpenPath('/dev/hidraw4'); direk path vererek bağlanmak için... | ||
Device := THidDevice.Open(DEMO_VID, DEMO_PID, ''); | ||
if not Assigned(Device) then begin | ||
WriteLn('Cihaza Bağlanılamadı!'); | ||
WriteLn('Doğru parametreleri girdiğinizden yada Cihaz izinlerini verdiğinizden emin olun') | ||
end | ||
else begin | ||
WriteLn('Cihaza Bağlanıldı!'); | ||
WriteLn('Manufacturer: ', Device.GetManufacturerString); | ||
WriteLn('Product: ', Device.GetProductString); | ||
for I := 1 to 1000 do begin | ||
Num := Device.Read(Buffer, SizeOf(Buffer)); | ||
for J := 0 to Num - 1 do begin | ||
Write(Format('%0.2x ', [Buffer[J]])); | ||
end; | ||
Write(#13); | ||
end; | ||
WriteLn(); | ||
WriteLn('Cihaz Kapatılıyor.'); | ||
Device.Close; | ||
end; | ||
end; | ||
|
||
|
||
begin | ||
EnumerationDemo; | ||
OpenAndReadDemo; | ||
end. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CONFIG> | ||
<ProjectOptions> | ||
<Version Value="11"/> | ||
<General> | ||
<Flags> | ||
<MainUnitHasCreateFormStatements Value="False"/> | ||
<MainUnitHasTitleStatement Value="False"/> | ||
<MainUnitHasScaledStatement Value="False"/> | ||
<UseDefaultCompilerOptions Value="True"/> | ||
</Flags> | ||
<SessionStorage Value="InProjectDir"/> | ||
<MainUnit Value="0"/> | ||
<Title Value="hidapi"/> | ||
<UseAppBundle Value="False"/> | ||
<ResourceType Value="res"/> | ||
</General> | ||
<BuildModes Count="1"> | ||
<Item1 Name="Default" Default="True"/> | ||
</BuildModes> | ||
<PublishOptions> | ||
<Version Value="2"/> | ||
<UseFileFilters Value="True"/> | ||
</PublishOptions> | ||
<RunParams> | ||
<FormatVersion Value="2"/> | ||
<Modes Count="0"/> | ||
</RunParams> | ||
<Units Count="1"> | ||
<Unit0> | ||
<Filename Value="hidapi.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
</Unit0> | ||
</Units> | ||
</ProjectOptions> | ||
<CompilerOptions> | ||
<Version Value="11"/> | ||
<Target> | ||
<Filename Value="hidapi"/> | ||
</Target> | ||
<SearchPaths> | ||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
</SearchPaths> | ||
<CodeGeneration> | ||
<RelocatableUnit Value="True"/> | ||
</CodeGeneration> | ||
</CompilerOptions> | ||
<Debugging> | ||
<Exceptions Count="3"> | ||
<Item1> | ||
<Name Value="EAbort"/> | ||
</Item1> | ||
<Item2> | ||
<Name Value="ECodetoolError"/> | ||
</Item2> | ||
<Item3> | ||
<Name Value="EFOpenError"/> | ||
</Item3> | ||
</Exceptions> | ||
</Debugging> | ||
</CONFIG> |
Oops, something went wrong.