markkimsal / homesecurity

VISTA ICM replacement: Adruino firmware for Honeywell / Ademco Vista series security panels
https://alarmtool.com/
51 stars 24 forks source link

Basic Compilation with Static Ethernet Doesn't Work #2

Closed chisaipete closed 11 years ago

chisaipete commented 11 years ago

I'm intending to create an Ethernet interface to monitor my Vista keypad bus, so I have an Arduino, protoshield with the keypad bus interface circuit, and an Arduino Ethernet Shield stacked. I've loaded a bootloader which allows me to flash sketches over Ethernet to enable making tweaks after I get the Arduino stack installed in the alarm box. Due to this sketch, I have the stack setup with a static IP and a set MAC address--from browsing the code, it doesn't seem like this will be too much of an issue to deal with. Ultimately, I'd like to expand the functionality of your code to send useful packets to a python home automation/security server box as well as be able to send commands to the keypad bus from the server. I'm currently trying to test the sketch before I install the Arduino stack in my Alarm box.

I cloned your repository to my machine, compiled the vanilla pull with Arduino 1.0.2 just fine by commenting out #include "out_wire.h" (it was throwing an error). I uploaded it to my Arduino + Ethernet shield and got it to spit out the correct stuff over serial. I went back and enabled the options in config.h to have static Ethernet, but now I'm getting a mystifying compiler error:

C:\arduino\arduino-1.0.2\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=102 -IC:\arduino\arduino-1.0.2\hardware\arduino\cores\arduino -IC:\arduino\arduino-1.0.2\hardware\arduino\variants\standard -IC:\arduino\arduino-1.0.2\libraries\Ethernet -IC:\arduino\arduino-1.0.2\libraries\SPI C:\Users\Connor\AppData\Local\Temp\build7707458059609855084.tmp\alta_veesta.cpp -o C:\Users\Connor\AppData\Local\Temp\build7707458059609855084.tmp\alta_veesta.cpp.o alta_veesta.ino: In function 'void on_status(char*, int*)': alta_veesta.ino:318: warning: unused variable 'bypass' alta_veesta.ino: In function 'void loop()': alta_veesta.ino:581: warning: comparison between signed and unsigned integer expressions alta_veesta.ino:592: warning: comparison between signed and unsigned integer expressions alta_veesta.ino:605: warning: comparison between signed and unsigned integer expressions alta_veesta.ino: In function 'void setup()': alta_veesta:665: error: expected primary-expression before '{' token

Any guidance would be appreciated!

chisaipete commented 11 years ago

Okay, so update: I grabbed a fresh copy of the sources and it seems to have compiled after a few changes:

In config.h I changed #define TX_PIN 8 to #define TX_PIN 7 (due to my hardware implementation) In config.h I changed the MAC address to match the address in my Ethernet Shield. In alta_veesta.ino I had missing open parentheses on lines 409, 416, 426, 429, 432

Then I kept getting: alta_veesta.ino:41:22: error: out_wire.h: No such file or directory so I commented out //#include "out_wire.h" on line 41 of alta_veesta.ino

Then: C:\Users\cmpeter1\AppData\Local\Temp/ccN810Uu.s: Assembler messages: C:\Users\cmpeter1\AppData\Local\Temp/ccN810Uu.s:243: Error: register r24, r26, r28 or r30 required C:\Users\cmpeter1\AppData\Local\Temp/ccN810Uu.s:263: Error: register r24, r26, r28 or r30 required

After some research I figured out that it is probably an issue in the SoftwareSerial2.cpp library with the inline assembly call tunedDelay. I changed line 169 from : "+r" (delay), "+a" (tmp) to : "+w" (delay), "+a" (tmp)

Now it compiles, but no Ethernet goodness.

To enable Ethernet connectivity I uncommented the #define STATIC_IP in config.h and modified it to match my setup, and then uncommented #define HAVE_NETWORK 1 to enable network setup in the setup() loop.

Then, I tried compiling and I'm back to my old friend:

alta_veesta.ino: In function 'void setup()': alta_veesta:658: error: expected primary-expression before '{' token

This line is: Ethernet.begin(mac, STATIC_IP);

Any ideas? The verbose compiler output is:

C:\arduino-1.0.3\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=103 -IC:\arduino-1.0.3\hardware\arduino\cores\arduino -IC:\arduino-1.0.3\hardware\arduino\variants\standard -IC:\arduino-1.0.3\libraries\Ethernet -IC:\arduino-1.0.3\libraries\SPI C:\Users\cmpeter1\AppData\Local\Temp\build4775935734202444592.tmp\alta_veesta.cpp -o C:\Users\cmpeter1\AppData\Local\Temp\build4775935734202444592.tmp\alta_veesta.cpp.o alta_veesta.ino: In function 'void on_status(char*, int*)': alta_veesta.ino:310: warning: unused variable 'bypass' alta_veesta.ino: In function 'void loop()': alta_veesta.ino:573: warning: comparison between signed and unsigned integer expressions alta_veesta.ino:584: warning: comparison between signed and unsigned integer expressions alta_veesta.ino:597: warning: comparison between signed and unsigned integer expressions alta_veesta.ino: In function 'void setup()': alta_veesta:658: error: expected primary-expression before '{' token

I'm kind of a github n00b, so if there was an easier way to show my changes, I'd be happy to do it: maybe make a branch with my changes and upload it for your review? Not sure.

markkimsal commented 11 years ago

Can you check out the branch "green_wire"? I must've leaked some C files back into the master branch for outbound communication.

Are you using the make file Makefile.mk ? If not you need to specify the Ethernet libraries in your compilation step. If you're using Eclipse, this might help: http://stackoverflow.com/questions/7422841/using-arduino-ethernet-h-under-eclipse

But, it doesn't sound like the Ethernet library is missing. What version of arduino or avr-gcc are you using to compile this? What sort of environment? Also, try the green_wire branch as it has been getting more attention lately.

markkimsal commented 11 years ago

You know, after all those missing open parenthesis, there's probably another syntax error somewhere. Maybe the nested #ifdefs dont' work? You can probably just cut out the #ifdefs and the #elses and #endifs and just leave the code you want (ethernet enabled, static ip).

Also, what is the exact line in config.h for #define STATIC_IP ?

markkimsal commented 11 years ago

I just checked out the master branch, fixed the syntax errors you reported, and I could compile with STATIC_IP and HAVE_NETWORK . Make sure STATIC_IP is defined like

#define STATIC_IP {192, 168, 1, 80}

otherwise, there will be a compilation error after the preprocessor replaces the define.

chisaipete commented 11 years ago

Thanks for getting back to me, I've been hacking away at the code over the weekend and oblivious to github, I didn't get these messages till just now. :( I basically commented out most of the code and began re-adding features until they broke, fixing them and moving on. I have a compiled, working version which streams the Serial output text over an Ethernet socket to my remote server. I'm using Arduino 1.0.2 to compile right now (latest looks like 1.0.3 or the 1.0.5 beta).

I'll have to try pulling your changes and recompiling this evening after work. Should I grab the green_wire or master branch to work from? I'd like to have outbound communication capability in the future, but I should probably deal with one thing at a time.

I'd be happy to prettify my changes (Ethernet socket communication instead of Serial/USB) and push them to a branch if you are interested.

markkimsal commented 11 years ago

The only changes I made where the missing parenthesis. I can compile the master branch just fine. I'm guessing that, if there are still compilation syntax errors, there is a problem with the definition of STATIC_IP in the config.h file.

Ethernet communication of the status is interesting. Is the device acting like a server or a client?

You can continue to work on the master branch as the green_wire will be merged in when it's finished.

If you want me to take your changes you should "fork" the project on github, checkout your own fork, make a topic branch, copy your changes into that checkout, then work and push until the feature is ready, then you can make a pull request and I'll pull it in.

https://help.github.com/articles/using-pull-requests