ISR Vector, UART issues

I am using an arduino mega2560, and a uLCD-43PT display from 4D systems with their library. I am trying to modify the library for the display such that it communicates from really any other serial port on the mega except the one the genieArduino library is setup for. That is, serial ports 1,2, or 3 but not 0. This is b/c I want to keep the default one open for communication. Now, if i do not start serial port 0 it compiles, and it works. That is, moving the serial port communication for the display to the other pins allows communication and I can still upload via USB while display is still connected. Originally, of course this is not possible (you have to disconnect display from serial port 0, before you can communicate with arduino).

Now, when I try to start the serial port; Serial.begin(whatever), I get this compiling error

core.a(HardwareSerial.cpp.o): In function `__vector_51':
C:\arduino\arduino-1.0.3\hardware\arduino\cores\arduino/HardwareSerial.cpp:169: multiple definition of `__vector_51'
genieArduino\genieArduino.cpp.o:C:\arduino\arduino-1.0.3\libraries\genieArduino/genieArduino.cpp:119: first defined here
c:/arduino/arduino-1.0.3/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

I’ve attached the original library files for the display, and the one I adjusted.

genieArduinoORIGINAL.h (3.2 KB)

genieArduinoORIGINAL.cpp (9.91 KB)

genieArduinoADJUSTED.cpp (10.8 KB)

Why are you using the genie serial code instead of Serial1 (hardwareSerial). I'd just drop the genie code altogether.

Mark

Why are you using the genie serial code instead of Serial1 (hardwareSerial). I'd just drop the genie code altogether.

B/c I'm not that familiar with serial libraries, and arduino in general to venture in something like that right now; believe me I thought about it and probably eventually will in the future; but the timing isn't right for me to dive into something like that right now. It's been years since I've coded, and only have started up again recently, and it's very frustrating knowing where I once was and feeling like I'm starting over again.

Start by taking a look in the reference section of this site.

Mark

Of coure, I have already gone through that. Most of that is very basic functions, bitwise operators, overloading of binary operators whatever, that's trivial. Look, I use to be pretty good in C++, I went on to learn OpenMP and some MPI as well, but that was a long time ago. I don't need calculus instructions on how to command various loops and what they do, etc. I remember all those fundamentals. However, I do need help with my question or help with the Serial library in general such that I would feel comfortable with ditching the genieArduino library and making something of my own that would perform similar to that library. So if you want to point me somewhere, point me in the direction of some good sources to conquer the hardware serial lib, UART, etc for the arduino.

The IDE adds declarations for Serial, Serial1 etc to your code along with other boiler plate code. So you don't need to add any other code to deal with any of the hardware Uarts on the chip.

Mark

holmes4: Start by taking a look in the reference section of this site.

lordofentropy: Of coure, I have already gone through that.

(snip)

So if you want to point me somewhere, point me in the direction of some good sources to conquer the hardware serial lib, UART, etc for the arduino.

Start by taking a look in the reference section of this site. Only this time, instead of turning your nose up when you see the parts that cover C++ operators you already know about, read the [u]whole[/u] page including the part at the bottom that provides links to the documentation for Serial and Streams. It really is pretty trivial to use.

When you've read that, look at the basic examples for the Arduino. Lots of them use the hardware Serial port. If you want to use the other hardware serial ports, just replace Serial with Serial1, Serial2 or Serial3.

Start by taking a look in the reference section of this site. Only this time, instead of turning your nose up when you see the parts that cover C++ operators you already know about, read the whole page including the part at the bottom that provides links to the documentation for Serial and Streams. It really is pretty trivial to use.

Again, of course I have already gone through ALL of that. I need something with much more detail, such that I can possibly get the geneArduino library working

When you've read that, look at the basic examples for the Arduino. Lots of them use the hardware Serial port. If you want to use the other hardware serial ports, just replace Serial with Serial1, Serial2 or Serial3.

If you would go back to my very first post, you would see that I have already tried that. by adjusted arduinoGenie file, I have changed if from default port to serial port 2. However, again when everything compiles nicely when I do not open the default port. Once however I do attempt to open the default port I obtain that compile error, which I don't quite understand b/c the arduino reference page does not go into detail.

Even if I try with the orginal library files, and setup various ports, I would still get a similar compile error...different vector. It has something to do with using the genieSetup(baud speed) function compromising the serialN.begin(baud speed) function

if the error message is saying you cant reassign the interrupt vector, then you need to either stop Hardwareserial.cpp setting it first, or allow the default assignment to be re-defined… hint lookup weak for function definitions.

lordofentropy: If you would go back to my very first post, you would see that I have already tried that. by adjusted arduinoGenie file, I have changed if from default port to serial port 2. However, again when everything compiles nicely when I do not open the default port. Once however I do attempt to open the default port I obtain that compile error, which I don't quite understand b/c the arduino reference page does not go into detail.

Even if I try with the orginal library files, and setup various ports, I would still get a similar compile error...different vector. It has something to do with using the genieSetup(baud speed) function compromising the serialN.begin(baud speed) function

The problem appears to be that you have two definitions on an interrupt handler. If you're using the Arduino API then you need to retain the Arduino implementation. I can't imagine why you would be reluctant to do this since the API is trivially simple, as you will have seen from your careful and thorough reading of the Arduino API reference.

If you decide to stick with the serial port driving code from your other runtime framework then I suppose you would need to remove or disable the corresponding parts of the Arduino framework. The Arduino reference doesn't go into detail about how to do it because that is not a use that Arduino supports, but there's nothing to stop you from doing it if you decide to - the source is all there and accessible for you. However, making two runtime frameworks coexist when neither of them are designed to be used like that is likely to require understanding of the operation of both frameworks at quite a low level. IMO you would have a much easier life if you stick to one or the other.