Pages: 1 ... 4 5 [6] 7   Go Down
Author Topic: An alternative Serial Library for Arduino 1.0  (Read 20785 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Edison Member
*
Karma: 63
Posts: 1604
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have posted a fast serial data logger that can log sustained serial data to an SD card at 57,600 baud on a 328 Arduino and 115,200 baud on a Mega. 

For details see this post http://arduino.cc/forum/index.php/topic,86300.0.html
Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All...

I am trying to use this library in a large application, and when I link it I get the errors pasted below. I have removed all places where the HardwareSerial.h library exists, and removed all Serial1 and Serial calls. I can build the samples. I realize the cause is because the compiler must be finding the original Serial library somewhere, but how to find it? Any hints?

Thanks...

-LC:\Users\jim\AppData\Local\Temp\build2981441506981796786.tmp -lm
core.a(HardwareSerial.cpp.o): In function `__vector_20':
C:\Users\jim\Desktop\arduino-1.0\hardware\maniacbug-mighty-1284p-8f335f8\cores\standard/HardwareSerial.cpp:106: multiple definition of `__vector_20'
SerialPort\SerialPort.cpp.o:C:\Users\jim\Desktop\arduino-1.0\libraries\SerialPort/SerialPort.cpp:198: first defined here
core.a(HardwareSerial.cpp.o): In function `__vector_28':
C:\Users\jim\Desktop\arduino-1.0\hardware\maniacbug-mighty-1284p-8f335f8\cores\standard/HardwareSerial.cpp:127: multiple definition of `__vector_28'
SerialPort\SerialPort.cpp.o:C:\Users\jim\Desktop\arduino-1.0\libraries\SerialPort/SerialPort.cpp:207: first defined here
core.a(HardwareSerial.cpp.o): In function `__vector_21':
C:\Users\jim\Desktop\arduino-1.0\hardware\maniacbug-mighty-1284p-8f335f8\cores\standard/HardwareSerial.cpp:190: multiple definition of `__vector_21'
SerialPort\SerialPort.cpp.o:C:\Users\jim\Desktop\arduino-1.0\libraries\SerialPort/SerialPort.cpp:243: first defined here
core.a(HardwareSerial.cpp.o): In function `__vector_29':
C:\Users\jim\Desktop\arduino-1.0\hardware\maniacbug-mighty-1284p-8f335f8\cores\standard/HardwareSerial.cpp:221: multiple definition of `__vector_29'
SerialPort\SerialPort.cpp.o:C:\Users\jim\Desktop\arduino-1.0\libraries\SerialPort/SerialPort.cpp:252: first defined here
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting, I see it's not working out of the box with maniacbug-mighty-1284p  smiley-mr-green

__vector_20 is USART0_RX_vect.  The 1284P defines the USART0 vectors, HardwareSerial picks them up.  Shouldn't this also have the same problem on a Mega?

Looks like this library is demanding access to the USART0_RX_vect?
« Last Edit: February 18, 2012, 01:22:47 am by maniacbug » Logged


Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting, I see it's not working out of the box with maniacbug-mighty-1284p  smiley-mr-green

__vector_20 is USART0_RX_vect.  The 1284P defines the USART0 vectors, HardwareSerial picks them up.  Shouldn't this also have the same problem on a Mega?

Looks like this library is demanding access to the USART0_RX_vect?

Oh? I was able to build a few of the examples that came with this library using your cores. I had suspected it was a core issue, but after I was able to build the examples I assumed it must be my code.

If I remove the HardwareSerial.cpp file, then the compilation fails. Its getting dragged in somewhere.
 
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, I mis-spoke.  As you say, examples compile fine on mighty-1284p.

What's happening is that the LINKER wants to include these symbols from HardwareSerial.  There's no avoiding the compiler picking them up.

It would be interesting to see the errors you get when removing HardwareSerial.cpp.
Logged


0
Offline Offline
Edison Member
*
Karma: 63
Posts: 1604
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A number of libraries access Serial.  This causes HardwareSerial to be loaded even if you don't call the functions that access Serial.  These libraries can't be used with SerialPort.

All released SD.h and SdFat libraries cause HardwareSerial to be loaded and can't be used with SerialPort.  I will soon release a version of SdFat that does not access HardwareSerial. 

A beta version of this SdFat is in SerialLoggerBeta20120108.zip here http://code.google.com/p/beta-lib/downloads/list.
Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A beta version of this SdFat is in SerialLoggerBeta20120108.zip here http://code.google.com/p/beta-lib/downloads/list.

Okay, when I use that beta I can link if I remove another library from my system. I was taking a look to see how I might be able to modify that library, and I looked into your headers and saw that in sdFatUtil.h:

Code:
#include <avr/pgmspace.h>
#if ARDUINO < 100
#include <WProgram.h>
#else  // ARDUINO
#include <Arduino.h>
#endif  // ARDUINO

WProgram.h brings in:

Code:
#include "HardwareSerial.h"

But my app includes that header.

How did you resolve this conflict?






Logged

Guildford, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 217
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I played around with this when the library was first posted, trying to understand how it all worked.

The problem is not including HardwareSerial.h but using Serial, Serial1 etc.

The first time you call Serial.begin() you will pull in all the code in HardwareSerial. If you reference a library that calls Serial.print() etc you will also pull in the HardwareSerial code.

If it's your library that's causing the problem, the easiest fix is to add a variable to your library:

Code:
Stream* activeSerialPort;

and initialise it in setup()

Code:
#include <MyLib.h>

void setup()
{
  Serial.begin(115200);
  activeSerialPort = &Serial;
}

or if you switch to SerialPort:

Code:
#include <MyLib.h>
#include <SerialPort.h>

SerialPort<0, 64, 64> serialPort;

void setup()
{
  serialPort.begin(115200);
  activeSerialPort = &serialPort;
}

HardwareSerial and SerialPort inherit from Stream, so it just works. Remember that any calls in your library will change from Serial.print() to activeSerialPort->print() etc.

Hope that helps.

Iain
Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Lain, but nowhere in my code am I using Serial or Serial1 any longer. I found the library that I need to exclude to "fix" the problem, but I can't see anywhere in that library where Serial or Serial1 is being used either. I sent a note to the author of the other library, perhaps he will have an idea.

Thanks again.
Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah!  I take it back, thanks sixeyes! That other library had a diagnostic function that was in fact using Serial. I commented it out, and all is good now, thanks! With any luck, the new SD Beta Library will work well and I'll be off to the races!


Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From looking at the code, it does not appear that the buffer sizes are restricted t powers of 2. Is that correct?
Logged

Guildford, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 217
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Correct. See post #40 in this thread for confirmation. Would have posted a link but I don't know how to link to a specific message.

Iain
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 199
Posts: 12768
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Reply #40...
http://arduino.cc/forum/index.php/topic,85207.msg641119.html#msg641119

...next to "Reply #" there is a message icon.  It is a link to that message.  On this message it is an exclamation mark.  The title over each message is also a link to that message.
Logged

Guildford, UK
Offline Offline
Full Member
***
Karma: 0
Posts: 217
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Reply #40...
http://arduino.cc/forum/index.php/topic,85207.msg641119.html#msg641119

...next to "Reply #" there is a message icon.  It is a link to that message.  On this message it is an exclamation mark.  The title over each message is also a link to that message.


Thanks for the tutorial. Most helpful.

Iain
Logged

Smithfield, Rhode Island
Offline Offline
God Member
*****
Karma: 3
Posts: 843
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A number of libraries access Serial.  This causes HardwareSerial to be loaded even if you don't call the functions that access Serial.  These libraries can't be used with SerialPort.

All released SD.h and SdFat libraries cause HardwareSerial to be loaded and can't be used with SerialPort.  I will soon release a version of SdFat that does not access HardwareSerial. 

A beta version of this SdFat is in SerialLoggerBeta20120108.zip here http://code.google.com/p/beta-lib/downloads/list.

Hi...

I was just wondering if there is an update to this beta?
Logged

Pages: 1 ... 4 5 [6] 7   Go Up
Jump to: