Re: [fpc-pascal] USB Human Interface Devices

2019-08-19 Thread Marc Santhoff
On Mon, 2019-08-19 at 04:24 -0400, James Richters wrote:
> I've been reading about libusb here:
> https://www.cs.unm.edu/~hjelmn/libusb_hotplug_api/group__syncio.html
>
> some things I just don't really understand, I'm hoping someone can explain:

I can't help with the details, but these sites are very informative,
especially the first one is nicely readable, the other has lots of details:

http://www.usbmadesimple.co.uk/index.html
https://www.beyondlogic.org/usbnutshell/usb1.shtml


> The wValue, wIndex and wLength fields values should be given in host-endian
> byte order.
> What does host-endian byte order mean??
>
> wLength
> the length field for the setup packet. The data buffer should be at least
> this size.
>
> What is this length supposed to be?  I've been using the length of the data
> I'm trying to send... so trying to send 8 bytes, I made it 8... but maybe
> it's wanting some other length?
>
> It seems to me that there would be little point in asking for this value if
> it was always just the length of the data field because the function could
> just get len(data) on it's own, so why bother passing something so obvious
> as a parameter...  this leads me to wonder if this length needs to be
> something else?
>
> James
> ___
> 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] USB Human Interface Devices

2019-08-18 Thread Marc Santhoff
On Mon, 2019-08-19 at 03:11 +0200, Marc Santhoff wrote:
> Hi James,
>
> are you really sure the WHB04B-6 is exactly the same as your WHB04B-4 viewn to
> the USB API?
>
> If those thingys come with a dll, maybe you can compare the header files?
> If there is no header file you could ask the manufacturer for it. If they made
> a programm using that dll, there must be a header file.

Oh, it's chinese - forget about getting any information.

Did you read there

https://github.com/rubienr/machinekit/tree/feature-xhc-whb04b-6/src/hal/user_comps/xhc-whb04b-6#findings

that the axis dial has to be switched on for the display to be updated?

> HTH somehow...
>
> --
> Marc Santhoff 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
--
Marc Santhoff 
--
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

2019-08-18 Thread Marc Santhoff
Hi James,

are you really sure the WHB04B-6 is exactly the same as your WHB04B-4 viewn to
the USB API?

If those thingys come with a dll, maybe you can compare the header files?
If there is no header file you could ask the manufacturer for it. If they made
a programm using that dll, there must be a header file.

HTH somehow...

--
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

2019-07-27 Thread Marc Santhoff
On Fri, 2019-07-26 at 22:37 +0200, Johann Glaser wrote:
> 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.

I've seen "$ifdef Windows" in the Code, so it does support Windows without any
change?

If so, that would be James' solution.

--
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

2019-07-26 Thread Marc Santhoff
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] USB Human Interface Devices

2019-07-26 Thread 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


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


[fpc-pascal] FReeBSD changing linker

2019-06-06 Thread Marc Santhoff
Hi,

some changes on FreeBSD 12 and up seem to affect FPC and Lazarus, see "Tasks"
list at the end of the quotation. Maybe it is of special interest to the dev
team.

Re-posting a part of FreeBSDs Quarterly Status Report Q1 2019:

"
LLVM's lld as the FreeBSD system linker

   Links
   LLD on the FreeBSD Wiki
URL: https://wiki.freebsd.org/LLD
   lld exp-run
URL: https://bugs.freebsd.org/214864

   Contact: Ed Maste 

   In FreeBSD-HEAD and 12.0 the default FreeBSD system linker (i.e.,
   /usr/bin/ld) is LLVM's lld, on amd64, arm64, and armv7. For i386 in
   12.0 lld is used as the bootstrap linker (i.e., to build the kernel and
   base system) but it is not enabled as the system linker because of
   multiple issues building FreeBSD ports with it enabled.

   The primary issue affecting i386 with lld is that many ports build
   position-dependent code (i.e., non-PIC) for use in shared libraries.
   This either comes from omitting the -fPIC compiler flag, or using
   hand-written position-dependent assembly. Compared with other CPU
   architectures i386 position-independent code is rather inefficient,
   which may be responsible for port authors making an explicit decision
   to avoid PIC.

   By default lld does not allow position-dependent code in shared objects
   (in particular, it does not permit relocations against read-only
   segments - typically containing the`.text` section).

   Over the last quarter many commits were made to the ports tree to fix
   the build when the system linker is lld - either building PIC code, or
   adding the -znotext linker flag to permit relocations against read-only
   segments, or just switching the port to link with GNU ld if it is
   incompatible with lld in some other way.

   At this point there are only a few dozen open bug reports for issues
   linking ports with lld as the system linker, and I expect FreeBSD 12.1
   to use lld as the system linker on i386 as well.

   Tasks:
 * Fix freepascal/Lazarus ports with lld
 * Triage and address remaining port failures
 * Holistic review of lld workarounds in the ports tree, to identify
   changes that are no longer needed, should be addressed in lld, or
   should be sent upstream

   This project was sponsored by The FreeBSD Foundation.
"

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

Re: [fpc-pascal] from fpc 2.6 to 3.x

2019-06-05 Thread Marc Santhoff
On Sat, 2019-06-01 at 22:26 +0200, Bart wrote:
> On Sat, Jun 1, 2019 at 8:41 PM Marc Santhoff  wrote:
>
> > which are the main changes when upgrading fpc from 2.6.4 to the current
> > 3.x
> > release?
>
> Codepage aware strings come to mind...
>
> New features are listed at
> http://wiki.freepascal.org/FPC_New_Features_3.0
>
> Changes that may break backwards compatibility are documented at
> http://wiki.freepascal.org/User_Changes_3.0

Thank you, but I know those documents. The hard part ist to compare backwards
version step by version step down to 2.6.4.

Most probably I'll jump right in and fix anything going through he complete
pile of sources. Working on a copies or branches certainly, not only switching
compilers.

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

[fpc-pascal] from fpc 2.6 to 3.x

2019-06-01 Thread Marc Santhoff
Hi,

which are the main changes when upgrading fpc from 2.6.4 to the current 3.x
release?

I remember having tried once for building ppcrossarm. That worked. When
compiling my old stuff in lazarus on x64 native it left me with a really big
mess. So big I switched back to 2.6.4 without taking any notes...

Since I do not want to do that again I need to know how to prepare properly.
I've ssen the release notes in the wiki [1], but there is no comparison
between the two lines of development.

TIA,
Marc

[1] http://wiki.freepascal.org/User_Changes_3.0.0

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

Re: [fpc-pascal] trying to use C code in .pas on WIN32

2019-02-13 Thread Marc Santhoff
On Tue, 2019-02-05 at 15:49 +0100, Marc Santhoff wrote:
> On Mon, 2019-02-04 at 15:59 -0700, conlin664 via fpc-pascal wrote:
> > THANKS GUYS.
> >
> > This is now working. The 'fix' was to actually install fpc 3.0.4 on this
> > machine.
> > My trusty 2.4.4 still compiled just fine what I use it for here at my day
> > job.
> >
> > But it seems 2.4.4 was not really pulling in the static reference.
> > { $L ccode.o }
>
> [...]
> > procedure HelloC; cdecl; external name 'HelloC';
> >
>
> [...]
>
> > compiled on WIN32 with:
> >
> > @set ToolPath=C:\VCAST63\MinGW\bin
> > @set cc=%ToolPath%\gcc.exe
> >
> > @set SAVED_PATH=%PATH%
> > @set PATH=%ToolPath%;%PATH%
> >
> > @set BASE=%cd%
> >
> > %CC% -g -I%BASE%  -DGNU_WIN32 -O1  -Wunused-variable   -c ccode.c -o
> > ccode.o
> >
> > rem %cc% -o test.exe ccode.o pcode.o  -lwsock32
> >
> > fpc -MDelphi  -vw -Sg  -Ci -O1  -OpPENTIUM3 -Ratt ^
> > -Fu%FPC_BASE%\units\i386-Win32 ^
> > -Fu%FPC_BASE%\units\i386-Win32\* ^
> > -Fu%FPC_BASE%\units\i386-Win32\rtl ^
> > -FlC:\VCAST63\MinGW\lib ^
> > pcode.pas
> >
> > @set PATH=%SAVED_PATH%
> > @exit /b
>
> Why does this work having 'cdecl' instead of 'stdcall'?
>
> Is it a special case regarding mingW32 that would not have happened using a
> native compiler like the one from Microsoft or Borland or similar?

http://willus.com/mingw/yongweiwu_stdcall.html

I will not write anything about that mess, feeling sick already.

--
This computer is not running MICROS~1.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Question: Is there a global callback, when a thread gets terminated?

2019-02-12 Thread Marc Santhoff
On Tue, 2019-02-12 at 17:36 +0100, Sven Barth via fpc-pascal wrote:

> Not every LazLogger user knows that their code is run in a thread. And not
> every thread user knows that the code they are using is using LazLogger in
> turn.

Ok.

But if used that way, would LazLogger need to notice at all?

As I understand it the use case will be to discriminate and not mix up the log
entries from different threads. If the user does not want this at all, why
bother inside the logger code?

I can imagine race conditions or misplaced log lines. If used in debugging
code this is mostly irrelevant, imho...

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

Re: [fpc-pascal] Question: Is there a global callback, when a thread gets terminated?

