Jump to content

[Raspberry Pi] [Lazarus] Beim Ausführen RunError(211)


Recommended Posts

Moin,

ich hab mir heute auf meinem Pi Lazarus installiert. Hab dazu folgende Befehle benutzt:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fpc
sudo apt-get install lazarus

Hat dann auch alles einwandfrei funktioniert.

Nachdem ich dann wie in der Doku beschrieben Brickd und Brickv inbstalliert hatte, ging nichts mehr.

Selbst ein "leeres" Programm gibt nur den Fehler:

Project project1 raised exception class 'RunError(211)'.

 

Hat wer eine Idee, was ich da tun kann?

 

Monti

 

Link zu diesem Kommentar
Share on other sites

Folgende Fehlermeldung bei der Konsole:

pi@raspberry ~/Desktop/Lazarus/TestfuerTF $ ./project1
Threading has been used before cthreads was inizialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $0003A1BC
$0003A1BC
$B6DAC81C

cthreads ist aber die erste Unit in den Uses.

Link zu diesem Kommentar
Share on other sites

Hab ich gdb richtig benutzt?

pi@raspberrypi ~/Desktop/Lazarus/Test fuer TF $ gdb project1
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/pi/Desktop/Lazarus/Test fuer TF/project1...done.
(gdb) run
Starting program: /home/pi/Desktop/Lazarus/Test fuer TF/project1 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $0003A18C
  $0003A18C
  $B6E8081C

[inferior 1 (process 2277) exited with code 0323]
(gdb) 

Link zu diesem Kommentar
Share on other sites

Hab ich gdb richtig benutzt?

 

Ja, das Problem ist leider, dass GDB das Programm beim RunError nicht angehalten hat. Ich habe mir auch gerade mal den Code der cthreads Unit angesehen und es hätte nichts geholfen, da an dieser nicht mehr ersichtlich ist was da zu früh aufgerufen wurde. Sorry, für den nutzlosen Vorschlag mit GDB.

 

Ich habe gerade Lazarus auf einem Raspberry Pi (mit aktuellem Raspbian, brickd und brickv) installiert und kann das Problem nicht nachstellen.

 

Meine project1.lpr Datei sieht so aus:

 

program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, Unit1
  { you can add units after this };

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

 

Wenn jetzt aus irgendwelchen Gründen UseCThreads nicht definiert ist dann ist cthreads nicht die erste Unit, sondern Interfaces.

 

Wenn das bei dir auch so aussieht, dann teste doch mal ob es hilft, die IFDEFs um cthreads zu entfernen, damit dass dann so aussieht:

 

program project1;

{$mode objfpc}{$H+}

uses
  cthreads,
  Interfaces, // this includes the LCL widgetset
  Forms, Unit1
  { you can add units after this };

[...]

Link zu diesem Kommentar
Share on other sites

Hmm, dann tritt das Problem nur bei mir auf...

@photron: Hast du Lazarus und fpc per apt-get installiert?

 

Aber egal...

 

 

Ich hab jetzt folgenden Programmcode:

 

program project1;

{$mode objfpc}{$H+}

uses

  cthreads,

  Classes
  { you can add units after this }, IPConnection, BrickletLCD20x4,sysutils;

         type
  TExample = class
  private
    ipcon: TIPConnection;
    lcd: TBrickletLCD20x4;
  public
    procedure PressedCB(sender: TBrickletLCD20x4; const i: byte);
    procedure ReleasedCB(sender: TBrickletLCD20x4; const i: byte);
    procedure Execute;
  end;

const
  HOST = 'localhost';
  PORT = 4223;
  UID = 'disp'; { Change to your UID }

var
  e: TExample;
{$R *.res}

{ Callback functions for button status }
procedure TExample.PressedCB(sender: TBrickletLCD20x4; const i: byte);
begin
  WriteLn(Format('Pressed: %d', [i]));
end;

procedure TExample.ReleasedCB(sender: TBrickletLCD20x4; const i: byte);
begin
  WriteLn(Format('Released: %d', [i]));
end;

procedure TExample.Execute;
begin
  { Create IP connection }
  ipcon := TIPConnection.Create;

  { Create device object }
  lcd := TBrickletLCD20x4.Create(UID, ipcon);

  { Connect to brickd }
  ipcon.Connect(HOST, PORT);
  { Don't use device before ipcon is connected }

  { Register button status callbacks to procedure PressedCB and ReleasedCB }
  lcd.OnButtonPressed := {$ifdef FPC}@{$endif}PressedCB;
  lcd.OnButtonReleased := {$ifdef FPC}@{$endif}ReleasedCB;

  WriteLn('Press key to exit');
  ReadLn;
  ipcon.Destroy; { Calls ipcon.Disconnect internally }
end;

begin
  e := TExample.Create;
  e.Execute;
  e.Destroy;
end.

 

Ergebnis:

pi@raspberrypi ~/Desktop $ cd Lazarus
pi@raspberrypi ~/Desktop/Lazarus $ cd Test\ fuer\ TF
pi@raspberrypi ~/Desktop/Lazarus/Test fuer TF $ ./project1
Press key to exit
Pressed: 0
Released: 0
Pressed: 1
Released: 1

pi@raspberrypi ~/Desktop/Lazarus/Test fuer TF $ 

 

Also: ALLES FUNKTIONIERT!!!

 

DANKE

Link zu diesem Kommentar
Share on other sites

Gast
This topic is now closed to further replies.
×
×
  • Neu erstellen...