Hi,
I am trying to collect values for several variables for my sketch in Arduino, from serial. My problems are that the variables are 53 and most of them time_t or Epoch date time format. If using DateTime library, on its playground page an example to collect the value for a 10 bytes variable is presented, which updates the clock in Arduino. However, this approach was not useful in my case due to the large number of variables, ending by overloading Arduino (Duemillanove 328). So, looking for a better way to retrieve long values from a Serial Port, I saw Firmata. Great but there is still not a version for Java, and my API to send the values to the Serial port to Arduino is a Java API.
Check: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1244065761
There, Agib, got a good step on that direction.
I attempted another path, by using Messenger library from:
http://www.arduino.cc/playground/Code/Messenger
I had problems with the "send" feature of Arduino IDE's Monitor. Thomas was very nice to help me looking for alternatives.
After getting readList example sketch up and running, I noticed that it can only retrieve int and char values using the functions readInt() or readChar()... very sad because it is a great tool that can collect the values for several variables just separated by a space or another character but limited to integers and the first char of strings.
I needed a readLong() that is not existing in the library.
If you need it as well, then this is what worked for me:
- download the last version of Messenger Library and install it.
- edit with Kate (linux) or notepad (windows) all the three main files of its Messenger folder as follows:
- add in Messenger.cpp, between the blocks for int and char:
long Messenger::readLong() {
if (next()) {
dumped = 1;
return atol(current); // atol for long instead of atoi for int variables
}
return 0;
}
-
added inside keywords.txt, between the lines for int and char:
readLongKEYWORD2 -
added on Messenger.h, under "public" between int and char lines:
long readLong();
IF you did not run a sketch with the Messenger library before, you are set. But if you did it, now you may get the error:
undefined reference to `Messenger::readLong()'
This is because when running the library, it creates a Messenger.o file. If you have it, just delete it, and compile your sketch using the new function readLong() as you would use the readInt().
Now you can collect values in Long, using this library just as Int and Char.
regards,
Gian Paolo