Canada
Offline
Jr. Member
Karma: 0
Posts: 75
I Love Arduino!
|
 |
« on: September 24, 2008, 07:26:58 am » |
Messenger is a new library for Arduino. It is a "toolkit" that facilitates the processing of ASCII messages. Messenger processes characters until it receives a carriage return (CR). It then considers the message complete and available. The message is split into many elements as defined by a separator. The default separator is the space character, but can be any character other than NULL, LF or CR. Messenger is the new SimpleMessageSystem. SimpleMessageSystem was nice, but not simple enough, so I wanted to switch to Firmata, but when I found out Firmata took at least half of my atmega168's memory, I went back to the drawing board and designed Messenger. Please note that Messenger only provides methods for incoming messages. The internal Serial.print() functions work just fine for outgoing messages. You can find Messenger here.
|
|
|
|
|
Logged
|
Thomas Ouellet Fredericks
|
|
|
|
New Jersey
Offline
Full Member
Karma: 0
Posts: 193
Ard at work
|
 |
« Reply #1 on: September 25, 2008, 03:29:10 am » |
Hey, thanks!
Can't wait to take it out for spin...
|
|
|
|
|
Logged
|
---------- Mathieu
|
|
|
|
0
Offline
Newbie
Karma: 1
Posts: 11
Arduino rocks
|
 |
« Reply #2 on: December 30, 2008, 10:38:36 am » |
This will be very useful! I would love to use this with my new ethernet shield to parse caller ID messages and perhaps scrape web pages but, unfortunately, it doesn't support strings yet.
I would take this on myself but efficient string handling requires more C expertise than I have!
Any hope that string support will be added to the messenger library anytime soon?
|
|
|
|
|
Logged
|
|
|
|
|
Canada
Offline
Jr. Member
Karma: 0
Posts: 75
I Love Arduino!
|
 |
« Reply #3 on: December 30, 2008, 12:03:53 pm » |
The problem with strings is that they use up a big chunk of memory (1 byte per letter). I could probably add string support. Something like: compareString(String) that would return a true or false. If the result is false, it stays in the buffer, if the result is true, it would pass to the next element of the message. p.s.: I am not sure I posted the link before, but Messenger can be found here: http://www.arduino.cc/playground/Code/Messenger
|
|
|
|
|
Logged
|
Thomas Ouellet Fredericks
|
|
|
|
0
Offline
Newbie
Karma: 1
Posts: 11
Arduino rocks
|
 |
« Reply #4 on: December 30, 2008, 02:31:47 pm » |
Yes, strings are memory hogs and are not easily handled in the Arduino environment. But something like Messenger could sure open a lot of interfacing possibilities!
I'd love to see support that allowed me to pick a string out of a sequence by position perhaps like:
readStr(index) returns the element at the index as a string (defined by the message separator).
Thanks for all you work on this so far!
|
|
|
|
|
Logged
|
|
|
|
|
Miami
Offline
Newbie
Karma: 0
Posts: 7
I <3 Embedded Linux
|
 |
« Reply #5 on: December 31, 2008, 03:48:53 pm » |
nice!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #6 on: July 24, 2009, 01:01:11 am » |
Hi,
Is it possible to use this library also on Serial1, Serial2 etc. available on the Arduino Mega? (This would be great)
Thank you
|
|
|
|
|
Logged
|
|
|
|
|
Canada
Offline
Jr. Member
Karma: 0
Posts: 75
I Love Arduino!
|
 |
« Reply #7 on: November 27, 2009, 09:49:36 am » |
Is it possible to use this library also on Serial1, Serial2 etc. Yes. You simply feed byte process(int serialData) with the serial data of the port you wish to parse. Please note that will also need one instance of the Messenger class for every port.
|
|
|
|
|
Logged
|
Thomas Ouellet Fredericks
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #8 on: November 28, 2009, 05:50:04 am » |
Hi, Thank you for indicating what needs to be done - I will answer back if this worked for me Ralph
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 6
Arduino rocks
|
 |
« Reply #9 on: November 28, 2009, 03:27:13 pm » |
I see what you mean - this was really not a too clever question of mine...
Thank you for providing this very useful library!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #10 on: November 30, 2009, 04:12:15 pm » |
Hello,
Could you develop the advantage of your solution compared with the bitlash one ? Bitlash runs on 168 and allows one to dial with serial term as easily as :
i=3; while i<=8: pinMode(i,1); digitalWrite(i,1); i++
It allows the macro too.
Regards
|
|
|
|
|
Logged
|
|
|
|
|
Canada
Offline
Jr. Member
Karma: 0
Posts: 75
I Love Arduino!
|
 |
« Reply #11 on: November 30, 2009, 07:35:20 pm » |
Could you develop the advantage of your solution compared with the bitlash one ? Well it is not a shoving match against messenger and bitlash that's for sure! If you read the start of the thread, you will see I was looking for a [glow]light weight[/glow] communication solution. Bitlash is not lightweight (takes up almost all the memory on a tamega168) and is not a simple communication protocol but a complete shell. Messenger is lightweight and very simple to implement.
|
|
|
|
|
Logged
|
Thomas Ouellet Fredericks
|
|
|
|
Canada
Offline
Jr. Member
Karma: 0
Posts: 75
I Love Arduino!
|
 |
« Reply #12 on: December 01, 2009, 09:27:31 am » |
Two string handling functions have been added to Messenger. Check them out here: http://www.arduino.cc/playground/Code/Messenger
|
|
|
|
|
Logged
|
Thomas Ouellet Fredericks
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 20
Arduino rocks
|
 |
« Reply #13 on: December 02, 2009, 10:56:39 am » |
Hi Excellent library I must say. Thanks for it. I am having some troubles trying to use Serial1 on the Arduino Mega. I basically took the example that is provided and changed Serial to Serial1. Can anyone take a look at my code below and help me please? #include <Messenger.h> // Instantiate Messenger object with the default separator (the space character) Messenger message = Messenger();
// Create the callback function void messageReady() { int pin = 10; // Loop through all the available elements of the message while ( message.available() ) { // Set the pin as determined by the message digitalWrite( pin, message.readInt() ); pin=pin+1; } }
void setup() { // Initiate Serial Communication Serial1.begin(9600); Serial.begin(9600); // Attach the callback function to the Messenger message.attach(messageReady); }
void loop() { // The following line is the most effective way of using Serial and Messenger's callback while ( Serial1.available() ) message.process(Serial1.read () ); }
|
|
|
|
|
Logged
|
|
|
|
|
Canada
Offline
Jr. Member
Karma: 0
Posts: 75
I Love Arduino!
|
 |
« Reply #14 on: December 02, 2009, 12:02:31 pm » |
I can only help you if you describe what are the troubles you are experiencing.
|
|
|
|
|
Logged
|
Thomas Ouellet Fredericks
|
|
|
|
|