[SOLVED] using a different hardware serial library

So, for a project I did, I had to modify the 'hardwareserial' library as I had some specific requirements.

Works great, only this is that the only way I seemed to be able use my modified library is to overwrite the original 'harwareserial' library.

Is there anyway to force the IDE to use the modified library without having to overwrite the original 'hardwareserial' files?

Give it a different name.

Grumpy_Mike:
Give it a different name.

yeah... tried that... did not work!

sherzaad:
yeah... tried that... did not work!

!
did you tell the IDE to "know" your lib?

sherzaad:
yeah... tried that... did not work!

What exactly did you try ?

UKHeliBob:
What exactly did you try ?

Give it a different name! :stuck_out_tongue_winking_eye:

but also put the library in the same folder as the sketch and in the sketch use #include "LINSerial.h".

however from the arduino output, it was somehow still using hardwareserial library

If anyone ever did something similar (ie use a modified hardware serial lib) without overwriting the original, if they could share their sketch for me to test it would be much appreciated.

sherzaad:
yeah... tried that... did not work!

That means a differ name for the folder it is in and all the files in it and the call to include the .h file in the .cpp file, and the word highlight file.

I have done it many times and it does work.

Grumpy_Mike:
Give it a different name.

Give the whole class a different name, and remove all double #define statements ! there might be a few more things you need to do. It should be possible to redefine the functions since they are declared weak. It is all a little bit above me though, but considering that you probably will never use both the original and the altered version in same sketch you could have 2 versions of the IDE on your computer one with the altered hwSerial and one with the original. (that was my solution and that works with ease of use) Hey but how about you post the other Serial Lib and see if anyone can make it work.

The idea i had was to integrate both versions into 1 HWSerial and use IFDEF to conditionally compile which ever version we want.

Also have a look at the 'Conceptinetics' DMX library, in there it is done in a very elegant way as well, you can on a 'Mega' run the DMX from 1 Serial port and use the others as normal.

Deva_Rishi:
Also have a look at the 'Conceptinetics' DMX library, in there it is done in a very elegant way as well, you can on a 'Mega' run the DMX from 1 Serial port and use the others as normal.

Thanks! I'll have a look.

Grumpy_Mike:
That means a differ name for the folder it is in and all the files in it and the call to include the .h file in the .cpp file, and the word highlight file.

I have done it many times and it does work.

Oh I'm sure it can be done! just me doing something wrong here... hence my request in my last post to SHARE an example to compare with

I have modified libraries in the past and if you put that new directory in your libraries folder, the IDE will use that instead of the build-in one. It will inform you of the choices it is making. This allows the modified library to be used by throughout your entire project, including other libraries.

In my case it was the i2c (wire) library

blh64:
I have modified libraries in the past and if you put that new directory in your libraries folder, the IDE will use that instead of the build-in one. It will inform you of the choices it is making. This allows the modified library to be used by throughout your entire project, including other libraries.

In my case it was the i2c (wire) library

does that work with 'core' libraries as well ?

Deva_Rishi:
does that work with 'core' libraries as well ?

The Wire library comes with the IDE - does that count as core? If so, then the answer is yes. If not, then the answer is no. Give it a try and the IDE will tell you which libraries it is using during linking.

blh64:
The Wire library comes with the IDE - does that count as core?

No. as core libraries count the ones that are part of the core, eg Arduino.h and the other found in
Arduino\hardware\arduino\avr\cores\xxx

blh64:
I have modified libraries in the past and if you put that new directory in your libraries folder, the IDE will use that instead of the build-in one. It will inform you of the choices it is making. This allows the modified library to be used by throughout your entire project, including other libraries.

In my case it was the i2c (wire) library

Deva_Rishi:
does that work with 'core' libraries as well ?

@Deva_Rishi

I have gone back and applied what was suggested by blh64 for my hardwareserial lib and it works! so I guess it does work for 'core' libraries as well.

in my case I have missed on of the hardwareserial lib ( I found 7 in all!) which was probably why it was not working originally