I am not sure this is the right place to ask this question. I am asking it here because fat16lib is the apparent author of the SerialPort Library that I am using. I am attempting to run the dataLogger example that comes with the library and had some stuff working but the Serial.txt file that is generated is empty. I was attempting to use the VisualMicro debugger to look at some things and it gives me the following errors. I am pretty new to Arduino and have limited programming experience so I am not exactly sure what its telling me. It looks like 2 things are defining something.
Compiling 'SerialLoggerWithMega' for 'Arduino Mega 2560 or Mega ADK'
core.a(HardwareSerial.cpp.o)*:In function `__vector_25'
HardwareSerial.cpp:multiple definition of `__vector_25'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:214: first defined here
ld.exe:Disabling relaxation: it will not work with multiple definitions
core.a(HardwareSerial.cpp.o)*:In function `__vector_36'
HardwareSerial.cpp:multiple definition of `__vector_36'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:231: first defined here
core.a(HardwareSerial.cpp.o)*:In function `__vector_51'
HardwareSerial.cpp:multiple definition of `__vector_51'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:237: first defined here
core.a(HardwareSerial.cpp.o)*:In function `__vector_54'
HardwareSerial.cpp:multiple definition of `__vector_54'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:243: first defined here
core.a(HardwareSerial.cpp.o)*:In function `__vector_26'
HardwareSerial.cpp:multiple definition of `__vector_26'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:271: first defined here
core.a(HardwareSerial.cpp.o)*:In function `__vector_37'
HardwareSerial.cpp:multiple definition of `__vector_37'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:281: first defined here
core.a(HardwareSerial.cpp.o)*:In function `__vector_52'
HardwareSerial.cpp:multiple definition of `__vector_52'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:287: first defined here
core.a(HardwareSerial.cpp.o)*:In function `__vector_55'
HardwareSerial.cpp:multiple definition of `__vector_55'
SerialPort.cpp.o:C:\Program Files\arduino-1.0.5\libraries\SerialPort\SerialPort.cpp:293: first defined here
Error creating .elf
Here is the logger code that I am using.
// Serial data logger example.
// Maximum baud rate for a 328 Arduino is 57600.
// Maximum baud rate for a Mega Arduino is 115200.
const uint32_t BAUD_RATE = 57600;
// Maximum time between sync() calls in milliseconds. If Serial is always
// active, you must provide a way to stop the program and close the file.
const uint32_t MAX_SYNC_TIME_MSEC = 1000;
// Pin number for error blink LED.
// Set ERROR_LED_PIN to -1 for no error LED.
const int8_t ERROR_LED_PIN = 22;
#include <SdFat.h>
#include <SerialPort.h>
#if defined(__AVR_ATmega1280__)\
|| defined(__AVR_ATmega2560__)
// Mega, use 4096 byte RX buffer
SerialPort<0, 4096, 0> NewSerial1;
#else // Mega
// not a Mega, use 1024 RX byte buffer
SerialPort<0, 1024, 0> NewSerial1;
#endif
SdFat sd;
SdFile file;
//------------------------------------------------------------------------------
// Error codes repeat as errno short blinks with a delay between codes.
const uint8_t ERROR_INIT = 1; // SD init error
const uint8_t ERROR_OPEN = 2; // file open error
const uint8_t ERROR_SERIAL = 3; // serial error
const uint8_t ERROR_WRITE = 4; // SD write or sync error
void errorBlink(uint8_t errno) {
uint8_t i;
while (ERROR_LED_PIN < 0);
while (1) {
for (i = 0; i < errno; i++) {
digitalWrite(ERROR_LED_PIN, HIGH);
delay(200);
digitalWrite(ERROR_LED_PIN, LOW);
delay(200);
}
delay(1600);
}
}
//------------------------------------------------------------------------------
void setup() {
pinMode(ERROR_LED_PIN, OUTPUT);
NewSerial1.begin(BAUD_RATE);
if (!sd.begin()) {
errorBlink(ERROR_INIT);
}
if (!file.open("SERIAL.txt", O_WRITE | O_CREAT | O_AT_END)) {
errorBlink(ERROR_OPEN);
}
if (file.fileSize() == 0) {
// Make sure first cluster is allocated.
file.write((uint8_t)0);
file.rewind();
file.sync();
}
}
//------------------------------------------------------------------------------
// Time of last sync call.
uint32_t syncTime = 0;
uint8_t buf[32];
void loop() {
if (NewSerial1.getRxError()) {
errorBlink(ERROR_SERIAL);
}
uint8_t n = NewSerial1.read(buf, sizeof(buf));
Serial.println(n);
if (n > 0) {
if (file.write(buf, n) != n) {
errorBlink(ERROR_WRITE);
}
// Don't sync if active.
return;
}
if ((millis() - syncTime) < MAX_SYNC_TIME_MSEC) return;
if (!file.sync()) {
errorBlink(ERROR_WRITE);
}
syncTime = millis();
}
Since I can't seem to use the debugger I put the Serial.println(n); in there to see the number of bytes read off the buffer but even with the debugger set to none I keep getting the above errors. Not sure what is going on. Thanks for any help.