Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Geschrieben

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

Geschrieben
  • Autor

Jop, die IP im Netzwerk hab ich auch schon getestet...

 

Geschrieben

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

Geschrieben
  • Autor

Zur externen IP: Ich kann von einem PC (nicht der Pi) mich per Brickv mit dem am Pi angeschlossenen Brick verbinden.

 

Zur hosts Datei:localhost verweist auf 127.0.0.1, also alles in Ordnung.

 

Und bei ifconfig stimmt auch alles...

Geschrieben
  • Autor

*Haut Kopf gegen die Wand*

Mir fällt grad ein: Ich hab nicht die neuesten Bindings benutzt...

Da hatten ja auch schon Andere Probleme unter Linux...

Das könnte es sein, oder? (Testen mach ich morgen)

Geschrieben
  • Autor

Hab grad die Bindings aktualisiert: Jetzt geht alles...

 

 

Join the conversation

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

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.