I intend to use the co-processor to read ADC values.
I see the Firmata flasher application on Github, exposes a simple HTTP API for flashing and setting pins. Very nice.
A few questions:
Should I just have the co-processor running as a parallel application, keeping the flash up to date and providing the middleware to the co-processor?
It’s hard to use it as a Git submodule due to the directory structure, maybe I will open an issue and discuss that directly. Am I expected to fork and modify the code to expose more hardware via the API?
What would be the smart approach to interfacing with the co-processor, if you ignore everything else that I’ve said? (The rest of my applications are written in Python, BTW.)
My colleagues were recently working on a project to facilitate getting up and running with the fin coprocessor via the firmata protocol. I have pinged them and they will be able to provide more concrete answers.
Great to hear that you’re using the Fin and it’s coprocessor. As Rahul said we’ve been doing some work in this area, specifically to make it easier for people to use in their applications. It’s still early in the development phase, but it would be great if you could try it out and add issues/requests/PRs to the github repo: https://github.com/balenablocks/finabler
This is a balena block, which means we build it as a docker image that can bring in via your docker-compose.yml file:
Add a series of tags to the device view of your Fin:
The ability to set an environment variable to a specific firmata version from our releases page and the block will handle flashing it for you. OR…
Set the variable to latest and the block will flash the latest version
All device configuration settings are auto-set
A REST API for interacting with the coprocessor.
Currently 5. is limited to a ping endpoint, to programmatically know when the coprocessor is ready for instructions, and a sleep endpoint. These are super useful, but we want to add more. Reading ADC values is high on our list, but adding your userland voice to the GH repo will help us to prioritise.
The API is exposed on port 1337. Have a play and see what you can do.
Phil, that is exactly what I was looking for, you rock.
I will fork and submit PRs if I get far enough along to want to try reading the inputs. Do you suggest that I just add it as a git submodule and specify build instead of image, so I can play with the node code in index.js?
Should I be setting SERIAL_DEVICE to something specific?
finblock Cannot query firmware
finblock Start automatic flashing: installing firmata v2.0.1
finblock flash stderr: Failed to open SERIAL_DEVICE: No such file or directory
finblock
finblock Error: Flashing failed with message: Failed to open SERIAL_DEVICE: No such file or directory
finblock
finblock at Socket.<anonymous> (/usr/src/app/flasher.js:39:22)
finblock at Socket.emit (events.js:315:20)
finblock at addChunk (_stream_readable.js:295:12)
finblock at readableAddChunk (_stream_readable.js:271:9)
finblock at Socket.Readable.push (_stream_readable.js:212:10)
finblock at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
finblock flash failed! device will not reboot.
Assuming that it’s looking for /dev/ttyS0:
root@tcore:/usr/src/app# stat /dev/ttyS0
stat: cannot stat '/dev/ttyS0': No such file or directory
(That’s logged into the host OS.)
I note the readme says:
Automatically applies device tree overlays required for the coprocessorI see that the image
But I don’t see anything about enabling the serial UART, is there a step I missed?
I sorted out the Balena OS issue and the finabler launched and flashed as expected. Very cool!
I tested /ping (via a simple GET request) and it just hangs, nothing happens. /firmware works, and so does /sleep, which is just fantastic. Thank you very much for the suggestion Phil, and your work on this project.
I’m glad you got this sorted. I think the crux of your issue getting the block to run, was in getting your Fin re-flashed and configured properly as a Fin. The overlays (and therefore UART enablement) will be predicated on this being correct.
With regards to the /ping endpoint, I’ve just spotted and fixed the bug and pushed a new image to docker. If you push this to your device, the ping endpoint will return if the device is ready. There is more to do on this endpoint, since we want to make sure it covers all of the cases where the block is running, but busy (e.g. flashing, about to sleep). For now it simply tells you that the block is up and running.
The only thing different than the documentation was the image parameter in docker-compose.yaml. The README shows image: balenablocks/finabler::latest but that caused an error, so I changed it to image: balenablocks/finabler which worked as expected.