title: Arduino I2C Wire master available read outputs -1 255 if slave sends less bytes
body: <p>i tried this example:
  <a href="http://arduino.cc/en/Reference/WireRead" rel="nofollow">http://arduino.cc/en/Reference/WireRead</a></p>
  
  <p>But if i send less than 6 bytes from the slave the master still tries to read all 6 bytes and then the read function outputs -1/255. So actually the available function is kinda useless in this case, i could rather use a for till 6.</p>
  
  <p>Any idea what i am doing wrong or how i can solve this? I cannot simply just filter all 255 values because sometimes i send them. I just dont understand the library behaviour here.</p>
  
  <p>Edit: The weird thing is the read function returns an int, not a byte. So i can see if its -1 or 255. And its definitly 255 instead of -1. If i try to read 7 times instead of using the available function the last reading then is -1. Does the slave send wrong bytes or do i maybe need a pullup or whats going on here?</p>
  
  <p>My solution is to read until read is -1 instead of using the available function. But there must be another solution.</p>