Re: [fpc-pascal] Reading AM2302 temp/humid sensor on RaspberryPi?

2018-08-22 Thread R0b0t1
On Wed, Aug 22, 2018 at 4:19 PM, Bo Berglund  wrote:
> I wonder if there are any demo projects around for reading the AM2302
> DHT sensor on a RaspberryPi through FreePascal?
> Any links to sample code would be appreciated.
> I have used it on an ESP-07 WiFi module (C language and Arduino
> environment) but now I would like to get it going on an RPi using
> FPC/Lazarus.
>

Can you briefly describe its protocol? Does it look anything like
Dallas/Maxim Semi 1-wire or I2C, or is it something else? If it is
either of those the I2C or SPI peripheral likely could do it. Even if
not the SPI peripheral may work.

It looks like pulse length modulation as used in IR receivers. Some
SPI peripherals have a mode that will read this; in other cases, you
can set the clock speed to the GCD of all signalling times and receive
a bitstream that maps to high/low intervals.


If you need to go DIY I think you will be able to easily, without
kernel modifications or writing kernelspace code. You should be able
to sleep for microseconds using nanosleep(2) (which is used by
usleep(3)). I think I read that for small values nanosleep(2) should
busy loop instead of yielding to the scheduler.  Or perhaps not.

I usually like to stick a small ARM chip somewhere (used to be an AVR)
to handle these things as the hardware is usually more configurable.

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

Re: [fpc-pascal] Reading AM2302 temp/humid sensor on RaspberryPi?

2018-08-22 Thread Bo Berglund
On Wed, 22 Aug 2018 23:19:28 +0200, Bo Berglund
 wrote:

>I wonder if there are any demo projects around for reading the AM2302
>DHT sensor on a RaspberryPi through FreePascal?
>Any links to sample code would be appreciated.
>I have used it on an ESP-07 WiFi module (C language and Arduino
>environment) but now I would like to get it going on an RPi using
>FPC/Lazarus.

Just to clarify, if I have to go the Do It Yourself route and read the
data from the sensor directly:

