Re: [fpc-pascal] TParamFlags and fpc 3.2.0.
Am 26.07.2019 um 14:50 schrieb fredvs: But, imho, there is problem with the behavior of fpc-ptypeinfo and filter in TParamFlags. Dont worry, I will not annoy you with this. There is no problem with PTypeInfo or TParamFlags. The tests for these functionalities pass without any issues on multiple platforms. You should fix the cause (ignoring hidden parameters) and not the symptoms (hidding "$self"), because the latter will cause you a headache further down (e.g. if you have a function with an open array parameter which will have a "$highArgN" parameter for each open array). That said the code I showed you had an issue which might explain the behaviour you got: === code begin === for int1:= 0 to paramcount - 1 do begin with params[int1] do begin // replace previous line with: with params[count] do begin flags:= tparamflags( {$ifdef mse_fpc_3_2}wordset{$else}byteset{$endif}(pbyte(po1)^)); inc(po1,{$ifdef mse_fpc_3_2}2{$else}1{$endif}); // the following code block of mine {$ifdef mse_fpc_3_2} // skip hidden parameters ($self, $high, etc.) if pfHidden in flags then Continue; {$endif} Inc(count); // up until here, needs to be further down (see below) // so remove this block again name:= getshortstring(po1); typename:= getshortstring(po1); if (typename = 'WideString') or (typename = 'UnicodeString') then begin typename:= 'msestring'; end else begin if typename = 'LongInt' then begin typename:= 'Integer'; end else begin if typename = 'Double' then begin typename:= 'Real'; end; end; end; end; // I think this is the end of the with-clause // we adjust the code a little bit as the continue is not needed at this location // this way we always increase the count on < 3.2 and only if it's not hidden // on >= 3.2; we need to put this at the end so that po1 is advanced correctly {$ifdef mse_fpc_3_2} // skip hidden parameters ($self, $high, etc.) if not (pfHidden in flags) then {$endif} Inc(count); end; === code end === This should hopefully solve the issue. Regards, Sven ___ 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
You can compile console projects with Lazarus, and even use non visual components and datamodules. I've coded a dll (several hundred thousand lines of code too) which is used by console programs on web servers. I compile the dll with the same lazarus project in Lazarus for Windows and in Lazarus for Linux. The dll include datamodules with dataset components. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TParamFlags and fpc 3.2.0.
Hello Sven. I did try your code but it has still problems. Here the result I get: procedure onexec(var elfPointer ... procedure tmainfo.onexec(var elfPointer It should be: procedure onexec(const sender: TObject); ... procedure tmainfo.onex(const sender: TObject); There is something strange in the behavior of "if pfHidden in flags then". It is the reason why, after many try, I stop to use filter in TParamFlags. In last mse commit it keep all default parameters and do the filter when parsing the method-code in the editor. It works perfectly. And to fix the parameter-matcher, a work-around ignore the first parameter like this: function parametersmatch(const a: ptypeinfo; const b: methodparaminfoty): boolean; var a1: methodparaminfoty; {$if FPC_FULLVERSION > 030200} params1: paraminfoarty; x : integer; {$endif} begin getmethodparaminfo(a,a1); {$if FPC_FULLVERSION > 030200} setlength(params1,length(a1.params)-1); for x:=0 to length(params1) -1 do params1[x] := a1.params[x+1]; a1.params := params1; {$endif} result:= parametersmatch1(a1,b); end; So, mse-ide side, with last commit, all is fixed, mse is still in the game and is fpc > 3.1.0 compatible. https://github.com/mse-org/mseide-msegui/commit/44f515f90ba5b8c553c7b5b52d845e870e3c9de3 But, imho, there is problem with the behavior of fpc-ptypeinfo and filter in TParamFlags. Dont worry, I will not annoy you with this. Many thanks Sven and your help is highly appreciated. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TParamFlags and fpc 3.2.0.
Hello Sven. Thanks for your code, I will deeply study it. Write you later. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ 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
Hi! Am Freitag, den 26.07.2019, 15:56 +0200 schrieb Marc Santhoff: > On Thu, 2019-07-25 at 19:40 -0700, Brian wrote: > > Try the libusb library Free Pascal interface .. but be aware of his > > license > > requirements. It works well. > > > > http://johann-glaser.blogspot.com/2012/07/libusb-for-pascal.html > > http://johann-glaser.blogspot.com/2012/09/libusb-10-for-pascal.html Thanks for referring to my translation! @Brian: I wasn't even aware of a license topic, but when checking back now, the wrapper for the "old" libusb 0.1 states GPL in the README. I think this was a bad idea. Thanks to Marc to point to the newer wrapper for libusb 1.0, which uses the same license as libusb, and for all stuff from me the same as the FPC units. Just use the branch "libusb-1.0". Anyhow, I would recommend to use libusb 1.0. If you need any support, feel free to contact me. Bye Hansi ___ 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 technical questions
On 2019-07-26 20:38, Mgr. Janusz Chmiel wrote: Please, how I could generate Android.pas and android.inc from The newest Android Platformtools? I think that android.jar is being used for this purposes. The information of how the included headers were generated can be found at https://wiki.freepascal.org/FPC_JVM/Building#Building_javapp The mentioned fixups will probably have to be changed for a different Android SDK. Jonas ___ 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 technical questions
Please, how I could generate Android.pas and android.inc from The newest Android Platformtools? I think that android.jar is being used for this purposes. But. Is it possible to use newer Platform tools such as Android 22? Or unfortunately, Google have made some restrictions so it is not possible to use newest Android platform tools to generate android.inc and android.pas? Thank you very much for yours answer. ___ 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
On Fri, 2019-07-26 at 11:44 -0400, James Richters wrote: > I did try fpc-usb-hid, it uses units: BaseUnix and Unix which I don't have, > and don't know what they are. I tried commenting them out thinking maybe > they were needed for Linux, but then it just can't find a lot of other > things... I am on Windows and using FPX 3.0.4RC1, if the units I need are > in a later version of FPC I can update it. If baseUnix ans Unix are in use, the code is for unixoid OS. Linux, *BSD, etc. The current LibUSB does support Windows, as you can see here: https://libusb.info/ But I _think_ the Pascal header adaption will need to be ported to Windows. Maybe someone else knows better? > A console demo would be a great help and very much appreciated, I am not in > a huge hurry. > > -Original Message- > From: fpc-pascal On Behalf Of > Dimitrios Chr. Ioannidis via fpc-pascal > Sent: Friday, July 26, 2019 6:51 AM > To: FPC-Pascal users discussions > Cc: Dimitrios Chr. Ioannidis > Subject: Re: [fpc-pascal] USB Human Interface Devices > > Hi, > > On 2019-07-26 13:39, James Richters wrote: > < snip > > > > Anyone have any suggestions for an FPC only console application method > > or demo I could use to access this USB HID device? > > < snip > > >As I suggested in my previous mail You can use the fpc-usb-hid library > from Alfred. I don't see any dependency for Lazarus in the usbcontroller.pas > which is, AFAIU, the main unit. > >If you're not in a hurry, I could try to make a simple console demo this > weekend. > > regards, > > -- > Dimitrios Chr. Ioannidis > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepa > scal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal -- Marc Santhoff ___ 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 technical questions
On 2019-07-26 19:24, Mgr. Janusz Chmiel wrote: Because my apps will be longer and longer, I have some special technical question to you. How many lines can PPCJVM compile while using one source file without units? I don't think there is a limit. There is only a limit per function/procedure/method: they cannot contain more than 64KB of java bytecode. I don't know exactly to how many lines of source code this corresponds (it probably depends on what the source code does, as some source code results in longer java byte code than other). How many values can be processed by using Case block? For example max 200 or similar value? Same answer as above. How to manage memory while using JVM Android target? Which commands or strategies can I use to minimize RAM overload? If I will type r=''; Will it deallocate allocated bytes for previously used value of string variable? After that statement has executed, the memory will be deallocated the next time the garbage collector runs. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] PPCJVM Android JVM target technical questions
Dear developers, Because my apps will be longer and longer, I have some special technical question to you. How many lines can PPCJVM compile while using one source file without units? How many values can be processed by using Case block? For example max 200 or similar value? How to manage memory while using JVM Android target? Which commands or strategies can I use to minimize RAM overload? If I will type r=''; Will it deallocate allocated bytes for previously used value of string variable? Sure, I know, that some special processes are not under my control. Such as when I will call some Android API function, The memory allocations will raise and I can not control it. I can only free previously called methods but memory allocations are on The control of Google Engineers, who ahave created specific API functions and methods or Android classes. Sure, I Am using The latest ppcjvm.exe which is The part of Lazarus package. ___ 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
I did try fpc-usb-hid, it uses units: BaseUnix and Unix which I don't have, and don't know what they are. I tried commenting them out thinking maybe they were needed for Linux, but then it just can't find a lot of other things... I am on Windows and using FPX 3.0.4RC1, if the units I need are in a later version of FPC I can update it. A console demo would be a great help and very much appreciated, I am not in a huge hurry. -Original Message- From: fpc-pascal On Behalf Of Dimitrios Chr. Ioannidis via fpc-pascal Sent: Friday, July 26, 2019 6:51 AM To: FPC-Pascal users discussions Cc: Dimitrios Chr. Ioannidis Subject: Re: [fpc-pascal] USB Human Interface Devices Hi, On 2019-07-26 13:39, James Richters wrote: < snip > > Anyone have any suggestions for an FPC only console application method > or demo I could use to access this USB HID device? < snip > As I suggested in my previous mail You can use the fpc-usb-hid library from Alfred. I don't see any dependency for Lazarus in the usbcontroller.pas which is, AFAIU, the main unit. If you're not in a hurry, I could try to make a simple console demo this weekend. regards, -- Dimitrios Chr. Ioannidis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ 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
On Thu, 2019-07-25 at 19:40 -0700, Brian wrote: > Try the libusb library Free Pascal interface .. but be aware of his license > requirements. It works well. > > http://johann-glaser.blogspot.com/2012/07/libusb-for-pascal.html http://johann-glaser.blogspot.com/2012/09/libusb-10-for-pascal.html -- Marc Santhoff ___ 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
Hi, On 2019-07-26 13:39, James Richters wrote: < snip > Anyone have any suggestions for an FPC only console application method or demo I could use to access this USB HID device? < snip > As I suggested in my previous mail You can use the fpc-usb-hid library from Alfred. I don't see any dependency for Lazarus in the usbcontroller.pas which is, AFAIU, the main unit. If you're not in a hurry, I could try to make a simple console demo this weekend. regards, -- Dimitrios Chr. Ioannidis ___ 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
El 26/07/2019 a las 12:39, James Richters escribió: Anyone have any suggestions for an FPC only console application method or demo I could use to access this USB HID device? Hello, This is not a complete HID interface but it can help you to start working with them. It has been designed to handle USB Relays which are managed using HID interface. Demos with and without GUI. https://github.com/JoshyFun/VUSBRelayPascal -- ___ 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
I've been trying to get some of these suggestions to work, but they all seem to require Lazarus, which I don't have and don't even know how to use. I'm looking for a solution that will work in a pure FPC console application in Windows, without Lazarus.I started trying to convert the demo programs into FPC only demos but there are just too many units I don't have and I don't know how to get around that. The project I am trying to integrate this into is huge and several hundred thousand lines of code, and has been in development for 30 years, starting back with Turbo Pascal it would be completely impossible to port it all over to Lazarus. I've tried just compiling my project with Lazarus before and just ran into issue after issue with it. I’m currently using FPC 3.0.4RC1 Anyone have any suggestions for an FPC only console application method or demo I could use to access this USB HID device? James -Original Message- From: fpc-pascal On Behalf Of Brian Sent: Thursday, July 25, 2019 10:41 PM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] USB Human Interface Devices Try the libusb library Free Pascal interface .. but be aware of his license requirements. It works well. http://johann-glaser.blogspot.com/2012/07/libusb-for-pascal.html -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TParamFlags and fpc 3.2.0.
fredvs schrieb am Fr., 26. Juli 2019, 09:06: > > It would help more if you'd point me exactly at the code in question. > > OK, now that you see the problem, here the code in mse-ide project: > > In msedesignparser.pas, procedure getmethodparaminfo: (Please take a look > at > the // in code that follow --> paramlist has one more entry in fpc 320) > I'll do my changes inline: > > procedure getmethodparaminfo(const atype: ptypeinfo; > var info: methodparaminfoty); > > function getshortstring(var po: pchar): string; > begin >setlength(result,byte(po^)); >inc(po); >move(po^,pointer(result)^,length(result)); >inc(po,length(result)); > end; > > type > pparamflags = ^tparamflags; > paramrecty = record >Flags : TParamFlags; > end; > var > isfunction: boolean; > int1: integer; > count: Integer; > po1: pchar; > begin > with info do begin > kind:= methodkindty(-1); > params:= nil; > if (atype^.Kind = tkmethod) then begin >with gettypedata(atype)^ do begin > kind:= tmethodkindtomethodkind[methodkind]; > int1:= paramcount; > isfunction:= methodkind = mkfunction; > if isfunction then begin > inc(int1); > end; > if isfunction or (methodkind = mkprocedure) then begin > setlength(params,int1); > > po1:= @paramlist; > count := 0; > > // there is now one more first parameter that must be ommited > >for int1:= 0 to paramcount - 1 do begin > with params[int1] do begin > // replace previous line with: with params[count] do begin >flags:= tparamflags( > {$ifdef mse_fpc_3_2}wordset{$else}byteset{$endif}(pbyte(po1)^)); >inc(po1,{$ifdef mse_fpc_3_2}2{$else}1{$endif}); > {$ifdef mse_fpc_3_2} // skip hidden parameters ($self, $high, etc.) if pfHidden in flags then Continue; {$endif} Inc(count); >name:= getshortstring(po1); >typename:= getshortstring(po1); >if (typename = 'WideString') or (typename = 'UnicodeString') then > begin > typename:= 'msestring'; >end >else begin > if typename = 'LongInt' then begin > typename:= 'Integer'; > end > else begin > if typename = 'Double' then begin > typename:= 'Real'; > end; > end; >end; > end; > end; > // adjust array now that we know the real count SetLength(params, count); > if isfunction then begin > params[high(params)].typename:= getshortstring(po1); > end; > end; >end; > end; > end; > end; > To resume: if somebody knows how to not add by default the first $self > parameter in paramlist, I vote for that solution. > The above changes should help. Regards, Sven ___ 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
I'm not an expert, but a few years ago I made small project to read data from an Arduino through USB port. The project was running on Raspberry Pi, on Windows it can be more tricky( I'm not sure, but I think a device driver is needed): https://github.com/jsuzineau/pascal_o_r_mapping/tree/master/electronic/Arduino/HeartRate , see Arduino_Special_Raspberry_Pi.lpi It seems I used TLazSerial component. Le 26/07/2019 à 00:04, James Richters a écrit : Does Freepascal have support for USB Human Interface devices? I am attempting to interface to an WHB04B-4 https://www.amazon.com/gp/product/B07M5ZY1P2 I have an example of how to do it that was written in Python, so I’m trying to figure out how to get it to work with my FPC console application. Figuring out how to interface with the device at all is what is holding me up, I don’t have any experience with direct interfacing to any USB devices. Any suggestions? James ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TParamFlags and fpc 3.2.0.
> It would help more if you'd point me exactly at the code in question. OK, now that you see the problem, here the code in mse-ide project: In msedesignparser.pas, procedure getmethodparaminfo: (Please take a look at the // in code that follow --> paramlist has one more entry in fpc 320) procedure getmethodparaminfo(const atype: ptypeinfo; var info: methodparaminfoty); function getshortstring(var po: pchar): string; begin setlength(result,byte(po^)); inc(po); move(po^,pointer(result)^,length(result)); inc(po,length(result)); end; type pparamflags = ^tparamflags; paramrecty = record Flags : TParamFlags; end; var isfunction: boolean; int1: integer; po1: pchar; begin with info do begin kind:= methodkindty(-1); params:= nil; if (atype^.Kind = tkmethod) then begin with gettypedata(atype)^ do begin kind:= tmethodkindtomethodkind[methodkind]; int1:= paramcount; isfunction:= methodkind = mkfunction; if isfunction then begin inc(int1); end; if isfunction or (methodkind = mkprocedure) then begin setlength(params,int1); po1:= @paramlist; // there is now one more first parameter that must be ommited for int1:= 0 to paramcount - 1 do begin with params[int1] do begin flags:= tparamflags( {$ifdef mse_fpc_3_2}wordset{$else}byteset{$endif}(pbyte(po1)^)); inc(po1,{$ifdef mse_fpc_3_2}2{$else}1{$endif}); name:= getshortstring(po1); typename:= getshortstring(po1); if (typename = 'WideString') or (typename = 'UnicodeString') then begin typename:= 'msestring'; end else begin if typename = 'LongInt' then begin typename:= 'Integer'; end else begin if typename = 'Double' then begin typename:= 'Real'; end; end; end; end; end; if isfunction then begin params[high(params)].typename:= getshortstring(po1); end; end; end; end; end; end; I did not find how to do for paramlist does not add that first parameter (maybe it is not possible). So, as work-around, now in function that parse the code into the source-editor: tsourceupdater.composeproceduretext(). there is a filter: > if name = '$self' then result := '', With this the problem is fixed. I have to fix too function parametersmatch() because for matching, first parameter must be omitted. To resume: if somebody knows how to not add by default the first $self parameter in paramlist, I vote for that solution. Otherwise maybe I will propose the work-around (that works perfectly) > if name = '$self' then result := ''; Many thanks Sven. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal