Jump to content

Monti

Members
  • Gesamte Inhalte

    88
  • Benutzer seit

  • Letzter Besuch

Posts erstellt von Monti

  1. Moin,

    ich versuche gerade folgendes Programm auszuführen:

    program project1;
    
    {$mode objfpc}{$H+}
    
    uses
    
      cthreads,
    
      Classes
      { you can add units after this },
       SysUtils, IPConnection, BrickletLCD20x4,BrickletDistanceIR;
    
    type
      TCMD = class
      private
        ipcon: TIPConnection;
        lcd: TBrickletLCD20x4;
        dr: TBrickletDistanceIR;
      public
        procedure DistanceCB(sender: TBrickletDistanceIR; const distance: word);
        procedure Execute;
      end;
    
    
        const
      HOST = 'localhost';
      PORT = 4223;
      UID = 'disp';
      UIDB = 'dist';
    var
    
       e: TCMD;
    procedure TCMD.DistanceCB(sender: TBrickletDistanceIR; const distance: word);
    begin
      if distance<1240 then begin
      //if (distance<701) and (distance >640) then WriteLn('Tuer Zu');
    
      if (distance<500)and(distance>180) then begin
      lcd.WriteLine(0, 0, inttostr(distance));
      lcd.writeline(1,0,datetimetostr(now));
    
      end;
    WriteLn(inttostr(distance));
    lcd.writeline(3,0,'                       ');
    lcd.WriteLine(3, 0, inttostr(distance));
    end;
    
    end;
    
    procedure TCMD.Execute ;
    begin
       ipcon := TIPConnection.Create;
       lcd := TBrickletLCD20x4.Create(UID, ipcon);
       dr := TBrickletDistanceIR.Create(UIDB, ipcon);
       ipcon.Connect(HOST, PORT);
       dr.SetDistanceCallbackPeriod(150);
       lcd.BacklightOn;
       lcd.ClearDisplay;
      dr.OnDistance := {$ifdef FPC}@{$endif}DistanceCB;
         dr.SetDistanceCallbackThreshold('<', 20*10, 0);
      readln;
      ipcon.Destroy;
    end;
    begin
      e := TCMD.Create;
      e.Execute;
      e.Destroy;
    end.
    
    

     

    Beim ausführen über die Konsole kommt aber:

    
    pi@raspberrypi ~/Desktop/Lazarus/Tuer $ ./project1
    An unhandled exception occurred at $00035650 :
    Exception : Could not resolve host: localhost
      $00035650  TIPCONNECTION__CONNECTUNLOCKED,  line 475 of IPConnection.pas
      $000350FC  TIPCONNECTION__CONNECT,  line 289 of IPConnection.pas
      $0000871C  TCMD__EXECUTE,  line 55 of project1.lpr
      $00008854  main,  line 66 of project1.lpr
    
    

     

    Der Master hängt direkt am Pi, Brickd ist installiert und ich kann mich von einem anderem Computer mit dem Master am Pi verbinden...

     

    Hat wer eine Idee, was da los ist?

     

     

    Monti

     

     

    Ist eventuell wichtig:

    Der Pi hat KEINE Internetverbindung, ich arbeite über statische IPs und einen LAN-Switch...

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

  3. 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) 
    

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

     

×
×
  • Neu erstellen...