I have done some relay control GPIO I/O code before using FPC on the
RPi2 which used the PiGpio.pas unit:
(http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi#PiGpio_Low-level_native_pascal_unit_.28GPIO_control_instead_of_wiringPi_c_library.29)

But that code only used simple pin on/off commands at low speed and
for the DHT sensor one needs to set and clear the pins at microsecond
timing and to read the data one needs to measure pin level durations
at microsecond level. This might not easily be accomplished on a Linux
system...
The DHT sensor is started by pulling the comm line low for about 1 ms,
then releasing it. Then the DHT will send 40 bits of data where the
bit value depends on the pulse high time in a 0-1-0 sequence where the
1 time is (nominal) 26 us for data=0 and 70 us for data=1.
So one has to measure the high time for each pulse to determine the
bit value. And the resolution is in the us range...

So I wonder if there are some examples of doing that, for example
using the PiGpio unit.
But better yet would be a complete DHT driver in pascal of course...

Question: Should I ask this on the Lazarus list instead?

(There seems to be no Pascal subforum at the Raspberrypi forum...)


-- 
Bo Berglund
Developer in Sweden

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

Re: [fpc-pascal] Type helper for JNI pointers

2018-08-22 Thread Andrew Haines via fpc-pascal



On 08/12/2018 07:42 AM, Benito van der Zander wrote:



But this does not work, because fpc thinks jclass and jobject are the 
same type, so there is only one type helper for both of the types allowed.


Because it is declared as

type
 jobject=pointer;
 jclass=jobject;


What can we do about this?


I haven't used type helpers but why not change to defines like

type
  jObjectRec = record end;
  jObject= ^jObjectRec;
  jClassRec = record end;
  jClass = ^jClassRec;

or possibly simpler you could try
  jclass = type(jobject); // I believe this forces a new type and is 
not just an alias


Regards,

Andrew

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

Re: [fpc-pascal] Link with GCC object files

2018-08-22 Thread Andreas Berger

Thank you Sven, this will be a big help

Regards,
Andreas


On 22/08/2018 12:12, Sven Barth via fpc-pascal wrote:
Andreas > schrieb am Mi., 22. Aug. 2018, 
12:59:


Hi, I have a question. Is it possible to link FPC for Linux (PC
and ARM)
with GCC or other C++ object files?


You can use the $L directive for this ( 
https://freepascal.org/docs-html/current/prog/progsu43.html#x50-490001.2.43 
).
If you use C++ it's recommended to use "extern "C"" however even 
though FPC supports cppdecl (as it can't handle all cases currently). 
And classes won't work either.


Regards,
Sven


___
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] Reading AM2302 temp/humid sensor on RaspberryPi?

2018-08-22 Thread Bo Berglund
I wonder if there are any demo projects around for reading the AM2302
DHT sensor on a RaspberryPi through FreePascal?
Any links to sample code would be appreciated.
I have used it on an ESP-07 WiFi module (C language and Arduino
environment) but now I would like to get it going on an RPi using
FPC/Lazarus.


-- 
Bo Berglund
Developer in Sweden

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

Re: [fpc-pascal] Link with GCC object files

2018-08-22 Thread Sven Barth via fpc-pascal
Andreas  schrieb am Mi., 22. Aug. 2018, 12:59:

> Hi, I have a question. Is it possible to link FPC for Linux (PC and ARM)
> with GCC or other C++ object files?
>

You can use the $L directive for this (
https://freepascal.org/docs-html/current/prog/progsu43.html#x50-490001.2.43
).
If you use C++ it's recommended to use "extern "C"" however even though FPC
supports cppdecl (as it can't handle all cases currently). And classes
won't work either.

Regards,
Sven

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

[fpc-pascal] Link with GCC object files

2018-08-22 Thread Andreas
Hi, I have a question. Is it possible to link FPC for Linux (PC and ARM) 
with GCC or other C++ object files?


Regards,
Andreas Berger


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

Re: [fpc-pascal] Very slow startup of Frepascal programs on just one system

2018-08-22 Thread James
>Does the same happen for GUI programs compiled with FPC on that machine?
I don't have any FPC GUI programs, they are all console programs, some console 
with ptcgraph 

>As a test try to disable your anti virus and/or Windows Defender.

>Pretty much only security software/anti virus.

Yes that is what it was... there was some free trial of Mcafee antivirus 
preinstalled on this system, and it had a feature that scanned every single 
file every time it was opened... I have NO idea how they can possibly take over 
50 seconds to scan a 70KB hello world program, they have an severe bug in their 
scanner, it's a silly feature anyway, because if you scan every file as it's 
put on the system, they why do you need to scan it again every time you use the 
file.   Anyway the free trial was going to expire in 2 days anyway, and the 
delay was completely unacceptable, so I just removed the entire thing and 
activated windows defender and now everything is running normally.

Thanks everyone for the help getting to the problem!

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

Re: [fpc-pascal] Very slow startup of Frepascal programs on just one system

2018-08-22 Thread Tomas Hajny
On Wed, August 22, 2018 11:06, James wrote:


Hello,

> I am experiencing very slow startup of all of my
> freepascal programs for windows on just one computer.
 .
 .

Does the same happen for GUI programs compiled with FPC on that machine?

Tomas


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

Re: [fpc-pascal] Very slow startup of Frepascal programs on just one system

2018-08-22 Thread Marco van de Voort
In our previous episode, James said:
> Does anyone have any idea what could be going on to cause such a
> slowdown?  

Pretty much only security software/anti virus.

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

Re: [fpc-pascal] Very slow startup of Frepascal programs on just one system

2018-08-22 Thread Sven Barth via fpc-pascal
James  schrieb am Mi., 22. Aug. 2018, 11:06:

> Any ideas on what may be going on?   This is pretty much un-usable with
> these huge delays every time I need to start one of my freepascal
> programs.
>
As a test try to disable your anti virus and/or Windows Defender.

Regards,
Sven

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

[fpc-pascal] Very slow startup of Frepascal programs on just one system

2018-08-22 Thread James
I am experiencing very slow startup of all of my freepascal programs for
windows on just one computer.  Normally they all start pretty much
instantly, but I just got a brand new Dell XPS desktop computer and they are
all starting up VERY slowly,  even simple console programs.. Even 'Hello
World'  take over 50 full seconds to start, even when running from a RAM
Drive.   Does anyone have any idea what could be going on to cause such a
slowdown?They all run faster than this on an ancient XP computer, I
don't understand what's taking so long on this new PC. All my programs
are compiled with FPC 3.0.4rc1 and normally start instantly even on my
slowest windows tablet pc. except for this new computer, and everything else
on this computer starts very fast,  it's only all of my freepascal programs
that start very very slow.  Once my programs finally.. eventually.. Get
around to starting, they execute just fine,  no further delay in processing,
disk access, or graphics.   I thought it might be smart screen or a virus
scanner causing the delay, so I turned those off,  still have a huge delay.
No matter what I do, every freepascal program I have ALWAYS takes at least
50 seconds to start on this system.

 

The system is this one:
https://www.dell.com/en-us/work/shop/desktop-and-all-in-one-pcs/xps-tower-sp
ecial-edition/spd/xps-8930-se-desktop/cto8930w10pcfl4h?ref=569_prodTitle
but it has been upgraded to 64GB of RAM, and a solid state hard drive.   The
processor is Intel Core i7-8700K @3.7GHz and is running windows 10 Pro
64bit.  This should be the fastest computer I have, yet it's the only one
with this issue.

 

Hello world program is this:

Begin

Writeln('Hello World');

Readln;

End.

 

Any ideas on what may be going on?   This is pretty much un-usable with
these huge delays every time I need to start one of my freepascal programs.


 

 

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