2019-02-12 Thread Marc Santhoff
On Mon, 2019-02-11 at 10:21 +, Michael Schnell wrote:
> > Yes, but how do I get notified, when the thread is gone, and I can free
> > the
> > memory (of the object that was created)?
>
> Ah, now I finally see the problem :)
>
> The only idea that comes in my mind is creating yet another thread or a
> TTimer (by means of "QueueAsyncCall") to poll if the original Threads still
> living. This supposedly would involve OS calls for getting the thread ID and
> for checking same for validity. Ugly ! :( .

If the LazLogger user has to put debugln() statements in his code, me thinks
it would be an acceptable price to tell him:

"If you are using debugln() inside threads, let each thread register with the
logger before first usage."

So the user could do sth. like

  LazLoggerObj.RegisterThread();

in the construction code of his threads. So you know the threads using the
logger. Same could be done in the destruction code, using the
".DeregisterThread()" method.

So you now the threads and their lifetime inside the logger.


HTH anyhow,
Marc

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

Re: [fpc-pascal] trying to use C code in .pas on WIN32

2019-02-06 Thread Marc Santhoff
Hi John,

thanks a lot for the verbose information.

I was thinking about putting up a wiki page collecting the diffenrent cases of
calling conventions, platforms and static vs. dynamic linking. But now I'm
totally confused.

Maybe a compiler developer or someone having enough knowlodge can clear things
up?

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

Re: [fpc-pascal] trying to use C code in .pas on WIN32

2019-02-05 Thread Marc Santhoff
On Mon, 2019-02-04 at 15:59 -0700, conlin664 via fpc-pascal wrote:
> THANKS GUYS.
>
> This is now working. The 'fix' was to actually install fpc 3.0.4 on this
> machine.
> My trusty 2.4.4 still compiled just fine what I use it for here at my day
> job.
>
> But it seems 2.4.4 was not really pulling in the static reference.
> { $L ccode.o }

[...]
> procedure HelloC; cdecl; external name 'HelloC';
>
[...]

> compiled on WIN32 with:
>
> @set ToolPath=C:\VCAST63\MinGW\bin
> @set cc=%ToolPath%\gcc.exe
>
> @set SAVED_PATH=%PATH%
> @set PATH=%ToolPath%;%PATH%
>
> @set BASE=%cd%
>
> %CC% -g -I%BASE%  -DGNU_WIN32 -O1  -Wunused-variable   -c ccode.c -o ccode.o
>
> rem %cc% -o test.exe ccode.o pcode.o  -lwsock32
>
> fpc -MDelphi  -vw -Sg  -Ci -O1  -OpPENTIUM3 -Ratt ^
> -Fu%FPC_BASE%\units\i386-Win32 ^
> -Fu%FPC_BASE%\units\i386-Win32\* ^
> -Fu%FPC_BASE%\units\i386-Win32\rtl ^
> -FlC:\VCAST63\MinGW\lib ^
> pcode.pas
>
> @set PATH=%SAVED_PATH%
> @exit /b

Why does this work having 'cdecl' instead of 'stdcall'?

Is it a special case regarding mingW32 that would not have happened using a
native compiler like the one from Microsoft or Borland or similar?

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

Re: [fpc-pascal] trying to use C code in .pas on WIN32

2019-01-31 Thread Marc Santhoff
On Thu, 2019-01-31 at 22:42 +0100, Tomas Hajny wrote:
> On Thu, January 31, 2019 21:57, Marc Santhoff wrote:
> > On Thu, 2019-01-31 at 11:00 -0700, conlin664 via fpc-pascal wrote:
> > > sven,
> > >
> > > so I just tried, what I think you said:
> > >
> > > procedure HelloC; cdecl; external name 'HelloC';
> > >
> > > pcode.pas(19,1) Error: Undefined symbol: _HelloC
>
>  .
>  .
> > You could rename your "HelloC.o to "_HelloC.o" before archiving inte the
> > library? Not that beautiful, but would be working, wouldn't it?
>
> @Marc: No, because 'HelloC' is name of the procedure, not of the object
> file.

You and Sven are right of course. I played around using nm, which the op
should probably do.


> @John: I noticed that you use a very old FPC version (2.4.4?) Do you get
> the same problem with the latest release?
>
> Moreover - wouldn't 'stdcall' be more appropriate than 'cdecl' in your
> case? What does 'objdump -t ccode.o' show about HelloC?



That's what I asked for, then overlooked it...

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

Re: [fpc-pascal] trying to use C code in .pas on WIN32

2019-01-31 Thread Marc Santhoff
On Thu, 2019-01-31 at 11:00 -0700, conlin664 via fpc-pascal wrote:
> sven,
>
> so I just tried, what I think you said:
>
> procedure HelloC; cdecl; external name 'HelloC';
>
> pcode.pas(19,1) Error: Undefined symbol: _HelloC
>
>
> sorry for complaining about windows, but i feel like this is more difficult
> on windows.
> All of the FPC examples, seem to run without this extra '_' business and i
> suspect they are on linux Os macOs.

You could rename your "HelloC.o to "_HelloC.o" before archiving inte the
library? Not that beautiful, but would be working, wouldn't it?

@Sven:
Maybe it is a later addition,  but her on fpc 2.6.4 your syntax is not
mentioned in the Programmers Guide (prog.pdf).

If i did look carefully enough there is no description of the syntax for:

"external name "

And more, those details of naming and the different name conventions on Win32
and Win64 are missing, too. I think there should be at least a wiki page or
better some explanations in the Programmers Guide.

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

Re: [fpc-pascal] trying to use C code in .pas on WIN32

2019-01-29 Thread Marc Santhoff
On Mon, 2019-01-28 at 08:19 -0700, conlin664 via fpc-pascal wrote:
> Thanks for the suggestions..
> 
> I'm pretty sure now, that the problem is that I'm thinking that the C code
> is being statically linked,
> but right now the compiler is going for dynamic.
> [ I've been comparing the size of the .exe ]
> 
> I also compiled with -va and note:
> 
> [0.388] Number of unresolved externals in objects 214
> [0.388] Number of unresolved externals after static libraries 214
> [0.388] Number of unresolved externals after defining COMMON symbols 214
> [0.389] Number of unresolved externals after DLL imports 0
> [0.396] There were 1 errors compiling module, stopping
> 
> when I don't try and call the C routine the number of unresolved objects is
> only 213
> 
> compiler switches:
> 
> -TWin32 -va -Mfpc -vw -Sg  -Ci -O1 -Cp386 -OpPENTIUM3 -Ratt -gl -p- -b-
> 
> I had -XS in there, but it doesn't seem to change anything.
> 
> So I'm just looking to static link external C code to a pascal program on a
> windows machine
> 

How do your declaration and compiler switch(es) in the code look like?

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

Re: [fpc-pascal] trying to use C code in .pas on WIN32

2019-01-24 Thread Marc Santhoff
On Wed, 2019-01-23 at 14:30 -0700, conlin664 via fpc-pascal wrote:
> I've done research, but am just missing something.
> my .pas code links just fine, but doesn't RUN.
> ( first writeln never appears )
> If I remove the  external call to C code, then the writeln works as normal.
>
> Problem:
>
> I have c code, which I'm compiling on a WIN32 machine ( yes the horror )
> using  GCC 4.5.2  target mingw32
>
> It generates .o files which i grouped together with ar  into common.a
> I then renamed common.a to be libcommon.a
>
> Then I have a
>
> Common.pas file:
>
> unit Common;
> interface
>
> uses
> sysutils, dos, CTypes;
>
> {$linklib libcommon.a }
>
> procedure CutilInit;  cdecl; external 'CutilInit';
>
> implementation
>
> end.
>

Try stdcall on Win32:

  procedure CutilInit;  stdcall; external 'common' name 'CutilInit';

If the full external declaration is necessary you'll have to try. I had to
when using a dynamic library (.dll in win32 terms).

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

Re: [fpc-pascal] instance memory usage

2018-10-24 Thread Marc Santhoff
On Wed, 2018-10-24 at 22:06 +0200, Sven Barth via fpc-pascal wrote:
> Am 20.10.2018 um 20:09 schrieb Marc Santhoff:
> > Hi,
> > 
> > from testing a while ago I remember the following:
> > 
> > The memory used by a class instance is composed of
> > 1. the size ".instanceSize()" gives back
> > 2. the memory used by other variables and maybe class instances referenced
> > by pointers and owned by the instance in question
> > 3. strings are (to be) included in 2., string types are in fact references
> > aka
> > pointers
> > 
> > The second clause is sort of "by definition", but I do define like that in
> > this case.
> > 
> > Is that listing correct and complete?
> 
> The size InstanceSize() returns is the pointer to the VMT plus the size 
> of any field in the class or any of its parent classes as if it would be 
> a record (keep in mind that class references are merely pointers, so a 
> class having another as a field is merely a pointer, not its 
> InstanceSize(), the same is true for e.g. Ansi-/UnicodeString).

OK, so my list is correct in general. The only thing missing would be the
code, but what I need to count is the data size when having lots of instance.


> Regards,
> Sven

Many thanks.

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

[fpc-pascal] instance memory usage

2018-10-20 Thread Marc Santhoff
Hi,

from testing a while ago I remember the following:

The memory used by a class instance is composed of
1. the size ".instanceSize()" gives back
2. the memory used by other variables and maybe class instances referenced
   by pointers and owned by the instance in question
3. strings are (to be) included in 2., string types are in fact references aka
   pointers

The second clause is sort of "by definition", but I do define like that in
this case.

Is that listing correct and complete?

TIA,
Marc

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

Re: [fpc-pascal] Using REST based Services

2018-10-08 Thread Marc Santhoff
Hello Alex,

sounds very interesting, but in this case I'm only the user of an API. Look 
there:

http://tika.apache.org/

Tika will run as a service and my task is to stick files in an get the contents 
back.
So nothing to debug regarding the API on my side.

Thank you anyway,
Marc


On Mon, 2018-10-08 at 02:04 -0400, Alexander Grotewohl wrote:
> A bit off topic for the list but I've used a program called "Insomnia" 
> which is a client for debugging REST APIs and it was incredibly handy. 
> Especially so you don't try everything under the sun before, for 
> example, realizing your API key is incorrect.
> 
> Alex
> 
> 
> On 10/7/2018 4:03 PM, Marc Santhoff wrote:
> > On Sun, 2018-10-07 at 00:23 +0200, Michael Van Canneyt wrote:
> > > On Sat, 6 Oct 2018, Marc Santhoff wrote:
> > > 
> > > > Hi,
> > > > 
> > > > being rather agnostic regarding web techniques I have to ask:
> > > > 
> > > > What module or unit is best for being used when calling web services?
> > > 
> > > fphttpclient is what you need.
> > 
> > OK, fine. I have used that already.
> > 
> > > > I want to try using Apache Tika running as a server for extracting the
> > > > contents of files. Files are transferred using HTTP PUT method-
> > > > 
> > > > See there for a quick overview:
> > > > https://wiki.apache.org/tika/TikaJAXRS#Services
> > > 
> > > Rest services are not very standardized. Each service is different, and
> > > therefor the lowest common denominator is the use of the HTTP protocol.
> > 
> > I see. It is simple enough to put a request together like when using curl 
> > in a
> > terminal.
> > 
> > > Which is exactly what is encapsulated in the fphttpclient unit.
> > > 
> > > The demo programs for fphttpclient should get you going.
> > 
> > Many thanks!
> > Marc
> > 
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-- 
Marc Santhoff 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Using REST based Services

2018-10-07 Thread Marc Santhoff
On Sun, 2018-10-07 at 00:23 +0200, Michael Van Canneyt wrote:
> 
> On Sat, 6 Oct 2018, Marc Santhoff wrote:
> 
> > Hi,
> > 
> > being rather agnostic regarding web techniques I have to ask:
> > 
> > What module or unit is best for being used when calling web services?
> 
> fphttpclient is what you need.

OK, fine. I have used that already.

> > 
> > I want to try using Apache Tika running as a server for extracting the
> > contents of files. Files are transferred using HTTP PUT method-
> > 
> > See there for a quick overview:
> > https://wiki.apache.org/tika/TikaJAXRS#Services
> 
> Rest services are not very standardized. Each service is different, and
> therefor the lowest common denominator is the use of the HTTP protocol.

I see. It is simple enough to put a request together like when using curl in a
terminal.

> Which is exactly what is encapsulated in the fphttpclient unit.
> 
> The demo programs for fphttpclient should get you going.

Many thanks!
Marc

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

[fpc-pascal] Using REST based Services

2018-10-06 Thread Marc Santhoff
Hi,

being rather agnostic regarding web techniques I have to ask:

What module or unit is best for being used when calling web services?

I want to try using Apache Tika running as a server for extracting the
contents of files. Files are transferred using HTTP PUT method-

See there for a quick overview:
https://wiki.apache.org/tika/TikaJAXRS#Services

TIA,
Marc

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

Re: [fpc-pascal] Bitmap-as-const-and-write-to-file-thingy

2018-09-20 Thread Marc Santhoff
Oncemore using the correct from address...
Sorry moderation.

On Thu, 2018-09-20 at 23:45 +0200, Bo Berglund wrote:
> On Wed, 19 Sep 2018 23:58:36 +0200, Marc Santhoff
>  wrote:
> 
> > Any pointers or hints, please?
> 
> You can convert any file you like to an inc file with pascal syntax:
> 
> data2inc -A -B laz/images/ide_icon48x48.png datatest.inc icon48x48
> 
> This will produce a datatest.inc file ready to be included in your
> project and with content looking like this:
> 
> const icon48x48 : array[0..4236] of byte=(
>   $89,$50,$4E,$47,$0D,$0A,$1A,$0A,$00,$00,$00,$0D,$49,$48,$44,
> 
>  $45,$4E,$44,$AE,$42,$60,$82);
> 
> data2inc is installed with fpc/lazarus ready for use.
> I used a png file shipped with lazarus as the example above.

Done. Cool stuff. :)

Thanks.

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

Re: [fpc-pascal] Bitmap-as-const-and-write-to-file-thingy

2018-09-20 Thread Marc Santhoff
On Thu, 2018-09-20 at 00:47 +0200, Tomas Hajny wrote:
> On Wed, September 19, 2018 23:58, Marc Santhoff wrote:
> 
> 
> Hi,
> 
>  .
>  .
> > What I need:
> > 
> > - A program taking a binary file and spitting out pascal code for the
> > const array. I know I have seen such program in the past, but do not know
> > where.
> 
> data2inc is included with FPC.

FPC is amazing! Batteries included. :)

> > - Some hints on using this constant for making files out of them.
> > Currently I'm plannig to use a TFileStreaam writing out Bytes, should do.
> 
> Indeed, should do; simple file of byte and BlockWrite should do as well.

I'll try soon,

Thank you very much.

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

[fpc-pascal] Bitmap-as-const-and-write-to-file-thingy

2018-09-19 Thread Marc Santhoff
Hi,

a program im fiddling with uses exactly 2 small .gif pictures that are to be
stored in the code and written out to the file system.

For several reasons - no gif writer, complicates ressouce file handling,
linking fpimage or similar - I want to handle those files directly in code,
having an array of hex bytes and some code writing those consts to file.

What I need:

- A program taking a binary file and spitting out pascal code for the const
array. I know I have seen such program in the past, but do not know where.

- Some hints on using this constant for making files out of them. Currently
I'm plannig to use a TFileStreaam writing out Bytes, should do.

Any pointers or hints, please?

TIA,
Marc

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

Re: [fpc-pascal] Unbuffering I/O

2018-08-30 Thread Marc Santhoff
On Wed, 2018-08-29 at 15:01 +, Mark Morgan Lloyd wrote:

> I've got two programs intended to be functionally identical, one in Perl 
> and the other in FPC. They read a unix-domain datagram, decode the 
> message, and emit output; if this goes to a file then it's reasonable to 
> monitor it using  tail -f
> 
> Perl has a variable that you can set to force output to be unbuffered, 
> with the result that as soon as a message is output it's in the file in 
> its entirety.
> 
> Is there an equivalent for Pascal, or should I be using something like 
> fpSync(stdout) at opportune times?

I don't know if it really helps, but since I fiddled with a similar topic:

FreeBSD has stdio channel non blocking by default. I had some problems with
that and did this:


procedure SwitchFdBlocking(var channel: Text);
var
  res: cint;
begin
  res := fpfcntl(TextRec(channel).Handle, F_GETFL);
  if ((O_NONBLOCK AND res)>0) then
  begin
res := res AND (NOT O_NONBLOCK);
res := fpfcntl(TextRec(channel).Handle, F_SETFL, res);
if (res=-1) then writeln(stderr, 'ERROR on SETFL');
  end;
end;

According to the man page of fcntl using the flag "O_DIRECT" instead of
"O_NONBLOCK" for switching of caching as far as possible. At least on FreeBSD
it is like this, check on Linux yourself...

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

Re: [fpc-pascal] Daemon using TTimer on Windows

2018-07-03 Thread Marc Santhoff
On Tue, 2018-07-03 at 10:14 -0300, Marcos Douglas B. Santos wrote:
> 
> Can we sleep a thread for minutes or even hours without any problems?
> The OS will not kill the thread?
> 

Sorry, I simply don't know. Try it.


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

Re: [fpc-pascal] Daemon using TTimer on Windows

2018-07-03 Thread Marc Santhoff
On Sat, 2018-06-30 at 17:57 -0300, Marcos Douglas B. Santos wrote:
> 
> My question is: Nowadays, can I use TTimer with no restrictions in a
> daemon application on Windows? If not, which could be a possible
> solution?
> 

