Jump to content

Recommended Posts

Posted

Hallo,

 

es gelingt mir nicht den Port eines IO16 abzufragen. Ich erhalte jedes Mal als Ergebnis "undefined". Das IO16 wird korrekt erkannt und ich kann es konfigurieren und schalten, nur eben nicht lesen.

 

if (deviceIdentifier == Tinkerforge.BrickletIO16.DEVICE_IDENTIFIER) {
  debug("Found IO16 with UID:" + uid);
  io16 = new Tinkerforge.BrickletIO16(uid, ipcon); // Create device object
  // Alle Pins an Port B auf Ausgang setzen (ausgeschaltet)
  io16.setPortConfiguration('b', 255, 'o', false);
  io16.setPort('b', 1);

  pins = io16.getPort('b');
  alert(pins); // bringt undefined"
}

 

Ich hoffe ihr könnt mir helfen :)

 

Gruß

gus484

Posted

Getter in den JavaScript Bindings sind async. Du musst getPort so aufrufen:

 

// Get current value from port A as bitmask
io.getPort('a',
function (valueMask) {
	alert('Value Mask (Port A): ' + valueMask.toString(2));
},
function (error) {
	alert('Error: ' + error);
}
);

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