FirmataScheduler module does not work on esp8266 and solution
Again I was testing my Lazarus client over wifi I realized that the module FirmataScheduler does not work on esp8266.
I thought it probably was a similar issue than OneWireFirmata, so more searching, and I discovered that changing some lines of code it works: // bad code delayTask((long)((byte*)argv)); // working code delayTask(argv[0] | (long)argv[1]<<8 | (long)argv[2]<<16 | (long)argv[3]<<24);
// bad code schedule(argv[1], (long)((byte*)argv + 2)); // working code schedule(argv[1], argv[2] | (long)argv[3]<<8 | (long)argv[4]<<16 | (long)argv[5]<<24);
You need to change more lines because int, long, pointer have different size on esp8266, in report task void FirmataScheduler::reportTask(byte id, firmata_task *task, boolean error)
// bad code for (int i = 3; i < firmata_task_len(task); i++) { Encoder7Bit.writeBinary(((byte )task)[i]); //don't write first 3 bytes (firmata_task, byte); makes use of AVR byteorder (LSB first) } // working code Encoder7Bit.writeBinary(task->time_ms & 0xFF); Encoder7Bit.writeBinary((task->time_ms >> 8) & 0xFF); Encoder7Bit.writeBinary((task->time_ms >> 16) & 0xFF); Encoder7Bit.writeBinary((task->time_ms >> 24) & 0xFF); Encoder7Bit.writeBinary(task->len & 0xFF); Encoder7Bit.writeBinary((task->len >> 8) & 0xFF); Encoder7Bit.writeBinary(task->pos & 0xFF); Encoder7Bit.writeBinary((task->pos >> 8) & 0xFF); for (int i = 0; i < task->len; i++) { Encoder7Bit.writeBinary(task->messages[i]); }
I hope it is useful.