Some years ago Graeme G. posted a solution to that problem. It's attached to
this mail, hoping hte list accepts pure text attachemnts, although I hoped it
would have been integrated in fpc/lazarus.

HTH,
Marc

-- 
Marc Santhoff {
  A basic thread based timer component. Can be used in GUI and non-GUI apps.
  Author:  Graeme Geldenhuys
}
unit ThreadTimer;

{$mode objfpc}{$H+}

interface

uses
  Classes;

type
  TFPTimer = class; // forward declaration


  TFPTimerThread = class(TThread)
  private
FTimer: TFPTimer;
  protected
procedure   DoExecute;
procedure   Execute; override;
  public
constructor CreateTimerThread(Timer: TFPTimer);
  end;


  TFPTimer = class(TComponent)
  private
FInterval: Integer;
FPriority: TThreadPriority;
FOnTimer: TNotifyEvent;
FContinue: Boolean;
FRunning: Boolean;
FEnabled: Boolean;
procedure   SetEnabled(Value: Boolean );
  protected
procedure   StartTimer;
procedure   StopTimer;
propertyContinue: Boolean read FContinue write FContinue;
  public
constructor Create(AOwner: TComponent); override;
procedure   On;
procedure   Off;
  published
propertyEnabled: Boolean read FEnabled write SetEnabled;
propertyInterval: Integer read FInterval write FInterval;
propertyThreadPriority: TThreadPriority read FPriority write FPriority default tpNormal;
propertyOnTimer: TNotifyEvent read FOnTimer write FOnTimer;
  end;


implementation

uses
  SysUtils;
  
{ No need to pull in the Windows unit. Also this works on all platforms. }
function _GetTickCount: Cardinal;
begin
  Result := Cardinal(Trunc(Now * 24 * 60 * 60 * 1000));
end;


{ TFPTimerThread }

constructor TFPTimerThread.CreateTimerThread(Timer: TFPTimer);
begin
  inherited Create(True);
  FTimer := Timer;
  FreeOnTerminate := True;
end;

procedure TFPTimerThread.Execute;
var
  SleepTime: Integer;
  Last: Cardinal;
begin
  while FTimer.Continue do
  begin
Last := _GetTickCount;
Synchronize(@DoExecute);
SleepTime := FTimer.FInterval - (_GetTickCount - Last);
if SleepTime < 10 then
  SleepTime := 10;
Sleep(SleepTime);
  end;
end;

procedure TFPTimerThread.DoExecute;
begin
  if Assigned(FTimer.OnTimer) then FTimer.OnTimer(FTimer);
end;


{ TFPTimer }

constructor TFPTimer.Create(AOwner: TComponent);
begin
  inherited;
  FPriority := tpNormal;
end;

procedure TFPTimer.SetEnabled(Value: Boolean);
begin
  if Value <> FEnabled then
  begin
FEnabled := Value;
if FEnabled then
  StartTimer
else
  StopTimer;
  end;
end;

procedure TFPTimer.StartTimer;
begin
  if FRunning then
Exit; //==>
  FContinue := True;
  if not (csDesigning in ComponentState) then
  begin
with TFPTimerThread.CreateTimerThread(Self) do
begin
  Priority := FPriority;
  Resume;
end;
  end;
  FRunning := True;
end;

procedure TFPTimer.StopTimer;
begin
  FContinue := False;
  FRunning  := False;
end;

procedure TFPTimer.On;
begin
  StartTimer;
end;

procedure TFPTimer.Off;
begin
  StopTimer;
end;

end.

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

Re: [fpc-pascal] How to list USB devices on Windows?

2018-06-27 Thread Marc Santhoff
On Wed, 2018-06-27 at 07:32 +0200, Bo Berglund wrote:
> I am writing a class that interfaces to a specific USB device HID type
> and I would like to list all such devices currently connected to the
> PC (usin Windows).
> 
[...]
> Is there some way I can do this on Windows so I can create a list of
> the device type I work with?
> Or is there an FPC command already?

I have some code in Object Pascal doing such stuff. The problem with it is, it
has no copyright string or author anywhere. I even don't know where it is
from, it's one of the pieces of code collected when stumbled upon, thinking
"this will be useful later"...

I can send it in private or post it here on the list or on pastebin. Maybe the
author can be identified?

I hesitate calling it public domain, but the code snippets I collect are
exactly that, visible for everyone, from postings on forums and the like.

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

Re: [fpc-pascal] Proper preprocessor?

2018-06-21 Thread Marc Santhoff
On Thu, 2018-06-21 at 22:25 +0700, Ryan Joseph wrote:
> > 
> I did a search and found only a few hits on the topic. Since I’ve been
> giving theoretical examples here’s something more practical a user
> attempted. Can you do that without macros? If I had to guess he had some
> funky code and just wanted to reduce typing and copy/paste bugs.
> 
> {$define HOFFSET(rec,field) := pointer(@rec.field) - pointer(@rec)} 

That funky code is the way some structured elements are defined when using
HDF5 file format library. It's pure C optimized for speed and my goal was to
adapt it to pascal. Using somesuch in C seems to be quite normal, it has an
entry in Wikipedia...

In the end I made the macro an inlined pascal function using the method of
"cruel casting"[tm]. After preprocessing C code should look similar.


#define HOFFSET(S,M)(offsetof(S,M)) // offsetof is a standard define

H5Tinsert(s1_tid, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT);
H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);



function HOFFSETP(rectypevar: pointer; fieldvar: pointer): longint; inline;
begin
HOFFSETP := longint(fieldvar - rectypevar);
end;

H5Tinsert(s2_tid, 'c_name', HOFFSETP(@s2[0], @s2[0].c), H5T_NATIVE_DOUBLE);
H5Tinsert(s2_tid, 'a_name', HOFFSETP(@s2[0], @s2[0].a), H5T_NATIVE_INT);



> type 
> s1_t = record 
> a: longint; 
> b: single; 
> c: double; 
> end; 
> var 
> s1: s1_t; 
> BEGIN 
> s1.a := 12345; 
> s1.b := 1.1; 
> s1.c := 1.2; 
> 
> writeln(HOFFSET(s1, a));
> END. 
> 
> Regards,
>   Ryan Joseph
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-- 
Marc Santhoff 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Proper preprocessor?

2018-06-20 Thread Marc Santhoff
On Wed, 2018-06-20 at 22:45 +0700, Ryan Joseph wrote:
> > On Jun 20, 2018, at 10:20 PM, Marc Santhoff  wrote:
> > 
> > The spots where resolving single parameter macros is done are pretty easy
> > to
> > find. Parsing the macro text and replacement will be the hardest part, as
> > Michael wrote. A bit of housekeeping for parameter-type lists, etc...
> 
> Easy? I’ve wanted to contribute to the compiler for years but it’s so
> daunting finding anything I give up. I’m curious how the parser works so
> please show me where the parser does the $defines. Maybe I can figure it out
> this time.

When I looked around it was in

scanner.pas
symsym.pas

Just grep for "macro".

If there is more or I'm wrong hopefully one of the "compiler guys" will help
out here, please. ;)

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

Re: [fpc-pascal] Proper preprocessor?

2018-06-20 Thread Marc Santhoff
On Wed, 2018-06-20 at 21:34 +0700, Ryan Joseph wrote:

> My impression was it was trivial extension to the current macros system but
> the compiler team was adverse to the idea because it creates “bad code” and
> all the other (very reasonable) reasons to not use macros in code (I read
> some old threads to this effect). It’s hard to understand why the current
> macros can’t be extended so I suspect this issue will just keep coming up
> over and over again.

If it's that important to you, do it yourself. The compiler is open source,
pure, readable pascal.

The spots where resolving single parameter macros is done are pretty easy to
find. Parsing the macro text and replacement will be the hardest part, as
Michael wrote. A bit of housekeeping for parameter-type lists, etc...

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

Re: [fpc-pascal] Proper preprocessor?

2018-06-20 Thread Marc Santhoff
On Wed, 2018-06-20 at 15:09 +0200, Michael Van Canneyt wrote:
> 
> On Wed, 20 Jun 2018, Mark Morgan Lloyd wrote:
> 
> > The other alternative would be break the compiler in such a way that it 
> > was usable from a standard makefile, but since there isn't separate 
> > compilation of definition and implementation parts this would probably 
> > impact on type safety. I believe that this too has been debated in the 
> > past, and has attracted even less enthusiasm than a hook for an extrnal 
> > preprocessor preprocessor.
> 
> Nothing stops people from preprocessing their code if they need really
> advanced preprocessing: The toolchain can handle it already.
> 
> But there is no need to integrate it in the compiler and thus needlessly
> complicating it even more. The consequences of such a step are far-reaching.
> 
> And till now, no-one has presented the really pressing use cases that would 
> warrant such a step.

The only use case for me would be macros having more than one parameter,
needed when translating C-code.

But I speak up for another reason:

Long ago, at the time of fpc 1.9.x or 2.0.x I did some digging in compiler
source code, the lexer and parser part. IIRC there were some hooks for calling
a proprocessor in the code at that time. If they are still there, wouldn't it
be a solution for both sides?

The compiler programmers only have to activate (or complete) a way to call a
preprocessor, solving the problem of mangled error messages.

The preprocessor user could implement whatever is needed on his or her side?

My 2 cent,
Marc

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

Re: [fpc-pascal] Realtime and freepascal???

2018-06-16 Thread Marc Santhoff
On Fri, 2018-06-15 at 10:17 +0200, Darius Blaszyk wrote:
> 
> One last point I have not covered is the use of video. For that I will need
> an MPU and as it stands I am thinking about using a Raspberry PI. I found
> this link on GPIO handling from FPC https://github.com/inforisorse/fprpiled.
> Anyone have a reference on reading HP video from RPI?

I'd recommend looking at "Ultibo", too. Best source if you want to do anything
in pure Object Pasal.

The standard way of getting video out of a rpi would be "mjpg-streamer". Easy
to set up, using webcams or the pi cam and you can use mostly any program able
to read streams from the net (vlc, mplayer, mpv, ...)
If you do not wanna use those they can be a source of information, how to
handle streams. In the end you deal with opening a socket for reading data
packets...

Another program dealing with video (surveillance stuff, ROI, multiple cams
iirc) is "motion".

Many 3D-prionters use Octopi (using mjpg.streamer) to have an eye on the
print, so there are lots of tutorials inthat information space.

Sorry, no more hints on programming, although I'm interested a bit, too. My
goal would be to show a video from file on the screeen and be able to navigate
by time code and by single picture.

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

Re: [fpc-pascal] Realtime and freepascal???

2018-06-01 Thread Marc Santhoff
On Thu, 2018-05-31 at 14:34 +, Mark Morgan Lloyd wrote:

> It's notable that the Boeing "Dreamliner" uses Ethernet heavily for both 
> control and passenger entertainment, allegedly with the various 
> subsystems both firewalled and airgapped (which raises the question: 
> would one really need both if one were confident in what he was doing?).

They most probably use industrial ehternet for the important things. There are
approaches doing both, tcp/ip and industrial protocols on one cable, but I
personally would not set one foot into a plane doing so. ;)

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

Re: [fpc-pascal] Realtime and freepascal???

2018-06-01 Thread Marc Santhoff
On Wed, 2018-05-30 at 22:27 +0200, Darius Blaszyk wrote:

> My project is planned to do data acquisition, either storing data to flash
> memory or sending it over RF, not decided yet. Later on video should be
> incorporated, also over RF. There are also multiple analogue controllers
> planned to be implemented. Some "simple" bus system (such as CAN??) should
> allow easy extension with modules (for data acquisition as well as for the
> controllers). The response time should be in the order of 10ms ideally.

Normally this would not be done on one Machine. If so it is a big one, having
enough power for running (parts of) the OS in real time. My suggestion would
be to use a small embedded SoC and a OS or programming technique doing hard
real time and another one, RPi would fit here from 15$ or so upward, recording
and / or streaming video.

Regarding data acquisition it is really hard to decide which bus or
communicaation port to use if the target measuring hardware isn't known. Many
industrial installations use modbus on RS485.

> Hoping for some useful replies. Thanks in advance for all the tips and
> pointers!

http://wiki.freepascal.org/Operating_Systems_written_in_FPC
http://wiki.freepascal.org/ARM
https://en.wikipedia.org/wiki/Comparison_of_real-time_operating_systems

Have fun,
Marc

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

Re: [fpc-pascal] Generating RTL Units for STM32 Processors

2018-03-01 Thread Marc Santhoff
On Wed, 2018-02-28 at 06:41 +0200, Christo Crause wrote:
> On 28 Feb 2018 4:22 am, "R0b0t1" <r03...@gmail.com> wrote:
> 
> I will be following up with you off list, since you do not seem to mind.
> 
> 
> I'm also interested in the general topic of incorporating embedded
> controllers (avr at the moment)  into fpc.

Me too, especially STM32F407 & 446.

-- 
Marc Santhoff <m.santh...@web.de>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] re-engineering tool

2018-01-09 Thread Marc Santhoff
On Mon, 2018-01-08 at 15:21 +0200, Juha Manninen wrote:
> On Sat, Jan 6, 2018 at 11:46 AM, Marc Santhoff <m.santh...@web.de>
> wrote:
> > Since I'm confronted with the task of analyzing a pile of object
> > pascal
> > sources I'd like to know:
> > 
> > Is there any tool that can help me?
> > 
> > Automatically generating a visual class diagram having uses and
> > aggregation of other classes would be very helpful.
> 
> There is also a Lazarus port of Ess-Model called Laz-Model.
> See:
>  https://github.com/dicepd/Laz-Model
> It is indeed a reverse-engineering class diagram tool.

