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.

Featured Replies

Geschrieben

Hallo alle zusammen,

ich habe ein kleines Problem beim Auslesen eines neuen IndustrialDigitalIn V2 Bricklets. Nachdem der Callback ausgelöst wurde bekomme ich keine Ergebnisse in den Arrays changed und value obwohl da was sein muss.  :-\

 

Vielleicht sieht jemand den Baum im Wald der Fehler und kann mir einen

kleinen Tipp geben.

 

Vielen Dank im voraus.

 

Anbei der PHP-Code und darunter die Consolen-Ausgabe des var_dumps.

 

<?php

require_once('Tinkerforge/IPConnection.php');
require_once('Tinkerforge/BrickletIndustrialDigitalIn4V2.php');

use Tinkerforge\IPConnection;
use Tinkerforge\BrickletIndustrialDigitalIn4V2;


const HOST = 'localhost';     // Adresse des Hosts
const PORT = 4223;            // Port des Stapels


const INDI_1_2  = 'Gp5';      // Unique ID Industrial digital in V2 1 - 2  Brick 6wTk39 - A


$ipcon = new IPConnection();  // Create IP connection
$ipcon->connect(HOST, PORT);  // Connect to brickd


$indi12 = new BrickletIndustrialDigitalIn4V2(INDI_1_2,$ipcon); // Platz 1 

function cb_interrupt12($changed,$value)
{
var_dump($changed)."\n";
var_dump($value)."\n";
}

  $indi12->registerCallback(BrickletIndustrialDigitalIn4V2::CALLBACK_ALL_VALUE, 'cb_interrupt12');  // CALLBACK einrichten
  $indi12->setAllValueCallbackConfiguration(100,TRUE);
  
  
  $ipcon->dispatchCallbacks(-1);



$ipcon->disconnect();


?>

 

Ausgabe :

 

--------------------> INPUT GEHT AUF TRUE <-------------------------------------------------------------
administrator@bfubsscr1:/opt/scripte/platzbelegtanzeige$ php -f indiV2_test.php

Notice: Undefined index: changed1 in /opt/scripte/platzbelegtanzeige/Tinkerforge/IPConnection.php on line 1388

Notice: Undefined index: value1 in /opt/scripte/platzbelegtanzeige/Tinkerforge/IPConnection.php on line 1388
array(4) {
  [0]=>
  bool(false)
  [1]=>
  bool(false)
  [2]=>
  bool(false)
  [3]=>
  bool(false)
}


--------------------> INPUT GEHT AUF FALSE <-------------------------------------------------------------
array(4) {
  [0]=>
  bool(false)
  [1]=>
  bool(false)
  [2]=>
  bool(false)
  [3]=>
  bool(false)
}

 

Geschrieben

Habs gefunden, das "entpacken" von Bool-Arrays funktionierte nicht wenn das Array in ein einzelnes Byte passt.

 

Hier ist der Fix: https://github.com/Tinkerforge/generators/commit/cd530f5c5fac87a5e6fcd450b3578734a91f1c09

 

Wird dann mit dem nächsten Bindings-Release gefixt. In der Zwischenzeit kannst du aber das diff im Link einfach schonmal auf deine IPConnection.php anwenden, sind nur 3 zusätzliche Zeilen.

Geschrieben
  • Autor

Erst mal herzlichen Dank für die superschnelle Antwort und den Bugfix  :)

 

Nachdem ich die Zeilen in die IPConnection.php eingefügt und die nicht benötigten Zeilen gelöscht habe, bekomme ich jetzt einen runtime - Fehler.

Dieser tritt etwa 3-4 Sekunden nach Programmstart auf.

 

Das Testprogramm ist das Gleiche geblieben. Siehe oben.

 

php -f indiV2_test.php

Fatal error: Uncaught Tinkerforge\TimeoutException: Did not receive response in time for function ID 4 in /opt/scripte/platzbelegtanzeige/Tinkerforge/IPConnection.php:404
Stack trace:
#0 /opt/scripte/platzbelegtanzeige/Tinkerforge/BrickletIndustrialDigitalIn4V2.php(331): Tinkerforge\Device->sendRequest(4, 'd\x00\x00\x00\x01')
#1 /opt/scripte/platzbelegtanzeige/indiV2_test.php(30): Tinkerforge\BrickletIndustrialDigitalIn4V2->setAllValueCallbackConfiguration(100, true)
#2 {main}
  thrown in /opt/scripte/platzbelegtanzeige/Tinkerforge/IPConnection.php on line 404

Geschrieben
  • Autor

hahaha ...,

 

sooorry, hatte ganz vergessen die IP-Adresse von localhost wieder auf die tatsächliche zu korrigieren.

 

Sorry nochmal, eigener Fehler  ;D

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.