Geschrieben October 14, 2014 at 20:2514. Okt 2014 Hi Folgendes simple node.js Programm: var TF = require('tinkerforge'); var HOST = 'myhost'; var PORT = 4223; var ipcon = new TF.IPConnection(); var masterBrick = new TF.BrickMaster('6esCZX', ipcon); var tempBricklet = new TF.BrickletTemperature('dCf', ipcon); var distUSBricklet = new TF.BrickletDistanceUS('nY3', ipcon); ipcon.connect(HOST, PORT, function(error) { console.log("Could not open connection: "+error); }); ipcon.on(TF.IPConnection.CALLBACK_CONNECTED, function(connectReason) { // Configure Bricklets masterBrick.setWifiPowerMode(TF.BrickMaster.WIFI_POWER_MODE_LOW_POWER); tempBricklet.setI2CMode(TF.BrickletTemperature.I2C_MODE_SLOW); // to prevent outlier tempBricklet.setTemperatureCallbackPeriod(5000); distUSBricklet.setMovingAverage(100); distUSBricklet.setDistanceCallbackPeriod(5000); }); tempBricklet.on(TF.BrickletTemperature.CALLBACK_TEMPERATURE, function(temp){ console.log('Temperature: '+temp/100); }); distUSBricklet.on(TF.BrickletDistanceUS.CALLBACK_DISTANCE, function(distance) { console.log('Distance: '+distance); }); Alle 5 Sekunden wird Temperatur und US Distanz angegeben. Starte ich nun den Brickv und gehe auf das DistanceUS Brickelt, dann sehe ich in meinem Node.js Program sehr viele und schnell hintereinander folgende Ausgaben: Temperature: 11.37 Temperature: 11.31 Distance: 1234 Temperature: 11.37 Distance: 1233 Distance: 1234 Distance: 1233 Distance: 1234 Distance: 1233 Distance: 1232 Distance: 1231 Distance: 1232 Distance: 1231 Distance: 1232 Distance: 1231 Distance: 1232 Distance: 1233 Distance: 1232 Distance: 1233 Distance: 1232 Distance: 1231 Distance: 1232 Distance: 1231 Distance: 1232 Distance: 1231 Distance: 1232 Warum beeinflusst der Bickv mein node Script? Es sollten doch unterschiedliche IPConnectios sein ?
Geschrieben October 15, 2014 at 07:5615. Okt 2014 Warum beeinflusst der Bickv mein node Script? Es sollten doch unterschiedliche IPConnectios sein ? Callbacks werden nicht per IP Connection eingestellt, sondern die Callback Einstellungen sind auf dem Brick(let)s und somit global über alle IP Connections hinweg. Daher können sich zwei Programme die die gleichen Callbacks nutzen in die quere kommen.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.