joepasquariello
Well-known member
Okay, that helps. First, as far as I know, you are the first to try to do this over I2C. If you look at the original FlasherX.ino sketch, you'll see that update_firmware gets called once and only once. If it returns to loop(), an error has occurred, and the Teensy will call REBOOT. Within update_firmware(), there is a loop that reads records from the specified serial stream, processing all records until an EOF is found. That loop calls read_ascii_line(), which reads from the specified stream until a newline is found. You need to replace read_ascii_line with a function that does the same thing, but reads from I2C rather than from the Serial stream. If you do that, you won't have to touch any of the other code. @jonr has suggested that the right way to do this is to implement a stream class for I2C, so the same code works for any stream, whether it be I2C, Serial, SPI, etc. For the time being, though, I suggest that you start with FlasherX.ino and try to modify read_ascii_line() to read records from I2C rather than a Serial stream.