MichaelJonker / HardwareSerialRS485

Arduino Software for RS485 support with collision detection and message handling capabilities
MIT License
107 stars 29 forks source link

Can't compile in 1.6.4. Any suggestion? #2

Closed MarcoBlulab closed 9 years ago

MarcoBlulab commented 9 years ago

I'm using Arduino 1.6.4 and I get the following errors and warning when I try to compile Morse demo:

\arduino\libraries\HardwareSerial_RS485/HardwareSerial_RS485.h:28:8: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
#error "HardwareSerial.h already loaded. The file HardwareSerial_RS485.h must be included before the #include "Arduino.h" (whether explicit or implicit)."

\arduino\libraries\HardwareSerial_RS485/HardwareSerial_RS485Helper.h:74:128: error: no match for ternary 'operator?:' (operand types are 'bool', 'PORTDemulation', and 'PORTBemulation')
const static unsigned char TRx_PORT = T__TRx_PORT == 'B' ? PORTB : T__TRx_PORT == 'C' ? PORTC : T__TRx_PORT == 'D' ? PORTD : PORTB;

\arduino\libraries\HardwareSerial_RS485/HardwareSerial_RS485Helper.h:75:128: error: no match for ternary 'operator?:' (operand types are 'bool', 'DDRDemulation', and 'DDRBemulation')
const static unsigned char DDR      = T__TRx_PORT == 'B' ? DDRB  : T__TRx_PORT == 'C' ? DDRC  : T__TRx_PORT == 'D' ? DDRD  : DDRB ;

\arduino\libraries\HardwareSerial_RS485/HardwareSerial_RS485.h:88:16: error: 'Serial0' was not declared in this scope
#define Serial Serial0

Do you have any suggestion to correctly compile the Morse demo? I'm very interested on this library, because it seems to be the better library for rs485 i found. You have done a great work!

MichaelJonker commented 9 years ago

Thanks for trying this code and reporting the issue. I developed the code with IDE 1.0.5 and did not have time yet to look at 1.6.4 and to solve any related issue.

What I already know is that one should remove the file HardwareSerial_USB.cpp from the distribution. This file is a nonfunctional development stub for ATmega32u4 based Arduini (Leonardo, micro). The file includes Platform.h which has been moved to a different location since 1.0.5

However, in your case there is another issue. From what I see in your error log: Due to the compiler changes, there is an error in my error report through the #error macro:

\arduino\libraries\HardwareSerial_RS485/HardwareSerial_RS485.h:28:8: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]

error "HardwareSerial.h already loaded. The file HardwareSerial_RS485.h must be included before the #include "Arduino.h" (whether explicit or implicit)."

This should be fixed. But the real problem is caused the wrong order of including header files. HardwareSerial_RS485.h should be included before HardwareSerial.h (which is often included by Arduino.h). All the other errors are caused this problem.

If you get these errors by compiling my examples without any modification, then this error is likely caused by changes in the framework and the way it loads the include files. In that case this is something I have to fix (might be nasty to do this properly, although nothing fundamental, it is kind of playing hide and seek with the framework include files). If you get the errors after making some mods, or by using your own sketches, then please carefully check the order of the include files.

Something else that is possibly not clear from my instructions is that the folders “HardwareSerial_RS485”, “MessageFilter” and “Morse” in the repository under the folder “libraries” should be copied to the user libraries folder (there should be a folder “libraries” in the Sketchbook location, the Sketchbook location can be set from preferences in the file menu item). The folder “morse” should be copied directly into the Sketchbook location. (I apologies in case these comments/suggestions are all too trivial and if this does not solve the problem. I just want to be sure (and I also hope) that the problem is not because of a change if file include policy by the framework).

Another thing which will be helpful to diagnose: please check the "Show verbose mode during: compilation" in the preference panel and give me the full output of the compilation. From this it is easier to determine the order of includes.

cheers

Michael

MarcoBlulab commented 9 years ago

Thanks a lot, your suggestion have been really helpful. I try the verbose, there was lot of warnings but no errors about missing files or anything I can debug. I was convinced that all files were in the right place, but I preferred to restart from a fresh installation of the Arduino IDE. After removing all libraries and reinstalling Arduino, I put the files taken from this repository, then I deleted HardwareSerial_USB.cpp and HardwareSerial_USB.h

Now "Morse" is compiled correctly. I don't know what exactly has changed, I only know that now all works correclty.

In the coming days I will do some experiments with the library. Thank you very much! Congratulations for the wonderful job you've done!

MichaelJonker commented 9 years ago

Dear Marco, Thanks for the feedback. I wonder if the problem maybe went away just because you restarted the IDE... This is only a wild hypothesis to be tested, but maybe the IDE has to be restarted after the installation of a new library. Anyway, do not hesitate to share your further experiences and maybe to tell me in what kind of environment you are using (or intending to use) the library. I hope to find some to further devellop the library.

Kind regards Michael

Envoyé depuis mon mobile

-------- Oorspronkelijk bericht -------- Van: MarcoBlulab Datum:2015-05-18 23:21 (GMT+01:00) Aan: MichaelJonker/Arduino_HardwareSerial_RS485 Cc: Michael Jonker Onderwerp: Re: [Arduino_HardwareSerial_RS485] Can't compile in 1.6.4. Any suggestion? (#2)

Thanks a lot, your suggestion have been really helpful. I try the verbose, there was lot of warnings but no errors about missing files or anything I can debug. I was convinced that all files were in the right place, but I preferred to restart from a fresh installation of the Arduino IDE. After removing all libraries and reinstalling Arduino, I put the files taken from this repository, then I deleted HardwareSerial_USB.cpp and HardwareSerial_USB.h

Now "Morse" are built correctly. I don't know what exactly has changed, I only know that now all works correclty.

In the coming days I will do some experiments with the library. Thank you very much! Congratulations for the wonderful job you've done!

— Reply to this email directly or view it on GitHubhttps://github.com/MichaelJonker/Arduino_HardwareSerial_RS485/issues/2#issuecomment-103215706.

MarcoBlulab commented 9 years ago

I'm going to build a small home automation system for my house. The idea is to use RS485 communication between touch buttons on the wall plates near doors (I'm testing Microchip CAP1188 IC for these) and the relay board that will control the lights. If it works then I will develop some extensions to this network, such as the alarm. So small messages but many board connected to the same RS485 bus, I think that the error checking and message collision detection are features that will be extremely useful.

MichaelJonker commented 8 years ago

Hello, you may be interested that I have released a new version of the RS485 support for Arduino, This version, besides being more stable, has also a few new features.

To be compliant with the Arduino Librarian, the repository has been moved to a new place: https://github.com/MichaelJonker/HardwareSerialRS485

Please let me know if you find any problems.

Cheers

M