Re: [fpc-pascal] USB Human Interface Devices

2019-08-03 Thread Jean SUZINEAU

  
  
Zadig

I found a way to make  my test with libusb-win32 work. You just need to install a specific driver for the usb device you want to see.
This can be done using Zadig ( https://zadig.akeo.ie/ ). If you change the driver to "libusbK" or "libusb-win32" for a certain device with Zadig, it will appear with lsusb_libusb-win32\lsusb.exe .
But it doesn't change anything for the version with libusb-compat, lsusb_libusb-compat-msys2_mingw64\lsusb.exe wich shows nothing.
And it doesn't change anything either to the version with libusb, https://github.com/jsuzineau/pascal_o_r_mapping/releases/tag/2019_08_03_lsusb which continue to show all the usb devices.
 
I have also tried libusbK ( http://libusbk.sourceforge.net/UsbK3/index.html ).
You can download it at  https://sourceforge.net/projects/libusbk/

There are delphi examples in the subdirectory bindings\examples_delphi .

They can be compiled easily with freepascal, you just need to compile in delphi mode.
For "bindings\examples_delphi\enumerate.dpr" you can use this command line ( from a cmd in the directory examples_delphi)
   C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.exe -MDelphi -Scghi -O1 -g -gl -l -vewnhibq -Filib\x86_64-win64 -Fu. -FUlib\x86_64-win64 -FE. -oenumerate.exe enumerate.dpr

For "bindings\examples_delphi\opendevice.dpr" it didn't found unit UExampleHelpers. I didn't investigated further but it seems you can find the unit at :
https://github.com/SimaWB/libusbkDelphi/blob/master/UExampleHelpers.pas
  

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] USB Human Interface Devices

2019-08-03 Thread Jean SUZINEAU
I've forgotten to give the command line to compile (change 
"C:\lazarus\fpc\3.0.4\bin\x86_64-win64" to your fpc installation):


C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.exe -MObjFPC -Scghi -O1 -g -gl 
-l -vewnhibq -Filib\x86_64-win64 -Fu..\pas-libusb\src -Fu. 
-FUlib\x86_64-win64 -FE. -olsusb.exe lsusb.lpr



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] USB Human Interface Devices

2019-08-03 Thread Jean SUZINEAU

  
  
I've made another (unsuccessful) test, using libusb-compat (
  https://github.com/libusb/libusb-compat-0.1/wiki ). 

It's a compatibility layer which allows to use the new libusb
  1.xx through the old API of libusb 0.1
I get nearly the same results as with libusb-win32 (just "Bus:
  001" instead "Bus: bus-0"), maybe there's an error in my code.
If you want to test, I've put temporarily a zip of my test
  directory at http://mars42.com/test_libusb-compat.zip
  .
I got the dlls  through msys2 in this way:
You can download MSYS2 (http://www.msys2.org/ ) by
  http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20190524.exe

After complete installation, to install libusb type on the
  command line:
   pacman -S mingw64/mingw-w64-x86_64-libusb
and to install libusb-compat type :

 pacman -S mingw64/mingw-w64-x86_64-libusb-compat-git
  
  In subdirectory mingw64\bin of your installation you get:
     libusb-1.0.dll    the libusb dll from https://libusb.info/
     libusb-0-1-4.dll  the libusb-compat dll with version 0.1
  functions names, and which call libusb-1.0.dll

I'm not sure of the value of PATH_MAX to define in libusb.pas
  because  in the dll PATH_MAX is taken from limits.h (
  mingw64\x86_64-w64-mingw32\include\limits.h) where it's first
  defined to PATH_MAX=260 but if _POSIX_ is defined then it's
  redefined to 512. Of course this can create havoc in the
  definition of USBDevice if the pointer "bus : PUSBBus;" isn't
  defined at the right place in memory...
  
  For getting limits.h in subdirectory
  mingw64\x86_64-w64-mingw32\include , type :
   pacman -S mingw-w64-x86_64-headers-git

  

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] USB Human Interface Devices

2019-08-03 Thread Jean SUZINEAU

  
  
I tried to make an import for libusb-1.0.22.7z from
  https://libusb.info/ .
  The import unit is very buggy but I could make a small program to
  list the usb devices.
  On my machine, it gives the same results that the example program
  libusb-1.0.22\examples\bin64\testlibusb.exe
  
  I've published this program and the import at
https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/tools/lsusb
  You can get the corresponding binaries in this release
https://github.com/jsuzineau/pascal_o_r_mapping/releases/tag/2019_08_03_lsusb
  .
I used lazarus to generate and compile the console app, but I
  verified, you can compile it from the command line, you'll just
  have to change the path to you freepascal installation.
I converted the libusb.h to libusb.pas with h2pas from the
  lazarus plugin H2Paswizard (
  https://wiki.freepascal.org/H2Paswizard ). 

You'll find the project for H2Paswizard at
https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/tools/lsusb/include/libusb-1.0/project1.h2p
It's a very quick an dirty conversion. In h2paswizard I added  a
  rename from LIBUSB_CALL to WINAPI.
I got some problems with var parameters in
functions for example I needed to change
   function libusb_open(dev: Plibusb_device; var
  dev_handle:Plibusb_device_handle):longint;cdecl;external name
  'libusb_open';
  into
      function libusb_open(dev: Plibusb_device; dev_handle:PPlibusb_device_handle):longint;cdecl;external
  name 'libusb_open'; 

I think this can be fixed by tuning some details of the import.


  

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] USB Human Interface Devices

2019-08-03 Thread Jean SUZINEAU

  
  
With libusb-win32 I tried to make a small program to list the usb
  devices. 
  I discovered that the constant PATH_MAX had changed from 4096 in
  pas-libusb to 512 in libusb-win32-bin-1.2.6.0\include\lusb0_usb.h
  line 21 . This was causing an exception.
Now the program works but just output "Bus: bus-0" with no
  devices.
  libusb-win32 comes with two test programs testlibusb-win.exe and
  testlibusb.exe but don't find any devices too. I think that for
  some reason libusb-win32 doesn't work with recent Windows (I'm
  testing on Windows 10).
