Community
OpenEnergyMonitor

Community

Arduino Errors trying to compile old firmware


(ian) #1

Hi

I need to make a minor change to firmware that I have on an old emonTX. I note the original file date was 2012.
First thing I did was to try and compile the original file before I make changes.

This produce some errors.

Back in 2012 I probably used an older jeelib library than that currently installed which is from [email protected]:openenergymonitor/jeelib.git.
My guess is that changes to Arduino are causing the problem and not the library but I do not have the knowledge to work out the fix.

Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"
In file included from D:\MicroProcessors\ArduinoCode\libraries\jeelibstable/JeeLib.h:18:0,
from D:\MicroProcessors\ArduinoCode\MyEmontTX\MyEmontTX.ino:36:

D:\MicroProcessors\ArduinoCode\libraries\jeelibstable/RF12.h:56:25: error: expected ',' or '...' before numeric constant

 #define RF12_433MHZ     1   ///< RFM12B 433 MHz frequency band.
                         ^
D:\MicroProcessors\ArduinoCode\MyEmontTX\MyEmontTX.ino:29:14: note: in expansion of macro 'RF12_433MHZ'
 #define freq RF12_433MHZ                                              // frequency - match to same frequency as RFM12B module (change to 868Mhz or 915Mhz if appropriate)
              ^
D:\MicroProcessors\ArduinoCode\libraries\jeelibstable/RF69.h:10:33: note: in expansion of macro 'freq'
     void setFrequency (uint32_t freq);
                                 ^

Any help would be much appreciated.

Ian


(Robert Wall) #2

I have an emonTx V2 that I use for testing/debugging (because there’s a lot of I/O pins I can hang a 'scope on), and I don’t have a problem. Which sketch are you trying to compile?

The “freq” error is a naming conflict - I can’t remember the details now.

(EmonLibCM runs on a V2, when you define the I/O pins - that’s what I last used mine for.)

[Edit]
Looking at my copy of emonTx_CT123_Voltage.ino and comparing it against the Git version. I have
#define FREQ RF12_433MHZ whereas the “official” Git version is #define RF_freq RF12_433MHZ
The conflict (IIRC) was there - the normal convention is to use CAPITALS in pre-processor substitutions, but G&T have never respected that, and that’s the likely source of the trouble. But if you tell me the sketch (or post it), I’ll take a look.


(ian) #3

Thank you Robert

The file is a very early one from Glyn and Tristan so hard to identify. Plus I hacked it by trial and error to monitor a pin to check a boiler state. I am not even sure of the emonTx version, I have not pulled it out of service yet. It is very early. As I say the file I modded in 2012.

Therefore I attach the complete directory.
MyEmontTX.zip (3.7 KB)


(Robert Wall) #4

That’s apparently all it was…
I’ve replaced freq with FREQ in lines 29 & 97

#define FREQ RF12_433MHZ   

    rf12_initialize(10, FREQ,210); 

and it compiles for me (with a warning - normal - that “‘prog_uint8_t’ is deprecated”) and transmits 14 bytes:
00 00 00 00 64 ce 64 ce 64 ce 64 ce 18 00

64 ce = -12700, so it doesn’t look far wrong.

I can’t test the RTC part, nor (I presume) the connected display.


(ian) #5

Thank you.

I don’t think I would have worked that out on my own.

Now compiles without error.


(Lee) #6

I had this a while back, if you change the ‘freq’ to something else, like ‘frequ’, it’ll compile just fine.


(Paul) #7

That could explain why there was an apparent shift from using freq to using RF_freq in the various older sketches.


(Robert Wall) #8

That’s right. IIRC, JeeLib changed internally to use “freq”. (I don’t know what it was originally.) OEM has previously used “freq” in a pre-processor substitution for the (integer) value that’s eventually used to select the numbers to load into the RFM registers. This is despite the convention that all such names should be UPPERCASE. The replacement text need not be upper case, but in our case the replacement text RF12_433MHZ is itself the subject of a substitution in RF12.h:
#define RF12_433MHZ 1 ///< RFM12B 433 MHz frequency band.

It would be quite in order, though obscure, to write:
rf12_initialize(8, 1, 210);

The reason why I recommended using FREQ was to stay with convention, so everybody knows it’s not a normal variable.