Print an error on bad i2c request

Reference: https://github.com/MarlinFirmware/Marlin/pull/3713#issuecomment-218333678
This commit is contained in:
Scott Lahteine 2016-05-11 15:28:05 -07:00
parent a454a88f9c
commit a6d594665b

View File

@ -5040,10 +5040,14 @@ inline void gcode_M121() { endstops.enable_globally(false); }
uint8_t addr = code_seen('A') ? code_value_short() : 0; uint8_t addr = code_seen('A') ? code_value_short() : 0;
int bytes = code_seen('B') ? code_value_short() : 0; int bytes = code_seen('B') ? code_value_short() : 0;
if (addr && bytes) { if (addr && bytes > 0 && bytes <= 32) {
i2c.address(addr); i2c.address(addr);
i2c.reqbytes(bytes); i2c.reqbytes(bytes);
} }
else {
SERIAL_ERROR_START;
SERIAL_ERRORLN("Bad i2c request");
}
} }
#endif //EXPERIMENTAL_I2CBUS #endif //EXPERIMENTAL_I2CBUS