If you want to test, I've put temporarily a zip of my test
  directory at http://mars42.com/test_libusb-win32.zip .
I've seen https://sourceforge.net/p/libusb-win32/wiki/Home/ that
  they advice to migrate to the libusb-1.0 form
  http://libusb.info.


  

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] PPCJVM Android JVM target and building to dex

2019-08-03 Thread Sven Barth via fpc-pascal
Mgr. Janusz Chmiel  schrieb am Sa., 3. Aug. 2019,
11:48:

> Many of advanced users and developers have tried PPCJVM. It is really
> possible to create fully functioning Android applications. And because
> it is even possible to access methods from previously compiled .jar
> files including Mysql.jar and others, Pascal language have very big
> potential.
> But it has a very remarkable hook.
> Latest JDK for WIndows from Oracle do not support old versions of Apache
> ANT, so it is not possible to build .dex files from classes, which have
> been previously generated by using PPCJVM.
> So The future or Pascal compilation to .dex fomrat is severely
> disadvantaged. Because old JDK 7 X release can produce .dex files and
> only specific versions of Android build tools.
> So The reality is, that PPCJVM can produce reliable classes, but there
> is not too much projects, which can convert those .class files to dex
> format.
> Does somebody of you know about The solution to this issue?
> I Am afraid, that this situation can lead to The fact, that PPCJVM will
> not support ANDROID target JVM for too long times. If something positive
> will not happen to generate while using newest JRE and JDK.
>

Hmm? The important part of converting the .class files to classes.dex is
the dx utility which is part of the Android toolchain. Apache ANT is only a
build system like Make or Gradle (which seems to be /the/ hype for Android
development). My first PPCJVM Android app I even built without any build
scripts completely by hand (see here:
https://wiki.freepascal.org/FPC_JVM_Android_Development#Building_an_Android_application
). The process might be a bit more involved nowadays, but in principle it
will still be the same.

TL;DR: the compiler is not the problem. But maybe the build chain needs to
be adjusted.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] PPCJVM Android JVM target and building to dex

2019-08-03 Thread Mgr. Janusz Chmiel
Many of advanced users and developers have tried PPCJVM. It is really 
possible to create fully functioning Android applications. And because 
it is even possible to access methods from previously compiled .jar 
files including Mysql.jar and others, Pascal language have very big 
potential.

But it has a very remarkable hook.
Latest JDK for WIndows from Oracle do not support old versions of Apache 
ANT, so it is not possible to build .dex files from classes, which have 
been previously generated by using PPCJVM.
So The future or Pascal compilation to .dex fomrat is severely 
disadvantaged. Because old JDK 7 X release can produce .dex files and 
only specific versions of Android build tools.
So The reality is, that PPCJVM can produce reliable classes, but there 
is not too much projects, which can convert those .class files to dex 
format.

Does somebody of you know about The solution to this issue?
I Am afraid, that this situation can lead to The fact, that PPCJVM will 
not support ANDROID target JVM for too long times. If something positive 
will not happen to generate while using newest JRE and JDK.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal