Hello Richard,
Thank you very much for getting back to me. I appreciate the "using TwoWire = I2CDriverWire;" hint! I'd managed to go in and replace all TwoWire with I2CDriverWire, which gives the same result.
Somehow, strangely, the code in EasyTransfer.h is:
1) Calling Wire1 and Wire2 even though I never do in the code
2)Trying to reinitialize
3) Saying that there are multiple versions of i2c_driver.h - even though there are not (checking full trees under both the program libraries and documents libraries folders).
4) The error below points at the EasyTransfe::receiveData member - I'll dig into that more later as commenting and breaking things gives me other errors
The output (same as when I swapped s/TwoWire/I2CDriverWire manually):
Code:
C:\Users\A\AppData\Local\Temp\arduino_build_633885\libraries\EasyTransferI2C\EasyTransferI2C.cpp.o:(.bss.Wire2+0x0): multiple definition of `Wire2'
C:\Users\A\AppData\Local\Temp\arduino_build_633885\sketch\i2c_EasyTransfer_Practice-master.ino.cpp.o:(.bss.Wire2+0x0): first defined here
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
C:\Users\A\AppData\Local\Temp\arduino_build_633885\libraries\EasyTransferI2C\EasyTransferI2C.cpp.o: In function `Print::flush()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\EasyTransferI2C/EasyTransferI2C.cpp:45: multiple definition of `Wire1'
C:\Users\A\AppData\Local\Temp\arduino_build_633885\sketch\i2c_EasyTransfer_Practice-master.ino.cpp.o:C:\Users\A\Documents\Arduino\Freeform\i2c_EasyTransfer_Practice-master/i2c_EasyTransfer_Practice-master.ino:71: first defined here
C:\Users\A\AppData\Local\Temp\arduino_build_633885\libraries\EasyTransferI2C\EasyTransferI2C.cpp.o: In function `Print::flush()':
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\EasyTransferI2C/EasyTransferI2C.cpp:45: multiple definition of `Wire'
C:\Users\A\AppData\Local\Temp\arduino_build_633885\sketch\i2c_EasyTransfer_Practice-master.ino.cpp.o:C:\Users\A\Documents\Arduino\Freeform\i2c_EasyTransfer_Practice-master/i2c_EasyTransfer_Practice-master.ino:71: first defined here
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for "EasyTransferI2C.h"
Used: C:\Program
Not used: C:\Users\A\Documents\Arduino\libraries\_EasyTransferI2C
Multiple libraries were found for "i2c_driver.h"
Used: C:\Users\A\Documents\Arduino\libraries\teensy4_i2c-master
Error compiling for board Teensy 4.0.
Test Code. You can see I've even commented out any use of EasyTransfer. Just calling the .h does something:
Code:
#define myI2CAddress 22 // Set to 0 to be chosen by code once the tile has been connected
// #define mySerialNumber 12345 // Currently used to verify whether tile has been connected (use address if maintains state)
#define I2C_SLAVE_ADDRESS 0
char myDesignationLetter = 'A'; // This is the letter Tile 'A'
byte myNeighbors[4]; // set up container for addresses, starting at top and going clockwise
byte myConnection; // The tile to which this tile is connected
//#include <Wire.h>
#include <i2c_driver.h>
#include <i2c_driver_wire.h>
using TwoWire = I2CDriverWire;
#include <EasyTransferI2C.h>
//create object
//EasyTransferI2C ET;
//EasyTransferI2C ET2;
struct SEND_DATA_STRUCTURE{
//put your variable definitions here for the data you want to send
//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
byte I2CAddress;
char designation;
byte connectedSide;
byte playerNumber;
};
struct RETURN_DATA {
char designation;
byte result;
};
//give a name to the group of data
SEND_DATA_STRUCTURE dataToSend;
SEND_DATA_STRUCTURE returnData;
//RETURN_DATA returnData;
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
//ET.begin(details(dataToSend), &Wire); //start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
// ET2.begin(details(returnData), &Wire);
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600);// Start serial for diagnostic output
Serial.println("Plug in now.");
delay(3000);
}
byte x = 0;
void loop() {
}
void receiveEvent(int numBytes) {}
I'm going to spend a bit more time poking around in hopes I can help others some day. If that doesn't work, I'm just going to have to cascade a serial port off of the Teensy to a Nano and figure out EasyTransfer on that side to maintain the computing and memory requirements.
My only question is whether
Code:
I2CDriverWire Wire(Master, Slave);
behaves differently because of its constructor than
which doesn't have the following calls in the brackets. I'm wondering if there is some bitwise operation which is expecting a single argument and is getting 3(Which I also can't find when searching by case. But I believe in magic so...)
Thanks again!
PS. For kicks and because I'm learning what I'm doing here one line at a time, what can otherse see in this??
Code:
boolean EasyTransferI2C::receiveData(){
//start off by looking for the header bytes. If they were already found in a previous call, skip it.
if(rx_len == 0){
//this size check may be redundant due to the size check below, but for now I'll leave it the way it is.
if(_serial->available() >= 3){
//this will block until a 0x06 is found or buffer size becomes less then 3.
#if ARDUINO >= 100
while(_serial->read() != 0x06) {
#else
while(_serial->receive() != 0x06) {
#endif
//This will trash any preamble junk in the serial buffer
//but we need to make sure there is enough in the buffer to process while we trash the rest
//if the buffer becomes too empty, we will escape and try again on the next call
if(_serial->available() < 3)
return false;
}
#if ARDUINO >= 100
if (_serial->read() == 0x85){
rx_len = _serial->read();
#else
if (_serial->receive() == 0x85){
rx_len = _serial->receive();
#endif
//make sure the binary structs on both Arduinos are the same size.
if(rx_len != size){
rx_len = 0;
return false;
}
}
}
}
//we get here if we already found the header bytes, the struct size matched what we know, and now we are byte aligned.
if(rx_len != 0){
while(_serial->available() && rx_array_inx <= rx_len){
#if ARDUINO >= 100
rx_buffer[rx_array_inx++] = _serial->read();
#else
rx_buffer[rx_array_inx++] = _serial->receive();
#endif
}
if(rx_len == (rx_array_inx-1)){
//seem to have got whole message
//last uint8_t is CS
calc_CS = rx_len;
for (int i = 0; i<rx_len; i++){
calc_CS^=rx_buffer[i];
}
if(calc_CS == rx_buffer[rx_array_inx-1]){//CS good
memcpy(address,rx_buffer,size);
rx_len = 0;
rx_array_inx = 0;
return true;
}
else{
//failed checksum, need to clear this out anyway
rx_len = 0;
rx_array_inx = 0;
return false;
}
}
}
return false;
}