austinbv / dino

Dino is a ruby gem that helps you bootstrap prototyping with an Arduino
MIT License
388 stars 84 forks source link

failing attempt to bring SoftwareSerial to dino #52

Closed cdcarter closed 11 years ago

cdcarter commented 11 years ago

I'm trying to bring SoftwareSerial support to Dino (to eventually support the AdaFruit Thermal printer). I have a pretty good handle on what is going on on the ruby side of the code, and I think I have structured this addition in the proper way. However, it won't compile, for what I imagine is just a basic C++ issue I don't understand. I'm including the code, but the error occurs when trying to reassign the serial object to a new one once setPins is called.

DinoSerial.cpp.o:(.bss.serial+0x0): multiple definition of `serial'
dino_serial.cpp.o:(.bss.serial+0x0): first defined here
/Users/cdcarter/Downloads/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld: Warning: size of symbol `serial' changed from 34 in dino_serial.cpp.o to 28 in DinoSerial.cpp.o

I realize a pull request isn't the best way to get this on someones radar, but I'd love to try and figure out how to get basic SoftwareSerial support into the Arduino half of the equation, and I'm happy to hack away on the ruby side to get communication flowing both ways and a printer connected!

Email or Twitter for conversation!

cdcarter commented 11 years ago

Whoops, total rookie mistake. Totally ignore this concern, because I was way off base in my debugging. I'll be back.

vickash commented 11 years ago

Your methodology for the Arduino code is spot on, but as of the latest commit to the 0.12.0 branch serial is a global variable pointing to whichever serial connection is talking to the computer. I did this to DRY up some code for boards with multiple serial connections, like the Mega and Due.

Changing serial inside DinoSerial.cpp to something else (maybe softwareSerial) should do the trick.

vickash commented 11 years ago

I really like this idea, and that printer. Does it just need write support? Writing is straightforward, but reading will require something like the digital and analog listeners in the Arduino code. Follow that pattern if you want to try it. If not, do the write stuff and I'll handle the Arduino code for reading.

cdcarter commented 11 years ago

You got it, that was the mistake I was making. About to put together a pull request with the writing (works fine for me now, but haven't automated the testing yet). Hopefully tomorrow I'll find some time to dig through the reading. The printer only requires write support, but it can't hurt to have a fully usable SoftwareSerial implementation.