krysiu / brewtrolleralpha

Automatically exported from code.google.com/p/brewtrolleralpha
0 stars 0 forks source link

Embedded i2c BTnic Step commands cause crash #70

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This only applies to the commands using the Embedded board, as this is an issue 
with the i2c bus.

The problem affects the Start(U), Advance(S), and Exit(T) step commands. 
Once execCmd() is called:

    1. it is successfully calling the appropriate step function in Step.pde. 
    2. That in turn is successfully calling the eventHandler() function, 
    3. which then calls the uiEvent() function. 
    4. in uiEvent it calls screenInit()
    5. screenInit() is calling LCD.clear()
    6. in LCDI2C::clear() we call i2cLcdClear()
    7. in i2cLcdClear() we are complete the call Wire.send(0x02), but halt on Wire.endTransmission();

The problem is that the i2c bus isn't released until the onRecieve callback 
function completes, so by calling Wire.endTransmission() to init the new 
visible screen, and attempting to flush the Wire buffer to the i2c bus, we get 
a crash. 

This only affects the i2c embedded board as, if we are using USB then the 
command is coming in over Serial, so the onReceive callback never comes into 
play. 

This also only affects the Step commands because they are the only ones where 
the active screen changes and must be init(ed).

See here: 
http://arduino.cc/playground/Main/WireLibraryDetailedReference#onReceive

Original issue reported on code.google.com by ericyan...@gmail.com on 5 Feb 2012 at 3:30