Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirmataScheduler module does not work on esp8266 and solution #90

Open
jcvillegasfernandez opened this issue Jun 12, 2019 · 0 comments
Open

Comments

@jcvillegasfernandez
Copy link

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.

@jcvillegasfernandez jcvillegasfernandez changed the title FirmataScheduler module does not work on esp8266 FirmataScheduler module does not work on esp8266 and solution Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant