Go Down

Topic: Leonardo & Firmata (Read 1 time) previous topic - next topic

PaulS

Quote
It looks like a great fit, conceptually.

Then use it, conceptually.

The problem is that no one is maintaining firmata for the Arduino, making it handle new boards and new USB-to-serial chips.

What most people are doing is putting the intelligence on the Arduino. After all, that's why most people bought an Arduino. Not because they need to attach peripherals to the PC. If you still need to do that, develop and implement your own protocol. It is pretty easy to send something like "R,D,12" to the Arduino, and have it figure out that you want it to read digital pin 12. "S,4,0" to set pin 4 to LOW. "S,5,156" to set the PWM value of pin 5. "R,A,3" to read analog pin 3.

The advantage is that you can do things like "P,6" to read the PING sensor on pin 6, which you can't even think about doing with Firmata. Plus, your protocol will expand to additional boards and USB-to-serial chips.

You can even add error checking, so that "R,A,42" or "S,134,2903" returns an error message, instead of a meaningless number.

billroy

Of course, you could write the code to parse and execute Paul's proposed command language.

Or you could install Bitlash and have the same commands already available, and readable by humans:
Code: [Select]

print d12
a5=156
print a3


Then, when you add your ping sensor, you can add a little C code to the project to extend the language by adding the new function "ping", so you can say:

Code: [Select]

print ping()


Which is more important for your project, I wonder: the protocol, or working code?

Cheers all,

-br

kev_rm

Despite all the high horsepower technical problem solving occurring here, I did manage to get this work, more than conceptually. 

For other folks benefit, change the sketch variables to analogInputsToReport and sampingInterval to a good starting point (1 and 50 in my case), so the client has a reasonable chance to attach and start monitoring without too much noise.  Other than that i have been able to put the firmata sketch through its paces on the leonardo and it looks fairly solid.  No changes other than the above.   Unfortunately, the same cannot be said of the .NET clients out there...  I ended up writing my own which is frustrating. 

PS:  Ping is trivial with an additional call back.  So is just about any other library call within the context of firmata, so I am struggling with all the bashing.  The protocol is solid, the sketch looks good, I don't see any limitations in terms of extending it.  The problem is there aren't any decent clients in the .NET world.


PaulS

Quote
PS:  Ping is trivial with an additional call back.  So is just about any other library call within the context of firmata, so I am struggling with all the bashing.

You want to explain how you got ping() to work? Plenty of other people want to use ping sensors with Firmata.

kev_rm

#9
Jan 01, 2013, 05:15 am Last Edit: Jan 01, 2013, 05:58 am by kev_rm Reason: 1

Quote
PS:  Ping is trivial with an additional call back.  So is just about any other library call within the context of firmata, so I am struggling with all the bashing.

You want to explain how you got ping() to work? Plenty of other people want to use ping sensors with Firmata.


Really?  Did anyone look at http://www.firmata.org/wiki/Proposals?  All three are a very very simple extension of sysex.  An example below as modifications to standard firmata.  This is just illustrative and has not been tested on anything real. An alternative approach is to use a new top level command and firmata.attach() to it.  Also note, this would require client changes to deal with the new custom sysex message type and ascii conversion from println etc.

Code: [Select]

...
#include <Ping.h>
....
#define SYSEX_PING    0x67 // kev_rm's new ping protocol command
....
void sysexCallback(byte command, byte argc, byte *argv)
{
..
switch(command) {
..
case SYSEX_PING:  
  Serial.write(START_SYSEX);
  Serial.write(SYSEX_PING);
  Ping ping = Ping(argc,0,0);
// put responses from all three methods in the sysex message
  Serial.println(ping.microseconds());
  Serial.println(ping.inches());
 Serial.println(ping.centimeters());
 Serial.write(END_SYSEX);
 break;
...
}


Go Up