Jump to content

[Raspberry Pi] [Lazarus] Exception : Could not resolve host: localhost


Monti

Recommended Posts

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

Link to comment
Share on other sites

Kurze Frage dazu:

und ich kann mich von einem anderem Computer mit dem Master am Pi verbinden...

D. h. über die externe IP des RasPI lässt sich der brickd ansprechen, von localhost aber nicht - korrekt?

 

- Steht der localhost in der /etc/hosts des PI?

- Ist das loopback-device gestartet?

 

Der Befehl ifconfig müsste u.a. sowas ausgeben:

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...