kmark / Bee

The simple DigiMesh XBee library for Arduino
Other
11 stars 9 forks source link

Compile Error #3

Closed BDK-FPE closed 8 years ago

BDK-FPE commented 8 years ago

Greetings,

I'm attempting to get this up and running using Arduino 1.6.7 and Teensyduino. Upon compile, I am getting the following errors. It appears as though the Serial construct in the library for one reason or another has a different data type that the HardwareSerial core. Do you happen to have any ideas or insight?

Thanks!

C:\Program Files (x86)\Arduino\libraries\Bee\Bee.cpp: In member function 'void Bee::sendData(String)': C:\Program Files (x86)\Arduino\libraries\Bee\Bee.cpp:150:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < sizeof packet; i++) { ^ C:\Program Files (x86)\Arduino\libraries\Bee\Bee.cpp: In member function 'void Bee::write(char, uint16t)': C:\Program Files (x86)\Arduino\libraries\Bee\Bee.cpp:240:27: error: invalid conversion from 'char' to 'const uint8t* {aka const unsigned char}' [-fpermissive] _serial->write(c, size); ^ In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:16:0, from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Arduino.h:1, from C:\Program Files (x86)\Arduino\libraries\Bee\Bee.h:23, from C:\Program Files (x86)\Arduino\libraries\Bee\Bee.cpp:20: C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/HardwareSerial.h:192:17: error: initializing argument 1 of 'virtual size_t HardwareSerial::write(const uint8t, size_t)' [-fpermissive] virtual size_t write(const uint8_t *buffer, size_t size) ^ exit status 1 Error compiling.

My sketch is:

include

void setup() { // put your setup code here, to run once:

}

void loop() { // put your main code here, to run repeatedly:

}

kmark commented 8 years ago

The issue here looks like slight API signature differences between Arduino and Teensy's HardwareSerial. I could refactor Bee to attempt to work with both but I do not have any such devices to test with and so cannot official support the Teensy add-on to Arduino.

I installed the Teensyduino 1.28 beta on top of Arduino 1.6.8 and was able to get Bee compiling with a single addition to Teensy3's HardwareSerial.h:

virtual size_t write(const char *buffer, size_t size) { return write((const uint8_t *)buffer, size); };

Add that to hardware/teensy/avr/cores/teensy3/HardwareSerial.h after line 204 (just above write9bit). It's not particularly important exactly where as long as it's within the public section of the HardwareSerial class definition. I don't think you'll need to repeat this for HardwareSerial2 and HardwareSerial3 since they are subclasses of HardwareSerial.

Let me know if this works for you. I'm not sure what the project goals of Teensyduino are but if API compatibility is one then I'd say this is a bug with it, not Bee.

BDK-FPE commented 8 years ago

Greetings Kevin,

Thanks - this was very helpful. It now compiles just fine in the IDE. I get hardware later this week and will verify functionality - I was getting a jump start on software in advance.

I'll also bring this up on PJRC.com - it does seem to be a difference/anomaly with Teensyduino and the different HardwareSerial definition.

Thanks again for the help - much appreciated.

kmark commented 8 years ago

My pleasure. I'll keep this open until you have a chance to test it on real hardware.

BDK-FPE commented 8 years ago

Hi Kevin,

I verified that this works on real hardware and I can now send out packets. Unrelated to this, however, when I receive an 0x91 Explicit RX Indicator frame, my Teensy locks up. I was able to narrow it down to where it locks up; it happens in Bee.cpp where, when processing frames, it uses the builtin_bswap64 function [pointerFrame.source64 = builtin_bswap64(pointerFrame.source64);]. It looks like this is a problem specifically with Teensy hardware wherein it doesn't know or can't perform that specific function. I googled it , and it looks like one other person has also seen the issue in May of 2015, but no responses/comments on it on the Teensy Forum. https://forum.pjrc.com/threads/29504-_builtin_bswap64-problem

I'm going to dig a little deeper and either write a custom bitswap function or get to the bottom of it. Then I should be able to receive frames.

The library is working great otherwise; thanks much! It has been helpful.

Brian

kmark commented 8 years ago

Glad this is useful for you! I'll close this up. Let's create a separate bug report for Teensy related issues feel free to just copy and paste your above post.