From: Shigeru K. <kot...@ya...> - 2009-07-25 13:47:51
|
Dear all, I'm sorry if this is a false alarm, but I want report here to make sure. In setPinModeCallback() function of StandardFirmata (r23), reportAnalogCallback() function is called for ALL types. This might be a problem, since if the specified mode is INPUT and the pin number is under 13, the first argument for reportAnalogCallback() will be out of range. void setPinModeCallback(byte pin, int mode) { ... if(pin > 1) { // ignore RxTx (pins 0 and 1) reportAnalogCallback(pin - 14, mode == ANALOG ? 1 : 0); // turn on/off reporting switch(mode) { case ANALOG: digitalWrite(pin, LOW); // disable internal pull-ups and fall thru to 'case INPUT:' case INPUT: ... Additionally, setPinModeCallback() is also called in reportAnalogCallback() as follows. This should be a problem. void reportAnalogCallback(byte pin, int value) { if(value == 0) { analogInputsToReport = analogInputsToReport &~ (1 << pin); } else { // everything but 0 enables reporting of that pin analogInputsToReport = analogInputsToReport | (1 << pin); setPinModeCallback(pin, ANALOG); ... My suggestion is removing the following line (i.e. the 102nd line of StandrdFirmata) to fix this problem. reportAnalogCallback(pin - 14, mode == ANALOG ? 1 : 0); // turn on/off reporting How do you think about this issue? Best, Shigeru |