Recent

Author Topic: Help please with getting Lazwiringpi working.  (Read 16512 times)

metal mark

  • New Member
  • *
  • Posts: 38
Help please with getting Lazwiringpi working.
« on: December 14, 2012, 03:00:13 am »
Hi , a little help with getting wiringpi going on Lazarus would be most appreciated.
I downloaded lazwiringpi and decompressed it. It made a directory lazwiringpi. In which was hwiring.pas, raspberry.lpi, raspberry.lpr, readme.txt and a directory wiringPi.
In wirng Pi is COPYING, libwiringPi, Makefile, README, wiringPi.c, wiringPi.h and wiringPi.o.
When I put at the top of my program in Lazarus under Classes to use hwiringpi and recompile it , I get back the warning "cant find unit hwiringpi used by xxxxx".
What does this mean. Have I got something in the wrong place and if so what ?
Thanks for looking.

geno

  • Full Member
  • ***
  • Posts: 198
Re: Help please with getting Lazwiringpi working.
« Reply #1 on: December 14, 2012, 03:51:32 am »
Did you  recompile the library by executing
Code: [Select]
gcc -c wiringPi.c.
 according to the instructions in the readme.txt file?

regards,
  geno
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

metal mark

  • New Member
  • *
  • Posts: 38
Re: Help please with getting Lazwiringpi working.
« Reply #2 on: December 14, 2012, 04:23:58 am »
Hi Geno,
I tried that but it failed, I just tried it again and it failed again it said "incompatible implicit declaration of built in function 'malloc' [enabled by default]". Any suggestions !
Thanks MM
« Last Edit: December 14, 2012, 05:50:36 am by metal mark »

geno

  • Full Member
  • ***
  • Posts: 198
Re: Help please with getting Lazwiringpi working.
« Reply #3 on: December 14, 2012, 06:11:07 am »
Are you attempting this on your RPi, or your desktop?  I just only did this after reading your first post on my desktop system, so don't know if I will have different results on my RPi.

 After extracting the files, I moved into the lazwiringpi/wiringPi directory and executed the make command
Code: [Select]
[geno@geno wiringPi]$ make
I don't know if this is important, but it does build the lazwiringPi.a file.  Then I hit it with the
Code: [Select]
gcc -c wiringPi.c.
In Lazarus, Project -> Open Project =>  lazwiringpi/raspberrypi.lpi which also opens hwiringpi.pas.  I made hwiringpi.pas the active code page, and went to the menu Run -> Build File; after successful build, switched back to raspberrypi.lpi code page and did menu Run -> Compile.

So there - should be as easy as ..... Pi ;D

  regards,
     geno
