@@ -54,9 +54,9 @@ uint8_t err =Wire.endTransmission(false); // don't send a STOP, just Pause I2C o
54
54
if(err==7){ // Prior Operation has been queued, it is NOT guaranteed that it will
55
55
// successfully occur!
56
56
err=Wire.requestFrom(addr,len);
57
- if(err!=len ){ // complete/partial read failure
58
- Serial.print ("Bad Stuff!! Read Failed lastError=");
59
- Serial.print( Wire.lastError(),DEC );
57
+ if(Wire.lastError()!=0 ){ // complete/partial read failure
58
+ Serial.printf ("Bad Stuff!!\nRead of (%d) bytes read %d bytes\nFailed lastError=%d,"
59
+ " text=%s\n",len,err,Wire.lastError(), Wire.getErrorText(Wire. lastError()) );
60
60
}
61
61
// some of the read may have executed
62
62
while(Wire.avaiable()){
@@ -70,13 +70,8 @@ Additionally I have expanded the ability of `Wire()` to handle larger Reads and
70
70
71
71
I have create a few new methods for Wire:
72
72
``` c++
73
- uint8_t oldEndTransmission (uint8_t); //released implementation
74
- size_t oldRequestFrom(uint8_t address, size_t size, bool sendStop); //released implementation
75
- //@stickBreaker for big blocks and ISR model
76
73
uint8_t writeTransaction (uint8_t address, uint8_t* buff, size_t size, bool sendStop);// big block handling
77
- size_t requestFrom(uint8_t address, size_t size, bool sendStop);
78
74
size_t requestFrom(uint8_t address, uint8_t* buf, size_t size, bool sendStop);
79
- size_t polledRequestFrom(uint8_t address, uint8_t* buf, size_t size, bool sendStop);//a BigBlock test case Not USING ISR
80
75
size_t transact(size_t readLen); // replacement for endTransmission(false),requestFrom(ID,readLen,true);
81
76
size_t transact(uint8_t* readBuff, size_t readLen);// bigger Block read
82
77
i2c_err_t lastError(); // Expose complete error
@@ -91,10 +86,9 @@ Wire.beginTransmission(ID);
91
86
Wire.write(highByte(addr));
92
87
Wire.write(lowByte(addr));
93
88
94
- uint8_t err=Wire.transact(len);
95
- if(err!=len){ // complete/partial read failure
96
- Serial.print("Bad Stuff!! Read Failed lastError=");
97
- Serial.print(Wire.lastError(),DEC);
89
+ uint8_t err=Wire.transact(len); // transact() does both Wire.endTransmission(false); and Wire.requestFrom(ID,len,true);
90
+ if(Wire.lastError != 0){ // complete/partial read failure
91
+ Serial.printf("Bad Stuff!! Read Failed lastError=%d\n",Wire.lastError());
98
92
}
99
93
// some of the read may have executed
100
94
while(Wire.avaiable()){
@@ -110,5 +104,4 @@ Set the "core debug level" to 'error'
110
104
There is MINIMAL to NO ERROR detection, BUS, BUSY. because I have not encounter any of them!
111
105
112
106
113
-
114
107
Chuck.
0 commit comments