Function wiringPiISR (pin:longint; edgeType:longint; var callback):longint;cdecl;external;That may not work, but test it to be sure. I prefer to use a typed parameter, that way the compiler can help ensure that you only pass a procedure with the correct signature:
Is this correct?
Hello ccrause,
it's me again! :-[
Got an error (see below):
Projekt kompilieren, Ziel: project1: Exit code 1, Fehler: 1, Hinweise: 1
unit1.pas(61,27) Error: Call by var for arg no. 3 has to match exactly: Got "<address of procedure;StdCall>" expected "<procedure variable type of procedure;CDecl>"
hwiringpi_DHA.pas(73,10) Hint: Found declaration: wiringPiISR(LongInt;LongInt;var TIsrProc):LongInt; CDecl;
Please help!
project1.lpr(23,0) Error: Error while linking[/i]Progress of some sorts. Seems like the linker either cannot locate the library, or the new function you are trying to wrap.
As soon as I uncomment the call "wiringPiISR(1, 1, @myISR);" in my test-program/unit it stops without showing the form (in my experience this is usually due to an error).There isn't a call to one of the setup functions (http://wiringpi.com/reference/setup/). There may be more subtle configuration problems if you just call functions at random. Permissions to access the hardware may have to be given to the user running the software. I don't have a Pi configured for testing so cannot help with actual testing on hardware.
But compiling was ok.
Do you have any idea what's going wrong?
One problem solved, the next one is on the way... %)Perhaps you need to give an example here, in my limited understanding wiringPi relies on the OS kernel to call the interrupt handler. So no waiting is required? Perhaps you need to explain a bit more what your requirements are.
In order to wait for an interrupt usually endless loops are used.
But this blocks the GUI.
Using other programming languages I solved this with multithreading. (but in Pascal I do not know how to implement multithreading)
Is there a better way to wait for an interrupt while GUI is nonblocking in Pascal/Lazarus?
Could you please give me a hint where to find such (solved) problems inside this forum?
Should I start a new thread for this problem?
Perhaps you need to give an example here, in my limited understanding wiringPi relies on the OS kernel to call the interrupt handler. So no waiting is required? Perhaps you need to explain a bit more what your requirements are.My requirement/application is to count pulses of an anemometer.
A question to your example code:I was imagining an example where a motor (switched on/off via pin 0) is moving an object. The motor needs to stop/switch off when a limit switch (connected to pin 1) is triggered. The ISR is connected to the limit switch pin, when triggered the motor is immediately stopped in the ISR callback (high priority action) and a message is posted to the main to display a message (low priority action).
I do not understand why an output has to be put to high in order to start (start what)?
Line 49 of your code
Why put that pin to low to stop (stop what)?
Line 34 of your code