aboutsummaryrefslogtreecommitdiff
path: root/libraries/Wire/src/utility/twi.c
diff options
context:
space:
mode:
authorkellerkindt <michael.watzko@web.de>2016-06-05 03:01:57 +0200
committerkellerkindt <michael.watzko@web.de>2016-06-05 03:01:57 +0200
commit43d5e073b440e3812e20c9a941a06ad81dffbfc1 (patch)
tree6621c76b3080e6c3da883bfeb047b29dec57e911 /libraries/Wire/src/utility/twi.c
parentcc4ddc358716f9a73205aed4e7726e0cd156b500 (diff)
Fix buffer being overwritten by multiple twi_transmit calls
Fixes that more complex methods (like Stream::print(float)) do not work properly. Without this fix, Wire.print(1.01f); results in '1' because Print::printFloat(double, uint8_t) performs multiple print() and therefore twi_transmit calls. Also Wire.println("Heyho"); results only in a newline character.
Diffstat (limited to 'libraries/Wire/src/utility/twi.c')
-rw-r--r--libraries/Wire/src/utility/twi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libraries/Wire/src/utility/twi.c b/libraries/Wire/src/utility/twi.c
index f5d7d5b..171af73 100644
--- a/libraries/Wire/src/utility/twi.c
+++ b/libraries/Wire/src/utility/twi.c
@@ -304,7 +304,7 @@ uint8_t twi_transmit(const uint8_t* data, uint8_t length)
uint8_t i;
// ensure data will fit into buffer
- if(TWI_BUFFER_LENGTH < length){
+ if(TWI_BUFFER_LENGTH < (twi_txBufferLength+length)){
return 1;
}
@@ -314,10 +314,10 @@ uint8_t twi_transmit(const uint8_t* data, uint8_t length)
}
// set length and copy data into tx buffer
- twi_txBufferLength = length;
for(i = 0; i < length; ++i){
- twi_txBuffer[i] = data[i];
+ twi_txBuffer[twi_txBufferLength+i] = data[i];
}
+ twi_txBufferLength += length;
return 0;
}