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

Identify each Firmata-flashed board with a unique name #471

Closed
PizzaProgram opened this issue Nov 22, 2020 · 8 comments
Closed

Identify each Firmata-flashed board with a unique name #471

PizzaProgram opened this issue Nov 22, 2020 · 8 comments

Comments

@PizzaProgram
Copy link

PizzaProgram commented Nov 22, 2020

After 2 years I still couldn't find any standard solution for naming the boards before flashing and searching for unique names to identify which board is at which usb/ip.

At sample .INO files there should be something like this at the beginning:
#define FIRMATA_UNIQE_BOARD_NAME "nano_b126_living_room_temp"; // <<-- RENAME this before flashing !!
...
And the identification could be something like:
string USBport = firmata.SearchSerialPortbyName("Mega36_basement");
So it would be nice to have a "built-in" simple search algorithm to help implement this basic feature to each programming language adapting Firmata.

Already a simple "readout", like:
if (firmata.ReadBoardName() != "b123_garage_door_relay") return;
would help a lot to prevent any accidents.

Why is this great protocol supports only 1 board by default?
Mixing up a board with others, if the USB port or IP number changes makes this protocol dangerous to use at real life or industrial enviroments.

@soundanalogous
Copy link
Member

soundanalogous commented Nov 22, 2020

The protocol supports several MCU architectures by default. The reason each board is not uniquely identified is this does not scale well and would be a huge maintenance issue. See boards.h for all of the currently supported architectures. Each board reports its features using the capability query.

Also, Firmata is not engineered for use in "industrial environments", as an open source project, it's "use at your own risk".

@soundanalogous
Copy link
Member

soundanalogous commented Nov 22, 2020

There is also a simple solution to what I believe you are trying to accomplish, that is to name the .ino file something unique for each board. So rather than StandardFirmata.ino, name the sketches: "boardA.ino", "boardB.ino", etc. There is no way to name the serial port from the code running on an Arduino that I'm aware of so, you'd have to attempt to make a connection on each serial port, and if a board running Firmata is found, then you can get the exact board based on what you named the .ino file.

@PizzaProgram
Copy link
Author

The reason each board is not uniquely identified is this does not scale well and would be a huge maintenance issue.

I think you have misunderstood me a bit. My suggestion has nothing to with the fact, how many kinds of board Firmata supports. (Which is extremly cool by the way 🥇 )
I'm talking about a different / independent naming.

So rather than StandardFirmata.ino, name the sketches: "boardA.ino", "boardB.ino"

This solution sounds interesting! :)
And what command is it, that gives me back the name of the "boardB.ino" from the host side?
Basically how do I "ask" the board connected currently to "/dev/ttyUSB3" >> Who are you? What "boardname" do you have?

@soundanalogous
Copy link
Member

Use the query firmware command as described here.

@dtex
Copy link

dtex commented Nov 23, 2020

@PizzaProgram Jeff's suggestion works well. I had a project that used multiple boards of the same type (Uno's). Renaming the sketch allowed me to sniff out which board I had connected to at each address.

@PizzaProgram
Copy link
Author

PizzaProgram commented Dec 1, 2020

@soundanalogous You are right, it's already done! I was "knocking on opened doors".
Maybe 1-1 sentence comment on the front page + in the SandardFirmata.ino sample file would save others many time too.
I'm looking at :
file:///C:/Program%20Files%20(x86)/Arduino/libraries/Firmata/docs/html/index.html

Something like:
# To give unique name to each flashed board, you can rename the .ino project file (Save As...)
# and read back later with this method:
# https://github.com/firmata/protocol/blob/master/protocol.md#query-firmware-name-and-version

Now I have to find a way to turn this into a REAL example, how to do it from Node-Red.
(Learning and trying since a week without success.)

@PizzaProgram
Copy link
Author

Jeff's suggestion works well. I had a project that used multiple boards of the same type (Uno's). Renaming the sketch allowed me to sniff out which board I had connected to at each address.

@dtex Many thanks for the feedback!
Can you please share your code, how you did it Please?

@dtex
Copy link

dtex commented Dec 2, 2020

I can't help with node-red, but with firmata.js you just check the board.name property. It will be whatever you named the sketch that was uploaded to that board. Does node-red expose the board object?

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

3 participants