Beautiful, open source and fpc code aware. I think I'll try that one
first. :)

Many thanks,
Marc

-- 
Marc Santhoff <m.santh...@web.de>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] re-engineering tool

2018-01-08 Thread Marc Santhoff
On Mon, 2018-01-08 at 08:35 +0100, Marc Santhoff wrote:
> On Sat, 2018-01-06 at 18:01 +0100, Marco van de Voort wrote:
> > In our previous episode, Marc Santhoff said:
> > > Since I'm confronted with the task of analyzing a pile of object
> > > pascal
> > > sources I'd like to know:
> > > 
> > > Is there any tool that can help me?
> > 
> > I've used Peganza's pascal analyser in the past, for D7 code. I
> > haven't
> > used it in a while though.
> 
> I'll have a look at it, thanky you!

There is a testing version and a free one.

So now lets see if it can handle "mode fpc" source...

-- 
Marc Santhoff <m.santh...@t-online.de>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] re-engineering tool

2018-01-07 Thread Marc Santhoff
On Sat, 2018-01-06 at 18:01 +0100, Marco van de Voort wrote:
> In our previous episode, Marc Santhoff said:
> > Since I'm confronted with the task of analyzing a pile of object
> > pascal
> > sources I'd like to know:
> > 
> > Is there any tool that can help me?
> 
> I've used Peganza's pascal analyser in the past, for D7 code. I
> haven't
> used it in a while though.

I'll have a look at it, thanky you!

Marc

-- 
Marc Santhoff <m.santh...@web.de>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] re-engineering tool

2018-01-06 Thread Marc Santhoff
Hi!

Since I'm confronted with the task of analyzing a pile of object pascal
sources I'd like to know:

Is there any tool that can help me?

Automatically generating a visual class diagram having uses and
aggregation of other classes would be very helpful.

Any hints?
TIA,
Marc

-- 
Marc Santhoff <m.santh...@web.de>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Modern Compiler Construction using Pascal

2018-01-02 Thread Marc Santhoff
On Mon, 2018-01-01 at 13:17 -0500, Yves Cloutier wrote:
> Hi there,
> 
> I'd be interested to know if any modern compilers have been written
> in
> Pascal (other than the Pascal Compiler).

A bit outdated, but intresting:

http://pascaland.org/pascall.htm

-- 
Marc Santhoff <m.santh...@web.de>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Modern Compiler Construction using Pascal

2018-01-02 Thread Marc Santhoff
On Mon, 2018-01-01 at 13:17 -0500, Yves Cloutier wrote:
> Hi there,
> 
> I'd be interested to know if any modern compilers have been written in
> Pascal (other than the Pascal Compiler).
> 
> It's unfortunate that that most Pascal books out there are rather dated.  I
> did recently purchase
> mailman/listinfo/fpc-pascal

Pascal purists, please do not read on!



Really good an modern books on writing compilers are those from Terence
Parr. They are really readable and understandable, forget about the
Dragon Book.

The tool in use is the well known ANTLR, the newer versions implemented
in Java. If you want to build real compilers look for version 3, if
making DSLs is your target version 4 would be appropriate.

Have a look at antlr.org, the books to read are:

  "The Definitive ANTLR Reference - Building Domain Specific Languages"

Like the title says, a verbose and well written refernce for using
antlr.

The best book on the topic by far is (for me):

  "Language Implementation Patterns"

That's a very clear, pragmatic, and analytic view on compiler
construction. It is structured modular and easy to read. Guido van
Rossum, the creator of Python, writes about it "Throw away your
compiler theory book!"
I would really appreciate a translation of the code from the book to
pascal. ;)



Sorry for mentioning something nasty like Java on this list.

-- 
Marc Santhoff <m.santh...@web.de>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-10 Thread Marc Santhoff
On Fr, 2017-11-10 at 19:07 +0100, Mattias Gaertner wrote:
> On Fri, 10 Nov 2017 18:57:19 +0100
> Marc Santhoff <m.santh...@web.de> wrote:
> 
> >[...]
> > > You can either use fpc and switch the target OS and /or processor.  
> > 
> > That solution isnt't doable, that would require a compiler for X86_64
> > and ARM.
> 
> fpc -Parm calls ppcarm, fpc -Px86_64 calls ppcx64.

Besides the language - fpc and lazarus are so cool tools!

Thank you,
Marc

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

Re: [fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-10 Thread Marc Santhoff
On Fr, 2017-11-10 at 18:22 +0100, Karoly Balogh (Charlie/SGR) wrote:
> Hi,
> 
> On Fri, 10 Nov 2017, Marc Santhoff wrote:
> 
> > What is that, is ppc used for bootstrapping the cross compiler
> > regardless of any other fpc maybe installed?
> 
> Yes. First that ppc gets built with the "other FPC" installed. Or you can
> specify a startup compiler explicitly with FPC= argument to the make. It
> doesn't even need the rtl or anything, just the "ppcXXX" native compiler.
> 
> During the first round it builds this new native compiler + rtl which will
> be used to bootstrap the actual crosscompiler then.

Ok. So I have a newer compiler for the base system built on the fly,
nice.

Thanks,
Marc

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

Re: [fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-10 Thread Marc Santhoff
On Fr, 2017-11-10 at 18:25 +0100, Mattias Gaertner wrote:
> On Fri, 10 Nov 2017 17:47:11 +0100
> Marc Santhoff <m.santh...@web.de> wrote:
> 
> > Hi again,
> > 
> > (too many sub threads, answering here - thanks to all helpers!)
> > 
> > OK, "$FPC -va | grep CPU" does the trick. If using the ppcrossarm:
> > 
> > marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppcrossarm 
> > -va|grep CPU
> > [0.004] Macro defined: CPUARMEL
> > [0.004] Macro defined: FPC_CPUCROSSCOMPILING
> > [0.004] Macro defined: CPUARM
> > [0.004] Macro defined: CPU32
> > [0.004] Macro defined: CPUINT32
> > [0.020] interpreting file option "#IFNDEF CPUI386"
> > [0.020] interpreting file option "#IFNDEF CPUAMD64"
> > 
> > See, an arm compiler. But when using the ppc binary in the same dir it
> > looks different. Here we go:
> > 
> > marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppc -va | grep 
> > CPU
> 
> What is ppc?
> Where is fpc?

That happens in the directory of a built but not yet installed cross
compiler. The build command following those instructions:

http://j-software.dk/stm32f103.php

was:

gmake clean buildbase installbase CROSSINSTALL=1 CROSSOPT="-XParm-elf-"
OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7m PREFIX=../../fpc-arm

IIRC. But actually the path from the PREFIX does not exist. Sth. to
investigate or redo for me.

> 
> > Next question is how to get started with lazarus and multiple compilers.
> > How do you do it, using configuration files for lazarus and starting
> > like "lazarus --primary-config-path= "? Or are there other
> > possibilities to try?
> 
> Lazarus supports multiple compilers.
> You can either use fpc and switch the target OS and /or processor.

That solution isnt't doable, that would require a compiler for X86_64
and ARM.

> Or you can switch the compiler binary: Project / Project Options /
> Compiler Options / Compiler Command. Replace the default
> value '$(CompPath)' with the path.

Aha, OK.

> You can use build modes to switch with a mouse click between various
> sets of compiler options.

Beautiful, may take a while to get there, but very handy. :)

Marc

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

Re: [fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-10 Thread Marc Santhoff
Hi again,

(too many sub threads, answering here - thanks to all helpers!)

OK, "$FPC -va | grep CPU" does the trick. If using the ppcrossarm:

marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppcrossarm -va|grep 
CPU
[0.004] Macro defined: CPUARMEL
[0.004] Macro defined: FPC_CPUCROSSCOMPILING
[0.004] Macro defined: CPUARM
[0.004] Macro defined: CPU32
[0.004] Macro defined: CPUINT32
[0.020] interpreting file option "#IFNDEF CPUI386"
[0.020] interpreting file option "#IFNDEF CPUAMD64"

See, an arm compiler. But when using the ppc binary in the same dir it
looks different. Here we go:

marc@puma:/home/marc/program/fpc-cross/src/fpc/compiler > ./ppc -va | grep CPU
[0.008] Macro defined: CPUX86_64
[0.008] Macro defined: CPUAMD64
[0.008] Macro defined: CPU64
[0.008] Macro defined: CPUX64
[0.008] Macro defined: CPUINT64
[0.023] interpreting file option "#IFNDEF CPUI386"
[0.023] interpreting file option "#IFNDEF CPUAMD64"

What is that, is ppc used for bootstrapping the cross compiler
regardless of any other fpc maybe installed?

Next question is how to get started with lazarus and multiple compilers.
How do you do it, using configuration files for lazarus and starting
like "lazarus --primary-config-path= "? Or are there other
possibilities to try?


Marc

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

Re: [fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-09 Thread Marc Santhoff
On Do, 2017-11-09 at 21:31 +0100, Giuliano Colla wrote:
> Il 09/11/2017 02:36, Marc Santhoff ha scritto:
> 
> > how does fpc and it's makefiles handle the case of installing a cross
> > compiler on a system having fpc installed?
> >
> > The target path will differ and I can set that, but how is the config
> > file .fpc.cfg handled?
> 
> You may edit your fpc.cfg for your different target using an IFDEF/ENDIF 
> pair.
> 
> Under Linux I have in my home directory a .fpc.cfg sort of:
> 
> #include /etc/fpc.cfg  <--- to get all the defaults
> #IFDEF CPUARM
>  here all the ARM specific paths and options
> #ENDIF

I see, so when using fpc for ARM these define is automatically set?
And would that be CPUAVR for Atmels chips?

> That's the basic idea. All that's between #IFDEF -- #ENDIF is ignored 
> when you're *not* cross-compiling.
> All that's between #IFDEF -- #ENDIF overrides the previous settings when 
> you're cross-compiling

I have thought about this solution, but did not know the details. Next
step will be to generate a default fpc.cfg for the arm cross compiler
and merge that into the .fpc.cfg using ifdefs.

Fine, now I know the way. :)

Thanks,
Marc

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

Re: [fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-09 Thread Marc Santhoff
On Do, 2017-11-09 at 20:05 +0200, Christo wrote:
> On Thu, 2017-11-09 at 02:36 +0100, Marc Santhoff wrote:
> > Additionally there seems to be no compiler switch for changing the
> > configuration file to use, only -n for ignoring it. Is ist possible
> > to
> > name the .cfg on the command line or how would it be done better?
> 
> Yes, specify alternative config file using the @ option.  Use in
> conjunction with -n if you want to exclude the default config file.

In fact you're right, I ovelooked that option. Now that the name ist
known:

 > ./ppcrossarm -h | grep @
  @   Read compiler options from  in addition to the default fpc.cfg

That solves most problems for now.

Thanks,
Marc

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

[fpc-pascal] installing cross fpc in parallel to systems fpc

2017-11-08 Thread Marc Santhoff
Hi,

how does fpc and it's makefiles handle the case of installing a cross
compiler on a system having fpc installed?

The target path will differ and I can set that, but how is the config
file .fpc.cfg handled?
I'm a bit afraid to mess up the installation not because of fpc but
because I'm not really knowing what I'm doing. ;)

Additionally there seems to be no compiler switch for changing the
configuration file to use, only -n for ignoring it. Is ist possible to
name the .cfg on the command line or how would it be done better?

TIA,
Marc


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

[fpc-pascal] Container class for key-value pairs

2017-09-10 Thread Marc Santhoff
Hi,

since I'm programming Pascal only on occasion I'd like to know:

Which container class ist the easiest to use for key-value pairs?

The goal is to store a configuration set from a hardware measuring
device having 81 items. This item set is fixed, no change. The values
are parsed from json data (text) and have to be stored in memory (for
now).

TIA,
Marc

-- 
Marc Santhoff <m.santh...@web.de>

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

Re: [fpc-pascal] Using Serial in a TCP/RS232 gateway, how to set buffer sizes?

2017-09-07 Thread Marc Santhoff
On Do, 2017-09-07 at 13:32 +0200, Bo Berglund wrote:
> On Wed, 06 Sep 2017 23:21:17 +0200, Marc Santhoff
> <m.santh...@web.de> wrote:
> 
> >Could that be some sort of timeout?
> >
> >You're setting
> >
> >  FTcpComm.ReadTimeout := 30;
> >
> >but I have no idea what order of magnitude this 30 is. Maybe streching
> >the timeout a little bit can help?
> >
> >I had several cases of timeout problems using RS232 over TCP.
> 
> No, the Tcp/IP part is not involved at all here. When the transfer to
> the server starts there is no response expected until all data have
> been transferred.
> The problem is that the Win7 application sends RS232 data out a serial
> port and another application (my relayer) is using another serial port
> which is connected by wire to the first serial port.
> This relaying application seems to lose incoming data, which are sent
> at a speed of 38400 baud.
> Before the data arrives to the TCP/IP part they have been corrupted.

What structure does the Windows side have, ist your application running
on the same machine as the remote control program for the data system or
is there a second computer attached using cables?

> The test on location proves that the case where the relayer is not
> involved (wire goes from Win7 application directly to the data system)
> is working fine.
> But I cannot use that because I am in Sweden and the data system is in
> Texas...

The most important part is to see where exactly data is vanishing. Which
I don't at the moment. There is only one small part of the transmission
path involved, running from the RS232 out of the windows app to the
relaying app, as I understand. And this only happens in the direction
from the win app to the remote system. Did I get that right?

-- 
Marc Santhoff <m.santh...@web.de>

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

Re: [fpc-pascal] Using Serial in a TCP/RS232 gateway, how to set buffer sizes?

2017-09-06 Thread Marc Santhoff
On Mi, 2017-09-06 at 23:06 +0200, Bo Berglund wrote:
> On Wed, 06 Sep 2017 22:52:12 +0200, Bo Berglund
>  wrote:
> 
> >I have now added extra binary logging to the relaying program only to
> >find that the data received and processed are missing about 50 k of
> >the 1M transmission.
> >Next I will edit serial.pp and up the buffers from 2K to 60K or so.
> 
> By the way:
> I have sent the Delphi test program I am debugging over to people at
> the remote location and they have connected their laptop directly to
> the data system and with that setup there is no data loss.
> So this leaves me with only the Lazarus/FPC network relaying app to
> fix...

Could that be some sort of timeout?

You're setting

  FTcpComm.ReadTimeout := 30;

but I have no idea what order of magnitude this 30 is. Maybe streching
the timeout a little bit can help?

I had several cases of timeout problems using RS232 over TCP.

> I could also create another test program, a serial sniffer that could
> be set up to just log whatever appears on the serial lines. I need a
> 3-way cable for that of course.

Such thing does exists, I only forgot the name(s), ;)

HTH,
Marc


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

Re: [fpc-pascal] Using Serial in a TCP/RS232 gateway, how to set buffer sizes?

2017-09-06 Thread Marc Santhoff
On Mi, 2017-09-06 at 21:22 +0200, Bo Berglund wrote:
> Where could I be losing incoming serial data?

Only for completeness:

Can you rule out problems reagrding the hardware side? Mabe there are
some weak line drivers or a faulty cable involved?

Worth checking, at least.

HTH anyhow,
Marc


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

[fpc-pascal] machine readable grammar of object pascal?

2017-05-02 Thread Marc Santhoff
Hi,

for playing around I would need a grammar of Object Pascal. I do not
care for which tool it is written or at best if it is plain EBNF.

Does such grammar exist?

TIA,
Marc


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

Re: [fpc-pascal] Translation C to Pascal

2017-05-02 Thread Marc Santhoff
On Di, 2017-05-02 at 08:33 -0700, fredvs wrote:
> Hello.
> 
> The best (IMHO) is c2pas32 --> http://www.astonshell.com/freeware/c2pas32/

Nice program, i fed the adc.c source from STMs fwlib for stm32f4 through
and the generated code looks fine. There is some guessing on type casts,
but I hope those can be cleared using simple scripting or the like.

> But it is old and translate into Delphi code, so still work after...

Will see that when trying the compiler on it, not enough time for mkore
than some preparations currently. Maybe switching to mode Delphi is
fine, if anything is working for embedded targets.

Many thanks,
Marc


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

[fpc-pascal] Translation C to Pascal

2017-05-01 Thread Marc Santhoff
Hi,

since fpc supports a lot of intresting SoCs and Microcontrollers - has
anyone really used Allwinner A20? - I need an update:

Which translator do you use for making Object Pascal code from C?

For headers there is the very well working h2pas. But what tool is
recommendable for .c files?

The one I used in the past had many flaws, at first a strongly limited
subset of translatable statements. Secondly it is not actively
developed, thats why I'm searching a new and better one.

TIA,
Marc


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

Re: [fpc-pascal] fpc for ARM on STM32F103

2017-01-22 Thread Marc Santhoff
On So, 2017-01-22 at 22:05 +0100, Florian Klämpfl wrote:
> Am 22.01.2017 um 21:43 schrieb Marc Santhoff:
> > On So, 2017-01-22 at 21:20 +0100, Florian Klämpfl wrote:
> >> Am 22.01.2017 um 19:33 schrieb Marc Santhoff:
> >>> Hi,
> >>>
> >>> I'd like to know if the floating point hardware on STM32F103
> >>
> >> What floating point hardware does it have? According to a quick search, it 
> >> is a Cortex-M3 which has
> >> no hardware floating point support?
> > 
> > Indeed, you're right. Having my head wrapped around a cpouple of
> > different SoCs I was blinded by the F in the name. Cortex-M4 may have
> > floating point hardware, if the implementer decides to build it into the
> > chip.
> > 
> > OK, moving the question to the STM32F4xx devices having "ARM FPv4-SP
> > single-precision FPU". Does fpc support that one?
> 
> Yes. Compile with -Cffpv4_s16 while using rtl/packages built with 
> CROSSOPT=-Cffpv4_s16, just add
> this to the command line provided by Jeppe's site.

Very nice. :)

Many thanks for answering and clearing things up,
Marc

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


Re: [fpc-pascal] fpc for ARM on STM32F103

2017-01-22 Thread Marc Santhoff
On So, 2017-01-22 at 21:20 +0100, Florian Klämpfl wrote:
> Am 22.01.2017 um 19:33 schrieb Marc Santhoff:
> > Hi,
> > 
> > I'd like to know if the floating point hardware on STM32F103
> 
> What floating point hardware does it have? According to a quick search, it is 
> a Cortex-M3 which has
> no hardware floating point support?

Indeed, you're right. Having my head wrapped around a cpouple of
different SoCs I was blinded by the F in the name. Cortex-M4 may have
floating point hardware, if the implementer decides to build it into the
chip.

OK, moving the question to the STM32F4xx devices having "ARM FPv4-SP
single-precision FPU". Does fpc support that one?

> 
> > is
> > supported by the fpc cross compiler. ARmv7 this is according to:
> > 
> > http://j-software.dk/stm32f103.php
> > 
> > Will fpc use floating point support on those SoCs?
> > 
> > TIA,
> > Marc
> > 
> > 
> > ___
> > fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> > 
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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


[fpc-pascal] fpc for ARM on STM32F103

2017-01-22 Thread Marc Santhoff
Hi,

I'd like to know if the floating point hardware on STM32F103 is
supported by the fpc cross compiler. ARmv7 this is according to:

http://j-software.dk/stm32f103.php

Will fpc use floating point support on those SoCs?

TIA,
Marc


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


Re: [fpc-pascal] questions on fpimage

2017-01-05 Thread Marc Santhoff
On Do, 2017-01-05 at 11:15 +0100, Mattias Gaertner wrote:
> On Tue, 03 Jan 2017 02:54:05 +0100
> Marc Santhoff <m.santh...@web.de> wrote:
> 
> > Hi,
> > 
> > firstly a happy new year to you all and keep on rocking!
> > 
> > While reading the fpimage unit code I found some pieces I don't
> > understand and could not clear up reading the docs. Here we go:
> > 
> > 
> > TFPCustomImage = class(TPersistent)
> > [...]
> > public
> > [...]
> >   property  Extra [const key:string] : string read GetExtra write 
> > SetExtra;
> >   property  ExtraValue [index:integer] : string read GetExtraValue 
> > write SetExtraValue;
> >   property  ExtraKey [index:integer] : string read GetExtraKey write 
> > SetExtraKey;
> >   procedure RemoveExtra (const key:string);
> >   function  ExtraCount : integer;
> > 
> > 
> > Whats that good for? Ist to tag images inside my own program or does it
> > handle image meta data like EXIF and stuff?
> 
> Yes. Both.

OK, fine. But there is no code doing sth. like reading EXIF tags from
files, I have do do myself?

I was hoping to find some code handling image comments and the like,
still searching for meta data access. ;)

> > And at the end:
> > 
> > 
> > initialization
> >   ImageHandlers := TImageHandlersManager.Create;
> > 
> > 
> > Looking at this class it seems to be sort of a type registry, maybe able
> > to detect type and name or instantiate the reader and writer classes.
> > How ist that to be used and do I need to care for?
> 
> All image formats register themselves there.
> It is used by
> TFPCustomImage.FindHandlerFromExtension
> and
> TFPCustomImage.LoadFromStream
> 
> You can query it yourself or use the above.

Nice and helpful, thanks.

Marc

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


[fpc-pascal] questions on fpimage

2017-01-02 Thread Marc Santhoff
Hi,

firstly a happy new year to you all and keep on rocking!

While reading the fpimage unit code I found some pieces I don't
understand and could not clear up reading the docs. Here we go:


TFPCustomImage = class(TPersistent)
[...]
public
[...]
  property  Extra [const key:string] : string read GetExtra write SetExtra;
  property  ExtraValue [index:integer] : string read GetExtraValue write 
SetExtraValue;
  property  ExtraKey [index:integer] : string read GetExtraKey write 
SetExtraKey;
  procedure RemoveExtra (const key:string);
  function  ExtraCount : integer;


Whats that good for? Ist to tag images inside my own program or does it
handle image meta data like EXIF and stuff?


And at the end:


initialization
  ImageHandlers := TImageHandlersManager.Create;


Looking at this class it seems to be sort of a type registry, maybe able
to detect type and name or instantiate the reader and writer classes.
How ist that to be used and do I need to care for?


TIA,
Marc


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


Re: [fpc-pascal] meta data of files

2016-12-15 Thread Marc Santhoff
On Mi, 2016-12-14 at 22:56 -0700, Lars wrote:
> On Wed, December 14, 2016 11:57 am, Marc Santhoff wrote:
> > Hi,
> >
> >
> > I'd like to read out meta data from files. is there any pascal code
> > supporting this task?
> >
> > This is about reading the comment of zip files, the author and
> > description of word processor files (open document format) and so on.
> >
> > TIA,
> > Marc
> >
> >
> >
> 
> You may check out total commander plugin source code..
> 
> Although it may be in Delphi, you could convert to Laz/fpc

OK, will loook at that.

> There are a lot of total commander plugins that deal with MP3 meta data
> and such... not sure about Open Document though..
> 
> Is meta data in files some standard, so that the meta data in an mp3 file
> is similar to a word process file? I have a hunch this is not going to
> help you.. as it's completely different

No, no standard at all. E.g. in .ODF zip files there are XML files
having some fields carrying meta data. For photos there is EXIF or
simple comments in JPEG, .PDF does use dublin core sometimes, and so on.

It would be a big pile of work to support only the most commen file
types, that's why I hope to find some source. ;)

One framework I know is Apache Tika, doing type identification, meta
data access and content access. Having it in pascal source would be a
dream.

http://tika.apache.org/


Thanks,
Marc


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


[fpc-pascal] meta data of files

2016-12-14 Thread Marc Santhoff
Hi,

I'd like to read out meta data from files. is there any pascal code
supporting this task?

This is about reading the comment of zip files, the author and
description of word processor files (open document format) and so on.

TIA,
Marc


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


[fpc-pascal] file identification using libmagic

2016-12-14 Thread Marc Santhoff
Hi,

I have made a header port of libmagic which is used by the file(1)
command to identify the type of files. Usage examples are availble, too.

Since it could be of general interest, I'm posting it here. Test it,
stick it in LCCR or whatever.

Have fun,
Marc

unit libmagic;
interface
{ Made by Marc Santhoff in 2016
  Do anything you like with this code, no warranties of any kind given.
  Please respect other licenses, see below.

  Issues:
  - I had to change two of the MAGIC_ constants because of name clashes.
They got an additional underscore after the name, see below.
  - Uses unit unixtype, don't know how portable that is and which unit to use
on Windows or elsewhere.
  - magic_set is declared as a pointer, could be some other type of handle
}
{
  Automatically converted by H2Pas 1.0.0 from /usr/include/magic.h
  The following command line parameters were used:
-DC
-l
magic
-o
./libmagic.pp
/usr/include/magic.h
}

  uses unixtype; //ctypes;
  const
External_library='magic'; {Setup as you need}

  Type
  Pchar  = ^char;
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}


  {
   * Copyright (c) Christos Zoulas 2003.
   * All Rights Reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
   *notice immediately at the beginning of the file, without modification,
   *this list of conditions, and the following disclaimer.
   * 2. Redistributions in binary form must reproduce the above copyright
   *notice, this list of conditions and the following disclaimer in the
   *documentation and/or other materials provided with the distribution.
   *
   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
   * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
}

{ from /usr/src/contrib/file/src/files.h, imported here to be compact, ms }
{ how does C know the meaning of "magic_set"-type?, ms }

{ end from /usr/src/contrib/file/src/files.h }

{$ifndef _MAGIC_H}
{$define _MAGIC_H}  
{ $include }
  { No flags  }

  const
MAGIC_NONE = $00;
  { Turn on debugging  }
MAGIC_DEBUG = $01;
  { Follow symlinks  }
MAGIC_SYMLINK = $02;
  { Check inside compressed files  }
MAGIC_COMPRESS = $04;
  { Look at the contents of devices  }
MAGIC_DEVICES = $08;
  { Return the MIME type  }
MAGIC_MIME_TYPE = $10;
  { Return all matches  }
MAGIC_CONTINUE = $20;
  { Print warnings to stderr  }
MAGIC_CHECK_ = $40;// changed because of name conflict
  { Restore access time on exit  }
MAGIC_PRESERVE_ATIME = $80;
  { Don't translate unprintable chars  }
MAGIC_RAW = $000100;
  { Handle ENOENT etc as real errors  }
MAGIC_ERROR_ = $000200;// changed because of name conflict
  { Return the MIME encoding  }
MAGIC_MIME_ENCODING = $000400;
MAGIC_MIME = MAGIC_MIME_TYPE or MAGIC_MIME_ENCODING;
  { Return the Apple creator and type  }
MAGIC_APPLE = $000800;
  { Don't check for compressed files  }
MAGIC_NO_CHECK_COMPRESS = $001000;
  { Don't check for tar files  }
MAGIC_NO_CHECK_TAR = $002000;
  { Don't check magic entries  }
MAGIC_NO_CHECK_SOFT = $004000;
  { Don't check application type  }
MAGIC_NO_CHECK_APPTYPE = $008000;
  { Don't check for elf details  }
MAGIC_NO_CHECK_ELF = $01;
  { Don't check for text files  }
MAGIC_NO_CHECK_TEXT = $02;
  { Don't check for cdf files  }
MAGIC_NO_CHECK_CDF = $04;
  { Don't check tokens  }
MAGIC_NO_CHECK_TOKENS = $10;
  { Don't check text encodings  }
MAGIC_NO_CHECK_ENCODING = $20;
  { Defined for backwards compatibility (renamed)  }
MAGIC_NO_CHECK_ASCII = MAGIC_NO_CHECK_TEXT;
  { Defined for backwards compatibility; do nothing  }
  { Don't check ascii/fortran  }
MAGIC_NO_CHECK_FORTRAN = $00;
  { Don't check ascii/troff  }
MAGIC_NO_CHECK_TROFF = $00;
{ C++ extern C conditionnal removed }

type
  { improvising...
the struct magic_set is declared in a private header, but is is used like
a handle - ms
  }
  magic_set = pointer;

Re: [fpc-pascal] C translation question

2016-11-18 Thread Marc Santhoff
On Di, 2016-11-15 at 22:38 -0700, Lars wrote:

> I just wish CVS and SVN had as nice of a GUI front end (like github).
> That's the one thing I really like about git is the nice GUI access,
> simple readme system for projects etc. With CVS and SVN gui's and website
> front ends I never found anything that pleasing, although I haven't looked
> at third party front ends.

http://www.twobarleycorns.net/tkcvs.html

I'm using TkCVS for many years now. Really easy to handle und
understand, and it is capacle of doing the same for SVN. It does run on
Windows, too. On the downside you have to edit a file and insert
directory and project name in a file for TkCVS to know what it is doing.
Only needed once for a new source tree.

I like it.

HTH,
Marc


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


[fpc-pascal] picture preview

2016-11-08 Thread Marc Santhoff
Hi,

if I want load a bitmap picture for extracting a small preview of it,
what component or library would be best?

My goal is to use pascal only without any external lirbraries if
possible. Second goal is to keep the program small, ideally avoiding to
link lcl controls in.

Bitmap picture may be anything commen, JPEG, PNG, GIF, BMP, etc.

TIA,
Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-09 Thread Marc Santhoff
On Fr, 2016-09-09 at 09:06 +0100, Graeme Geldenhuys wrote:
> On 2016-09-05 05:02, fredvs wrote:
> > In FreeBSD forum they explain that FreeBSD 64 bit can run Linux 64 bit
> > applications (I am able too) but can only link Linux 32 bit applications
> > (that cannot be run on a FreeBSD 64 bit system).
> 
> That's weird. On my 64-bit FreeBSD, I can't run 64-bit Linux
> applications, but can run 32-bit Linux applications. So I'm experiencing
> a bit of the opposite to you then. :-/

Without an error message one can only guess what happened... ;)
Maybe you forgot to "brandelf -T Linux" the freshly compiled program?

Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-06 Thread Marc Santhoff
On Di, 2016-09-06 at 10:42 -0700, fredvs wrote:
> > No, I didn't. I only compile native programs.
> 
> Huh, it is what I wanted to ask...
> 
> Did you try to compile on a native FreeBSD 32 bit using -XX parameter (smart
> link).

No, I have no FreeBSD 32 Bit at hand, sorry.

Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-05 Thread Marc Santhoff
On Mo, 2016-09-05 at 16:42 -0700, fredvs wrote:
> Thanks Marc for that clear explanation, I knew linux emulation, of course,
> but not that nickname.
> 
> By the way, if you are using a FreeBSD 32 bit system, did you try to compile
> a fpc application with smart link enabled (*-XX* parameter) ?

No, I didn't. I only compile native programs. Even worse, when compiling
for Windows I do start Windows. ;)

Regards,
Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-05 Thread Marc Santhoff
On So, 2016-09-04 at 08:44 -0700, fredvs wrote:

> There is a answer there (but not sure I understand, what is "linuxolator" ?)

The Linuxolator is a freebsd specific term for the linux binary
emulation on freebsd.

AFAIK it is done by implementing a small layer between the linux
libraries and programs and the freebsd kernel. This small layer does
nothing more than forming a linux kernel api and translating linux
kernel calls to the freebsd equivalent.

See there for more details and in depth explanations:
https://www.freebsd.org/doc/en/articles/linux-emulation/article.html

HTH,
Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-03 Thread Marc Santhoff
On Fr, 2016-09-02 at 15:03 -0700, fredvs wrote:
> Hello Marc.
> 
> And thanks to help.

You're welcome.

[...]
> But when compiling on a FreeBSD 64 bit system using fpc-*linux-64*, there is
> that message on  linking:
> 
> [4.438] Searching file /bin/ld... found
> [4.438] Using util /bin/ld
> [4.438] Executing "/bin/ld" with command line "-b elf64-x86-64 -m elf_x86_64 
> *--dynamic-linker=/lib64/ld-linux-x86-64.so
> .2*  -L. -o ./test ./link.res"
> /bin/ld: warning: ./link.res contains output sections; did you forget -T?
> [246.930] test.pas(62,1) Error: Can't call the linker, switching to external
> linking
> [246.930] test.pas(62,1) Error: Error while linking
> [246.930] test.pas(62,1) Fatal: There were 2 errors compiling module,
> stopping
> [247.070] Fatal: Compilation aborted
> 
> So the question is:
> What define in fpc.cfg --->
> *with fpSystem call* 
> vs
> *--dynamic-linker=/lib64/ld-linux-x86-64.so.2* 
> 
> This because I want to try when linking using fpc-linux:
> 
> [4.438] Executing "/bin/ld" with command line "-b elf64-x86-64 -m elf_x86_64 
> *with fpSystem call*   -L. -o ./test ./link.res"

I don't know about the *with fpSystem call* problem, but the other is
solvable using 

  "fpc -k --dynamic-linker=/lib64/ld-linux-x86-64.so.2 ..."

as Jonas pointed out already.

Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-02 Thread Marc Santhoff
On Fr, 2016-09-02 at 09:32 -0700, fredvs wrote:
> Hello Marc.

Hi Fred.

> Thanks for the infos, good to know that it is possible to install linux
> package via FreeBSD-pkg install.
> Sadly I did not see any linux-ld or linux-binutils package in
> https://www.freebsd.org/ports/linux.html
> 
> So, the manually way that i did is the only way (yes/no ?).

Were reaching the end of my wisdom here. ;)

I know linux programs can be compiled on FreeBSD, but I do not know the
details. I'd suggest asking on one of the freebsd mailing lists or some
forum. You find them via the main page of the web site of freebsd in the
"community" menu.

Good luck,
Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-02 Thread Marc Santhoff
On Fr, 2016-09-02 at 08:57 -0700, fredvs wrote:
> Hello.
> 
> The night was very long and hard...
> 
> I have some result.
> 
> Here how I did:
> 
> - Copy ld-linux into /compat/linux/bin
> 
> - Copy dependencies-linux needed by ld-linux (some needed to be in
> /compat/linux/lib, other in /compat/linux/lib64).
> 
> - When using fpc-linux to compile-link a simple fpgui-programe, compilation
> is ok, linking begin but after 3 minutes, there is a message from fpc.
> 
> > Error (9014) Can't call the linker, switching to external linking
> > Error (9013) Error while linking.
> 
> So i tried to link manually all the compiled files in /units to see what
> appends with:
> 
>  ->  /compat/linux/bin/ld -o  /compat/linux/lib/crt0.o
> /usr/test/units/test.o -lc
> 
> And there is that error message:
> 
> 
>  
> 
> Do you have a idea what is wrong ?

Not very precise, but the error "undefinded reference to ..." tells you
it can't find something, that should be there. And since $FPG_MAIN is
the first I assume you will have to pass a list of paths to ld helping
it finding the .o files missing.

There are ways to see the path list the compiler hands over to the
linker - which others will have to show you because I don't know how -
and then you can use that path list to tell the linker while trying
manually.


Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-01 Thread Marc Santhoff
On Do, 2016-09-01 at 14:24 -0700, fredvs wrote:
> > Sorry, I can't help you much with that, ld-linux is not installed here
> > and I don't know which package it is from. 
> 
> Huh, is it possible to install Linux packages (apt-get install something) in
> a FreeBSD system ?
> Or do you mean (like I did), copy ld-linux from a installed Linux system. ?

Sorry for being terse. A package in this context is a pre-compiled
binary port on FreeBSD. So I should have written "which FreeBSD
package".

For relevant ports see there:

https://www.freebsd.org/ports/linux.html

Most of those are installable without compiling by using pkg(1).




Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-01 Thread Marc Santhoff
On Do, 2016-09-01 at 13:54 -0700, fredvs wrote:
> > See Greames message for why you still will have to use the Linux ld.
> > Your error message clearly says, the FreeBSD linker can only create bfsd
> > code for i386 and x64.
> 
> >> Supported emulation: elf_x86_64_fbsd and elf_i386_fbsd 
> 
> Yes, before to sent that topic, I have try with the Linux ld and...
> in fact it is absolutely the same file than ld-freebsd. (same size, same
> date).
> 
> And using ld-linux gives the same message:
> 
> >> Supported emulation: elf_x86_64_fbsd and elf_i386_fbsd 
> 
> So, maybe, (I do not know *ld*), like Jonas said, *ld *needs parameters to
> change default elf.
> But yes, the best is to try it. And asap. I will try to find time tonight.

Sorry, I can't help you much with that, ld-linux is not installed here
and I don't know which package it is from.

But many binaries are links to the original binary which, when started,
check under what name they were started and behave accordingly. So the
fact that it's the same binary does not mean it cannot do the job.

Try asking it what options in knows with --help or -h or whatever works.
And have a look at the man page with "man ld-linux".

If all that gives not enough hints you could go to www.freebsd.org and
look in the at the documentation. The handbook and maybe the developers
handbook or FAQ may help.

HTH somehow,
Marc


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


Re: [fpc-pascal] Linking to Linux on a FreeBSD system with Linux emulated ?

2016-09-01 Thread Marc Santhoff
On Do, 2016-09-01 at 09:56 -0700, fredvs wrote:
> > With fpc's -k parameter, you can pass parameters directly to the linker.
> > If you need to pass multiple parameters, use -k several times
> > (e.g.-k-para1 -kvalue1)
> 
> Wow, many thanks Jonas.
> 
> I will try it and write you the result.
> 
> But, imagine, with FreeBSD, you could:
> Compile and run on same system (no need virtual-box to test it):
> - FreeBSD 64 bit programs.
> - FreeBSD 32 bit programs.
> - Linux 64 bit programs.
> - Linux 32 bit programs.
> - Windows 64 bit programs (via wine).
> - Windows 32 bit programs (via wine).
> - Maybe other program-system too (via emulator).

See Greames message for why you still will have to use the Linux ld.
Your error message clearly says, the FreeBSD linker can only create bfsd
code for i386 and x64.

> Supported emulation: elf_x86_64_fbsd and elf_i386_fbsd

Have a look for brandelf(1), btw. You'll need it. And "man linux" will
tell some stories, too.

HTH,
Marc


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


Re: [fpc-pascal] Delphi may have Linux support next year

2016-08-30 Thread Marc Santhoff
On Di, 2016-08-30 at 11:31 -0500, Snorkl e wrote:
> Big deal, we can do all that and more with Lazarus and FPC

... without waiting for "perhaps next year".


Marc (using fpc/lazarus since fpc-version 1.9 or so ;)

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

2016-07-22 Thread Marc Santhoff
On Sa, 2016-07-23 at 05:55 +0200, Marc Santhoff wrote:
> On Fr, 2016-07-22 at 18:20 -0400, James Richters wrote:
> > I'm trying to avoid custom hardware if possible.  I have always used
> > parallel ports and never had a problem with them until now.   I like the
> > idea of a parallel port because they are still built onto motherboards, and
> > there are also a TON of USB to parallel port adapters out there.   I'm
> > trying to keep this simple.
> > 
> > I put a repository of my test program here:
> > https://github.com/Zaaphod/FPC-Parallel-Port.  Perhaps someone can see what
> > I'm doing wrong.I'm reading 255s no matter what I do.I included my
> > old turbo pascal test program.  I would normally specify the port in hex
> > with a $ like this $378.  I could write to the port then read back what I
> > just wrote.. which is what I am trying to do now.. I don't have anything
> > hooked up to the port yet, I should be able to write to it and read it back.
> > 
> > I seem to be accessing the DLL correctly, because I tried it on a windows 7
> > computer and  IsInpOutDriverOpen was false, because I forgot to install the
> > driver, once I installed the driver IsInpOutDriverOpen is now true, so that
> > tells me I'm accessing the DLL and the DLL is confirming the driver is open.
> 
> >From what I know, although it may be a bit outdated, on windows external
> functions have to be declared 'cdecl'. Which isn't so in the library
> port to pascal.
> 
> One example:
> 
>   implementation
>   Function IsInpOutDriverOpen; external 'inpout32.DLL';
> 
> would then be:
> 
>   implementation
>   Function IsInpOutDriverOpen; cdecl; external 'inpout32.DLL';

No, sorry. It has to be the other way round:

  Function IsInpOutDriverOpen; {$ifndef Win32}cdecl{$else}stdcall{$endif}; 
external 'inpout32.DLL';

I didn't recognize that it is  $ifndef, not $ifdef.

Marc


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


Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

2016-07-22 Thread Marc Santhoff
On Fr, 2016-07-22 at 18:20 -0400, James Richters wrote:
> I'm trying to avoid custom hardware if possible.  I have always used
> parallel ports and never had a problem with them until now.   I like the
> idea of a parallel port because they are still built onto motherboards, and
> there are also a TON of USB to parallel port adapters out there.   I'm
> trying to keep this simple.
> 
> I put a repository of my test program here:
> https://github.com/Zaaphod/FPC-Parallel-Port.  Perhaps someone can see what
> I'm doing wrong.I'm reading 255s no matter what I do.I included my
> old turbo pascal test program.  I would normally specify the port in hex
> with a $ like this $378.  I could write to the port then read back what I
> just wrote.. which is what I am trying to do now.. I don't have anything
> hooked up to the port yet, I should be able to write to it and read it back.
> 
> I seem to be accessing the DLL correctly, because I tried it on a windows 7
> computer and  IsInpOutDriverOpen was false, because I forgot to install the
> driver, once I installed the driver IsInpOutDriverOpen is now true, so that
> tells me I'm accessing the DLL and the DLL is confirming the driver is open.

>From what I know, although it may be a bit outdated, on windows external
functions have to be declared 'cdecl'. Which isn't so in the library
port to pascal.

One example:

  implementation
  Function IsInpOutDriverOpen; external 'inpout32.DLL';

would then be:

  implementation
  Function IsInpOutDriverOpen; cdecl; external 'inpout32.DLL';

HTH,
Marc


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


Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

2016-07-22 Thread Marc Santhoff
On Do, 2016-07-21 at 05:29 +0200, Marc Santhoff wrote:
> On Fr, 2016-07-15 at 14:59 -0700, Zaaphod wrote:
> > I am trying to get access to the parallel port with Free Pascal.  
> > 
> > I'm trying to use this version of inpout32 (x64)
> > http://www.highrez.co.uk/downloads/inpout32/ 
> > 
> > Here's my program:
> > http://pastebin.com/facf6EFc
> > 
> > Here's my Unit:
> > http://pastebin.com/XR0aYUPR
> > 
> > When I try to run it, I get a windows message The application was
> unable to
> > start correctly (0xc07b). click ok to close the application.
> 
> You could search Microsofts web site to decode this error. 

Or use a search engine:

http://www.techanges.com/fix-error-0xc7b/
http://stackoverflow.com/questions/10492037/the-application-was-unable-to-start-correctly-0xc07b

Looks like you are using a 32 Bit version on 64 bit or the like. The
original site tells about similar error:

http://www.highrez.co.uk/downloads/inpout32/

Look at the update history...


Marc

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


Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

2016-07-21 Thread Marc Santhoff
On Do, 2016-07-21 at 08:39 -0500, Paul Breneman wrote:

> You can do *everything* via USB. :) I joked about this several years ago 
> but then went searching and found USB to ISA slot and USB to PCI slot 
> adapters.  Folks use these to run expensive data acquisition cards.

https://www.youtube.com/watch?v=MoREmn7SCwg ?

CNR,
Marc


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


Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows

2016-07-20 Thread Marc Santhoff
On Fr, 2016-07-15 at 14:59 -0700, Zaaphod wrote:
> I am trying to get access to the parallel port with Free Pascal.  
> 
> I'm trying to use this version of inpout32 (x64)
> http://www.highrez.co.uk/downloads/inpout32/ 
> 
> Here's my program:
> http://pastebin.com/facf6EFc
> 
> Here's my Unit:
> http://pastebin.com/XR0aYUPR
> 
> When I try to run it, I get a windows message The application was unable to
> start correctly (0xc07b). click ok to close the application.

You could search Microsofts web site to decode this error.

> then  I get Exitcode 123 in the Free Pascal IDE.  123 is decimal of 7b.
> 
> Does anyone know how to get this to work?   reading and writing the parallel
> port used to be so easy, now it's extremely confusing, thanks windows!

Didn't test, but as a remark: parallel port is dead and it has been a
constant source of problems. First the access rights problems you know
of. Second it has no fixed timing, so you're in trouble when e.g.
flashing a microcontroller works on one machine and refuses to on
another one. Third it is not electrically protected, if you fry it, the
mainboard is dead by chance or you have to insert an extension board -
which is hard to find nowadays, too.

Depending on your needs I'd suggest using a USB-to-serial-Adapter or
similar. They are cheap and well supported (e.g. using CP2102). As an
alternative FTDI has some nice USB-to-anything (including parallel)
chips and they sell modules with mil spacing pins for easy
breadboarding.

HTH somehow,
Marc


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


Re: [fpc-pascal] FPC sources in FreeBSD

2016-07-09 Thread Marc Santhoff
On Sa, 2016-07-09 at 12:28 +0300, Juha Manninen wrote:
> Thanks everybody for help and comments.
> My memory is recovering slowly about keyboard configuration. It was
> many years ago I did it manually for Linux distros.
> But yes, "setxkbmap fi" in .xinitrc did the job.
> 
> I confused "pkg" and "ports". Must learn more about the topic.

Easy if you know:

ports  are sources ported to FreeBSD, the port holds patches,
   building rules, configuration, etc. They live in "the
   ports tree" usually in /usr/ports, if you installed it

packages   are binary, precompiled programs, made from ports. Can be
   installed directly using "pkg".

pkgis the program for installing, deleting, getting info about
   packages, a package managing program.


> I am quite happy with my current host OS, Manjaro Linux + KDE. Not
> planning to change it.

So you know about dot-names for hidden files and other basics. ;)

Marc

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


Re: [fpc-pascal] FPC sources in FreeBSD

2016-07-08 Thread Marc Santhoff
On Fr, 2016-07-08 at 23:03 +0300, Juha Manninen wrote:
> Hello
> 
> I installed FreeBSD 10.3 under VirtualBox. This is the first time I
> use FreeBSD. Cool!
> I managed to install X, XFCE and all applications I need.
> FPC and Lazarus both work.
> 
> Only thing missing now is FPC source code, needed by Lazarus.
> Can it be installed from ports with "pkg" command?
> I don't see sources in "pkg search fpc" output list.

I never did that. Fpc in the ports has been fragmented into lots of
single ports in the past. Since I prefer to have anything in one go I do
the same as Graeme, using the official installers.

For lazarus anything I do is get the source, unpack an type "make
bigide" in it's directory.

> Another thing missing from my FreeBSD is proper keyboard mapping. It
> behaves like US keyboard now.

If you run X by the start script "startx" it is sufficient to add the
following line to the file ".xinitrc" in you home directory:

setxkbmap de

Replacing the "de" with what you need. Type "man setxkbmap" in a
terminal (xterm) for more info. And don't get confused, names starting
with a dot are hidden but existing.

Have fun,
Marc


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


Re: [fpc-pascal] Single threaded application on multicore CPU

2016-06-23 Thread Marc Santhoff
On Mi, 2016-06-22 at 15:01 +0200, Mattias Gaertner wrote:
> On Wed, 22 Jun 2016 13:36:08 +0100
> Graeme Geldenhuys  wrote:
> 
> > On 2016-06-22 13:14, Mattias Gaertner wrote:
> > > On my Linux it does not swap the CPU and I can't find any hard data that
> > > Windows is swapping because of hotspot problems,  
> > 
> > It’s not just a Windows thing. On my FreeBSD system...
> 
> I don't doubt that it is swapping. I would like to know why it is
> swapping. Is it avoiding hotspots, or for longevity, or turbo boost, or
> system processes, or security, or 
> Related: What is the downside of pinning the process to a cpu?

AFAIK it is mostly a matter of the OSs scheduler implementation. E.g. on
FreeBSD you can select at least two variants (sched_ule, sched_4bsd).

A short glimpse on what thats all about may be read there:

http://www.freebsd.org/cgi/man.cgi?query=sched_4bsd=4=0=FreeBSD+10.3-RELEASE+and+Ports

http://www.freebsd.org/cgi/man.cgi?query=sched_ule=0=0=FreeBSD+10.3-RELEASE+and+Ports=default=html

An abstraction of the scheduler from the physical count of CPUs is a
good thing, at least from OS writers view. If that would not be the case
everyone running that OS would have to compile or at least install a
specially designed kernel...

The decision not to pin processes to cpus by default sounds logical to
me. Process number CPU-count + 1 would have to wait immediately.

The other way round, switching a process from cpu to cpu happens
automatically, I think. If there is some form of process queue with
processes ready to run, the will get distributed to the cpu free to
execute them in that (very small) moment. Being able to pin processes to
cpus is the logical consequence of such design.

After all, I am only guessing, too... ;)

Marc


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

Re: [fpc-pascal] Parser Generator

2016-05-20 Thread Marc Santhoff
On Fr, 2016-05-20 at 10:53 +0200, Marc Santhoff wrote:

> There are some tools I liked very much when dealing with language
> translation in the past, but they don't fit her. None of them generates
 ^e
"they don't fit here."

Fatal typo. I know Torsten is not a girls name.

Marc


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


Re: [fpc-pascal] Parser Generator

2016-05-20 Thread Marc Santhoff
On Fr, 2016-05-20 at 08:38 +, Mark Morgan Lloyd wrote:
> Marc Santhoff wrote:
> > On Do, 2016-05-19 at 13:10 +0200, Torsten Bonde Christiansen wrote:
> > 
> >> * GOLD Parser: http://www.goldparser.org/
> 
> >> * COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
> 
> >> * TP Yacc/Lex: (included in Free Pascal)
> 
> > http://www.atocc.de/cgi-bin/atocc/site.cgi?lang=en=main
> > 
> > Sorry, I had no time to test it yet.
> 
> "For target code generation you need to specify code fragments for each 
> rule in VCC."

Örks. Didn't read that.

> I think the important thing for all of these is that they still assume a 
> lot of hard work from the person defining the custom syntax. They're not 
> a magic bullet.

There are some tools I liked very much when dealing with language
translation in the past, but they don't fit her. None of them generates
Pascal Code out of the box.

ANTLR3 was my favourite, generating tree walkers with little extra work
(iirc). But it generates Java code.

> For the last 30 years or so I've been using a compiler compiler 
> originally written in 1964, the implementation has matured as different 
> pascal compilers have become available. I'm not suggesting that this is 
> usable in the general case, but looked at objectively it does allow me 
> to make gross behavioural changes fairly easily, e.g. to define novel 
> string properties and to embed pragmata in comments.

Beautiful. Would you mind disclosing the name of that fine tool? ;)

Marc


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


Re: [fpc-pascal] Parser Generator

2016-05-19 Thread Marc Santhoff
On Do, 2016-05-19 at 13:10 +0200, Torsten Bonde Christiansen wrote:

> * GOLD Parser: http://www.goldparser.org/
> Was last updated in sept. 2012 and the lastest pascal implementation is 
> not for the lastest version of the program!
> 
> * COCO/R: http://www.ssw.uni-linz.ac.at/Research/Projects/Coco/
> Same as with the GOLD parser - last updated in 2014 and lastest pascal 
> implementation is for an older version of the program.
> 
> * TP Yacc/Lex: (included in Free Pascal)
> Is included with Free Pascal, but the generated code is non-OO, and 
> seems to rely on text-files for input.
> 
> So if there is anyone out there who knows of such a generator I would be 
> glad to know.

There is a german learning programm named AtoCC. It can generate Object
Pascal Code:

http://www.atocc.de/cgi-bin/atocc/site.cgi?lang=en=main

Sorry, I had no time to test it yet.

Marc


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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 09:47 -0700, fredvs wrote:
> Re-hello.
> 
> To resume.
> 
> Here what is working perfectly for me:
> 
>  {$IF DEFINED(freebsd)}
> ...
>  var
> ap1 : pointer;
> begin
>   ap1 := dlopen(Pchar(mp4ff), 1);
>   Pointer(mp4ff_open_read) :=  dlsym(ap1, pchar('mp4ff_open_read'));
> ...
>  {$else}
> ...
>  var
> an1 : integer;
> begin
>   an1 := DynLibs.SafeLoadLibrary(PChar(mp4ff));
>   Pointer(mp4ff_open_read) :=  GetProcAddress(an1,
> pchar('mp4ff_open_read'));
> ...
>  {$endif}

That's totally OK, but the unit dynlibs is written for platform
independence and I'd like to be able to use it on FreeBSD and at least
Windows without having much $ifdefs and the like.

Have fun,
Marc

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 15:10 +0100, Marc Santhoff wrote:
> On So, 2016-03-20 at 14:27 +0100, Ewald wrote:
> 
> > Could this be related to pointer trucation? The man page of dlopen tells
> > us that the return value is a pointer (hence the return value of
> > LoadLibrary has the same width). In your example you used an integer. Is
> > sizeof(Integer) = sizeof(Pointer) of your system?
> > 
> > If for example, you are missing the upper four bytes of the pointer, the
> > above message makes sense.
> 
> Good point:
> 
> marc@puma:/home/marc/program/Test_fpc/LoadLibrary > uname -mrs
> FreeBSD 9.1-STABLE amd64
> 
> marc@puma:/home/marc/program/Test_fpc/LoadLibrary > ./pointersize
> pointersize: 8
> size of integer: 2
> 
> marc@puma:/home/marc/program/Test_fpc/LoadLibrary > cat pointersize.pas 
> program pointersize;
> uses
>   sysutils;
> begin
>   writeln('pointersize: ' + inttostr(sizeof(pointer)));
>   writeln('size of integer: ' + inttostr(sizeof(integer)));
> end.

Doing it right it seems to work, I've tried three libs with one of them
definitely not part of the OS but from a port:

program loadlibrary;
{$mode objfpc}{$H+}
uses
  sysutils, dynlibs;
var
  //libname: string = '/usr/lib/libalias.so';
  //fncname: string = 'AddLink';
  //libname: string = '/usr/lib/libipsec.so';
  //fncname: string = 'ipsec_dump_policy';
  libname: string = '/usr/local/lib/vlc/plugins/codec/libx264_plugin.so';
  fncname: string = 'vlc_entry__1_1_0g';

  libhandle: TLibHandle;
  pfnc: pointer;
begin
  libhandle := dynlibs.LoadLibrary(pchar(libname));

  if (libhandle = 0) then begin
writeln('loading error: ' + GetLoadErrorStr);
halt(1);
  end else
writeln('library ' + libname + ' loaded.');

  pfnc := GetProcedureAddress(libhandle, pchar(fncname));
  if (pfnc = NIL) then
writeln('got proc address error: ' + GetLoadErrorStr)
  else begin
writeln('function ' + fncname + ' loaded.');
writeln(inttostr(qword(pfnc)));
  end;

  UnloadLibrary(libhandle);

end.

I did not call any of those functions, but their nakmes are found and
loaded by dlsym. For all three libraries the program worked fine.

For Fred:
You can check the names inside a dynamic liobrary using system tools:

nm -D /usr/lib/libipsec.so
nm -D /usr/local/lib/vlc/plugins/codec/libx264_plugin.so

The letters after the address tell the type of symbol, see

$ man nm

for an in detail explanation. Mostly those having a T are really inside
the library, U means unresolved and so linked fgrom another lib.


-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 14:27 +0100, Ewald wrote:

> Could this be related to pointer trucation? The man page of dlopen tells
> us that the return value is a pointer (hence the return value of
> LoadLibrary has the same width). In your example you used an integer. Is
> sizeof(Integer) = sizeof(Pointer) of your system?
> 
> If for example, you are missing the upper four bytes of the pointer, the
> above message makes sense.

Good point:

marc@puma:/home/marc/program/Test_fpc/LoadLibrary > uname -mrs
FreeBSD 9.1-STABLE amd64

marc@puma:/home/marc/program/Test_fpc/LoadLibrary > ./pointersize
pointersize: 8
size of integer: 2

marc@puma:/home/marc/program/Test_fpc/LoadLibrary > cat pointersize.pas 
program pointersize;
uses
  sysutils;
begin
  writeln('pointersize: ' + inttostr(sizeof(pointer)));
  writeln('size of integer: ' + inttostr(sizeof(integer)));
end.

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 05:11 -0700, fredvs wrote:
> >> ap1 := dlopen(Pchar(lib), 0);
> 
> > Here you are using 0 for three mode argument. One difference I can see
> > ist that uysing dynlibs.pas the mode is RTLD_LAZY like it should be, but
> > that constant is defined as 1. 
> 
> Huh, indeed, 0 is working in Linux but not in FreeBSD --> changed to 1 and
> all ok in FreeBSD.

So that's not the cause.

> > Or simply dlerror() like in the other program, should work. 
> 
> OK. here code + result of GetProcedureAddress(), maybe it could help for
> future fixes in fpc:
> 
> GetProcedureAddress(hn, pchar('mp4ff_open_read');
> writeln(dlerror());
> 
> ---> Result:
> 
> "Invalid shared object handle 0x2fb2800"

Doesn't tell much, I fear. I'll have to do same testing myself to find out.

> Many, many thanks to Marc, Marco, Ewald and Sven.

You're welcome, thanks for reporting and testing.

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On Sa, 2016-03-19 at 14:39 -0700, fredvs wrote:
> @ Marco and Marc thanks for help.
> 
> Sorry I do not have easy internet connection so I worked by my side.
> 
> I will try your tips.
> 
> By the way, here are my investigations:
> 
> 
> 
> Hello.
> 
> Ok, ok, understood and wow.
> 
> Added in code:
> 
> Function dlopen(filename: PChar; flags: cint): Pointer; cdecl; external;
> Function dlclose(handle: Pointer): cint; cdecl; external;
> Function dlsym(handle: Pointer; Name: PChar): Pointer; cdecl; external;
> Function dlerror: PChar; cdecl; external;
> 
> and, magic, it works. ;-)
> 
> Now the result:
> 
> In code:
> 
> procedure loadmylib(lib : pchar);
> var
> ap1, ap2, ap3 : pointer;
> '
> begin
> /// FreeBSD functions:
> ap1 := dlopen(Pchar(lib), 0);

Here you are using 0 for three mode argument. One difference I can see
ist that uysing dynlibs.pas the mode is RTLD_LAZY like it should be, but
that constant is defined as 1.

Does anyone now if this really makes a difference?

> if ap1 <> nil then
> writeln('dlopen() is OK') else
> writeln('dlopen() is NOT OK') ;
> 
> ap2 := dlsym(ap1, Pchar('mp4ff_open_read');
> if ap2 <> nil then
> writeln('dlsym() is OK') else
> writeln('dlsym() is NOT OK') ;
> 
> writeln(dlerror());
> 
> end;
> 
> ---> result:
> writeln('dlopen() is OK')
> writeln('dlsym() is OK')
> _ (no error)
> 
> --
> Now with DynLibs:
> 
> procedure loadmylib(lib : pchar);
> var
> ap1: pointer;
> hn : integer;
> '
> begin
> /// with dynlibs
> hn := dynlibs.loadlibrary(Pchar(lib));
> 
> if hn <> 0 then
> writeln('loadlibrary() is OK') else
> writeln('loadlibrary() is NOT OK') ;
> 
> ap1 := getprocedureaddress(hn, Pchar('mp4ff_open_read');
> 
> if ap1 <> nil then
> writeln('getprocedureaddress() is OK') else
> writeln('getprocedureaddress() is NOT OK') ;

Looking at dynlibs.pas you can use

  Function GetLoadErrorStr: string;

here. Or simply dlerror() like in the other program, should work.


> end;
> 
> --> result:
> 
> loadlibrary() is OK
> getprocedureaddress() is NOT OK
> 
> 
>  
> Conclusion: Maybe getprocedureaddress() has problems.

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Marc Santhoff
On Mo, 2016-03-14 at 08:15 -0700, fredvs wrote:
> Hello.
> 
> I have problem to access methods from a C library.
> 
> For FreeBSD, the methods cannot be accessed (but ok for Linux and Windows).
> 
> In FreeBSD, LoadLibrary(aac.so) is working but all GetProcAdress() for each
> method fail.

> Does anybody have a idea why GetProcAdress() fail in FreeBSD (but ok for
> Linux and Windows) ?
> 
> Or must the library-code be compiled with some special instructions for fpc
> ?
> 
> Every comment or light is highly welcome (tips, must-know, etc,...).

It would be helpful to see the code fragments in question. The
declaration of the external functions if any and the code calling
LoadLibrary() and GetProcAddress().

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Marc Santhoff
On Fr, 2016-03-18 at 16:34 -0700, fredvs wrote:
> > When following the procedure calls I find: 
> ...
> 
> Hello Mark.
> 
> Thanks for your light.
> 
> Huh, yes, IMO, there is something strange in dlsym/FreeBSD.

Would you mind telling the result of dlerror()?

> And asking something about C library/compiler is extremely sensible there on
> FreeBSD forum.
> (FreeBSD needs 8 (!) different C compilers (clang, c++, CC, cc, cpp, ...) to
> compile himself).

Not really. Since c++ is the same compiler as (g)cc, cpp is the C
ppreprocessor an CC is mostly only used as a variable name in Makefiles
and shell skripts set to the right compiler, that is clearly wrong.

There are in fact different C compilers which are all able to compile C
or C++. There is actually the system compiler, which has been gcc and
will be or is already clang. Some ports require newer versions of gcc,
so sometimes there are two or three of them installed. But that's it,
AFAIK.

Look:

marc@puma:/home/marc > cc -v
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070831 patched [FreeBSD]

marc@puma:/home/marc > gcc -v
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070831 patched [FreeBSD]

marc@puma:/home/marc > CC -v
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070831 patched [FreeBSD]

marc@puma:/home/marc > c++ -v
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070831 patched [FreeBSD]

marc@puma:/home/marc > cpp --version
cpp (GCC) 4.2.1 20070831 patched [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

All the same. ;)
Only that one differs:

marc@puma:/home/marc > clang -v
FreeBSD clang version 3.0 (tags/RELEASE_30/final 145349) 20111210
Target: x86_64-unknown-freebsd9.0
Thread model: posix


You can try looking at the manual pages, type in "man cc" and the other
names.

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Marc Santhoff
On Do, 2016-03-17 at 04:27 -0700, fredvs wrote:
> > it would be helpful to see the code fragments in question.
> > The declaration of the external functions if any and the code calling
> > LoadLibrary() and GetProcAddress(). 
> 
> Hello Mark and thanks for help.
> 
> Here declaration to load-getprocess:
> -
> var
>   mp4ff_open_read: function(f : p_mp4ff_callback_t) : mp4ff_t; cdecl;
>   libpointer : {$IFDEF MSWINDOWS}longword{$ELSE}{$IFDEF
> CPU32}longword{$ELSE}PtrInt{$ENDIF}{$ENDIF};
> ...
> 
> libpointer := DynLibs.SafeLoadLibrary(PChar(mp4ff)); -> OK for FreeBSD64
> too;-)
> 
>  Pointer(mp4ff_open_read) :=
> GetProcAddress(hMp4ff, pchar('mp4ff_open_read')); -> Here always =
> nil for FreeBSD 64 ;-( (but ok for Linux + Windows)
> ...
> -

When following the procedure calls I find:


Function GetProcAddress(Lib : TlibHandle; const ProcName : AnsiString) :
Pointer;

begin
  Result:=GetProcedureAddress(Lib,Procname);
end;


Next is:


Function GetProcedureAddress(Lib : TLibHandle; const ProcName :
AnsiString) : Pointer;

begin
  Result:=dlsym(lib,pchar(ProcName));
end;


Okay, man page says:

http://www.freebsd.org/cgi/man.cgi?query=dlsym=0=0=FreeBSD+10.2-RELEASE=default=html

You could do some things, like trying to use the special handle
RTLD_NEXT, or and much more important, call dlerror() after the failing
dlsym(). It should tell _why_ the call failed.

> PS: I have the same problem for other libraries in FreeBSD 64 ->
> GetProcAddress() fail.
> PS2: It appends for some libraries in FreeBSD64, not all.

Intresting. I know there are differences in the systems dlopen() and
another similar variant installed by libtool, found in libbtdl regarding
to my notes. Dunno if it matters. Libtools implementation does
differentiate between OSs by itself (at compile time). Cold be a source
of confusion...

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] ARM CMSIS support

2016-02-23 Thread Marc Santhoff
On Di, 2016-02-23 at 15:58 +0100, Bernd Mueller wrote:
> Marc Santhoff wrote:
> 
> > Did you use the stmf103fw.pas translation from Jeppe or make you own
> > unit for supporting the 429?
> 
> I needed only a few peripherals (GPIO, USART, RCC and embedded FLASH). I 
> wrote this stuff by myself.

OK.

> > My target would be f407, although the project in mind has to be done
> > using an Atmel SAM7 now, programmed in C... :|
> 
> I used the AT91SAM7S256 controller 5 years ago (with fpc 2.3.1 btw). If 
> I had to use ATMEL, I would look at the SAM3S or SAM4S family. They 
> should replace the SAM7 which is now over 10 years old. But since ATMEL 
> has been bought by Microchip, I would avoid them.

I know, I know. But it is a low volume device and the chips are in
stock. Plus there is the complete compiler and support/HAL-library stuff
already done.

-- 
Marc Santhoff <m.santh...@web.de>

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


Re: [fpc-pascal] ARM CMSIS support

2016-02-23 Thread Marc Santhoff
On Di, 2016-02-23 at 12:25 +0100, Bernd Mueller wrote:
> Michael Ring wrote:
> > 
> > (Glad to hear that basic functionality works...)
> 
> I finished my first (small) project with the STM32F429ZI controller and 
> everything went smooth :-) Even with optimization level -O2.
> 
> Thanks everyone, who is involved in the ARM compiler/rtl development.

Did you use the stmf103fw.pas translation from Jeppe or make you own
unit for supporting the 429?

My target would be f407, although the project in mind has to be done
using an Atmel SAM7 now, programmed in C... :|

-- 
Marc Santhoff <m.santh...@web.de>

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


  1   2   3   4   5   6   >