Reading data from slave i2c device in meta gcode (M260 gcode).
-
Is it possible to access in meta script data received in M260 gcode? For example, to read the settings of an interchangeable tool from the i2c eeprom chip attached to it. The last answer to this question was a year ago. Then it was a promise to add this functionality to the new release of reprap firmware. How is it doing by now? What else could be the way to solve this problem? Advise, please, in a nutshell, how could this be done in the firmware. Without details. Just to figure out which way to go.
-
Unfortunately, no one answered me. I tried to solve this problem myself. It seemed to me a good option would be to return data from the gcode to a buffer local variable, the name of which should be reported to the gcode through an additional string parameter of the gcode. For example:
var i2cReadBuffer = vector(10, 0) M260 A80 B0 R10 S"i2cReadBuffer" echo "buffer:", var.i2cReadBuffer
I changed the procedure of M260 gcode. If S parameter is missing, the behavior remains unchanged. If S parameter is set and there are no errors, the behavior is the same plus the received data is stored in a buffer variable. If an error is found, the result of the gcode is changed to ERROR and the reason is reported in the reply. Possible reasons -
- variable not found
- does not match the type of the variable (an array of integers)
- insufficient array length
It works at first glance. I've done a few checks with BMP280 and eeprom 24c04:
I plan to make a post in Firmware developers branch. I think this topic deserves discussion. Otherwise M260 gcode remains near useless in meta gcode.
-
@arkayu I will continue the conversation in this thread as you say - it will require firmware updates:
https://forum.duet3d.com/topic/31842/returning-data-resived-from-i2c-slave-m260-to-calling-macro