Jump to content

Mein Anfang war leicht, aber jetzt


Tippel
 Share

Recommended Posts

Hallo,

 

mein Anfang war sehr erfolgreich. Ausgepackt, angeschlossen, Brickd und Brickv installiert. Alles wunderbar.

 

brickviewer.jpg

 

Aber jetzt will ich über WAMP zugreifen und das geht nicht.

 

<?php
echo "Test 1<br>";
require_once('../../../source/Tinkerforge/IPConnection.php');
require_once('../../../source/Tinkerforge/BrickMaster.php');
echo "Test 2<br>";

use Tinkerforge\IPConnection;
use Tinkerforge\BrickMaster;
echo "Test 3<br>";

$host = 'localhost';
$port = 4223;

$uid = '94wpecnBBF8'; // Change to your UID
#$uid = 'ayNfRV5u9Vg'; // Change to your UID
echo "Test 4 $host $port $uid<br>";

$ipcon = new IPConnection($host, $port); // Create IP connection to brickd
echo "Test 5.1<br>";
$master = new BrickMaster($uid); // Create device object
echo "Test 5.2<br>";

$ipcon->addDevice($master); // Add device to IP connection
// Don't use device before it is added to a connection
echo "Test 6<br>";

// Get voltage and current from stack (in mV/mA)
$voltage = $master->getStackVoltage();
$current = $master->getStackCurrent();
echo "Test 7<br>";

echo "Stack Voltage: " . $voltage / 1000.0 . " V\n";
echo "Stack Current: " . $current / 1000.0 . " A\n";
echo "Test 8<br>";

echo "Press key to exit\n";
fgetc(fopen('php://stdin', 'r'));
$ipcon->destroy();

?>

 

php1.jpg

 

Leider baut er die Verbindung nicht auf. Was mache ich falsch?

 

Danke

Tippel

Link to comment
Share on other sites

Lässt du dir Fehler anzeigen? Normalerweise wirft der Konstruktor der IPConnection Exceptions wenn was schiefgeht, das müsstest du sehen wenn dein PHP Fehlermeldungen ausgibt.

 

Zu Fuß gehts aber auch:

Frei nach w3schools:

try
{
  $ipcon = new IPConnection($host, $port);
}
catch(Exception $e)
{
  echo 'Message: ' .$e->getMessage();
}

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.

 Share

×
×
  • Create New...