« Last Edit: December 14, 2012, 07:02:20 am by geno »
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Help please with getting Lazwiringpi working.
« Reply #4 on: December 14, 2012, 07:31:15 am »
Quote
When I put at the top of my program in Lazarus under Classes to use hwiringpi and recompile it , I get back the warning "cant find unit hwiringpi used by xxxxx".
What does this mean. Have I got something in the wrong place and if so what ?
You didn't tell the compiler where to look for the unit (-Fu).
Quote
I tried that but it failed, I just tried it again and it failed again it said "incompatible implicit declaration of built in function 'malloc' [enabled by default]". Any suggestions !
Of course it won't magically work just by retrying, there's something wrong there and which you may have to fix. gcc for linux seems to be stricter than for windows, check whether the .c (or any #include-ed .h) has
Code: [Select]
#include <stdlib.h>line.
Quote
I don't know if this is important, but it does build the lazwiringPi.a file.  Then I hit it with the
if you already execute make, then I guess you don't need to execute gcc -c (compile only, producing a.out from .c if no other options affect) anymore, it's supposed to be one of the things that the makefile does.

geno

  • Full Member
  • ***
  • Posts: 198
Re: Help please with getting Lazwiringpi working.
« Reply #5 on: December 14, 2012, 04:31:19 pm »
Quote
if you already execute make, then I guess you don't need to execute gcc -c (compile only, producing a.out from .c if no other options affect) anymore, it's supposed to be one of the things that the makefile does.
Of course, you are right as always...  I went back and started over and found that executing make is not necessary, just do the   gcc -c wiringPi.c

@metal mark
I received the same warnings when executing gcc as well as
Quote
warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
but it did not stop the program from compiling in lazarus.  Of course the resulting program will not execute on my desktop, so in a little while I will pull out the RPi and try it again.

good luck
  geno
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

metal mark

  • New Member
  • *
  • Posts: 38
Re: Help please with getting Lazwiringpi working.
« Reply #6 on: December 14, 2012, 07:00:16 pm »
Thank you for the advice. I was doing all this on my RPi during my breaks at work last night. I tried doing the compile of wiringPi at the command line in the ways suggested but it did not seem to make any difference, it still showed warnings. So I tried compiling what it gave in Lazarus i.e hwiringpi and raspberry.lpr. These seemed to compile ok and now when I compile my project with hwiringpi in the uses/Classes it no longer whines and looks to compile successfully. If I get time tonight I will try out adding gpio calls to my code.
This is a very steep learning curve as it is all new to me.
Many thanks for your help.
Thanks MM
« Last Edit: December 14, 2012, 11:38:34 pm by metal mark »

picstart

  • Full Member
  • ***
  • Posts: 236
Re: Help please with getting Lazwiringpi working solved
« Reply #7 on: December 15, 2012, 12:05:53 am »
Ok I gave running lazarus a shot on a raspberry pi Rev B (512K)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fpc
 ///// ok so far but with the file complexity of linux and lazarus  usually if it can go wrong it already has
////   in this case /var/cache/apt/archives ran out of space
///   ok a solution could be using sudo apt-get clean
///   alright there might be enough space after the clean
sudo apt-get install lazarus
//// If it can go wrong it did
cannot copy extracted data
/usr/lib/lazarus/0.9.30.4/lcl/units/arm-linux/extctrls.o
Now this install runs slower than a melting glacier so don't attempt this unless you have several hours of spare time.
Maybe running the lazarus IDE on a raspberry pi is a bridge too far. If anyone has it working it would be good to hear from you.

Solution
I was using a win7 pro 64 so win32Imagemanager was needed to create the partitions and provide a small FAT file system so install config files can be edited. I had a DVI monitor with a DVI to HDMI dongle.
The config .txt file needed tweaking
uncomment ( remove # )  for the the following
   disable_overscan=1
   hdmi_force_hotplug=1
   config_hdmi_boost=4
The pi will switch immediately to composite video is it suspects the HDMI connection.

This was a win32 image manager free feature....it created a 2gb partition on a 16gb sdhc...this and the fact that apt-get install fpc is messed up ( needed apt-get update and then re-applying apt-get install fpc
to fix it) created the opportunity for the unexpected.
The size of the raspberry img file correlates to the size of the partition win32 image manager will create
the raspberry img from the web is 2db ( I suspect 2gb is never large enough to install lazarus)
 After I expanded the partition with Paragon Disk Manager and after logging in
 startx
and entering the following commands using LXTerminal
 sudo apt-get install fpc
 sudo apt-get update
 sudo apt-get install fpc
sudo apt-get install lazarus

lazarus showed up in the files>>applications

« Last Edit: December 17, 2012, 10:00:08 pm by picstart »

geno

  • Full Member
  • ***
  • Posts: 198
Re: Help please with getting Lazwiringpi working.
« Reply #8 on: December 15, 2012, 12:42:39 am »
I am running Rasbian on a Rev A (256K).  Lazarus ver 0.9.30.4-1.1 w/FPC 2.6.  Yes, it is slow, but only during compiles, which are very processor intense.  Heck, I have had worse over the years!!

  I try to remember not to Run [F9] the project within the ide, because it usually throws an exception, but the few test projects I have done will execute from the command line as they should.

  regards,
      geno

edit 1:  I am also running the RPi from my desktop with ssh and lxsession over wireless, so that may account for some of the perceived slowness for me.  I seem to remember it being a little more responsive when I connected to a screen w/HDMI, but that was a few months ago.
« Last Edit: December 15, 2012, 12:48:03 am by geno »
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

metal mark

  • New Member
  • *
  • Posts: 38
Re: Help please with getting Lazwiringpi working.
« Reply #9 on: December 15, 2012, 05:48:11 am »
Oops  :-[ sorry, when I said it compiled ok I was wrong, I compiled the wrong program and didnt notice, doah.
When I tried to compile my program it whinged with :-
"experimental_project_ver1.pas(9,13) Fatal Cant find unit hwiringpi used in experimental_proj_ver1". So I suppose I have to tell it the path to hwiringpi, not sure how to do that, some advice would be most appreciated.
Thanks, MM

geno

  • Full Member
  • ***
  • Posts: 198
Re: Help please with getting Lazwiringpi working.
« Reply #10 on: December 15, 2012, 06:44:24 am »
insert the relative path to the folder containing hwiringpi.pas  into
Project -> Project Options -> Paths -> Other Unit Files (-Fu)
eg:   ../lazwiringpi

  regards, geno
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

metal mark

  • New Member
  • *
  • Posts: 38
Re: Help please with getting Lazwiringpi working.
« Reply #11 on: December 15, 2012, 07:10:29 am »
Thanks Geno, I put in /home/pi/lazwiringpi and my program complied without the "cant find" whinge. It only mentioned that I had not used it yet. No chance to test it before I go home to bed though, but thanks very much for your help.
Regards MM :D

geno

  • Full Member
  • ***
  • Posts: 198
Re: Help please with getting Lazwiringpi working.
« Reply #12 on: December 15, 2012, 03:44:30 pm »
I'm glad I could be of some help.  :) Good luck with your project!

  regards,
     geno
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

metal mark

  • New Member
  • *
  • Posts: 38
Re: Help please with getting Lazwiringpi working.
« Reply #13 on: December 16, 2012, 01:50:47 pm »
Sorry to be a pest but still having problems. My program compiles ok but when it runs and gets to the statement "pinMode(P7,OUTPUT)" it crashes and gives the warning :-
 "Exception class EXTERNAL:SIGSEGV".
 If I click on ok for that it takes me to the assembler code for pinMode(268) !! Any suggestions would be greatfully accepted  %).
Thanks MM
« Last Edit: December 16, 2012, 02:27:17 pm by metal mark »

geno

  • Full Member
  • ***
  • Posts: 198
Re: Help please with getting Lazwiringpi working.
« Reply #14 on: December 16, 2012, 04:21:58 pm »
Can you post your code?
version:      Lazarus 1.9   FPC 3.0.4
   
widget set:  x-86_64-linux-gtk 2
OS:             ArchLinux/ Xfce 4.12

 

TinyPortal © 2005-2018