Help porting library

Status
Not open for further replies.

cmat1120

New member
I could use some help making an arduino library compatible with the teensy 3.0. I tried just compiling the library I want to use and the arduino library on a bare minimum sketch and got a few errors:

E:\Clayton\Arduino\arduino-1.0.2\libraries\OBD\OBD.cpp: In member function 'void COBD::Query(unsigned char)':
E:\Clayton\Arduino\arduino-1.0.2\libraries\OBD\OBD.cpp:70: error: 'sprintf_P' was not declared in this scope
E:\Clayton\Arduino\arduino-1.0.2\libraries\OBD\OBD.cpp: In member function 'virtual char* COBD::GetResponse(byte, char*)':
E:\Clayton\Arduino\arduino-1.0.2\libraries\OBD\OBD.cpp:130: error: 'strstr_P' was not declared in this scope
E:\Clayton\Arduino\arduino-1.0.2\libraries\OBD\OBD.cpp:145: error: 'strstr_P' was not declared in this scope
E:\Clayton\Arduino\arduino-1.0.2\libraries\OBD\OBD.cpp: In member function 'bool COBD::Init(bool)':
E:\Clayton\Arduino\arduino-1.0.2\libraries\OBD\OBD.cpp:262: error: 'strstr_P' was not declared in this scope

I am using the arduino ide posted on your kickstarter page for teensy 3.0 and it does compile fine for arduino boards. If there is any other info you need please ask.

library as well as example files can be found at: http://sourceforge.net/projects/obdcon/files/arduino-obd-library-20121201.zip/download

also is there any pwm libraries that support shift registers(or vice-versa)? I want to use ShiftPWM, but it seems to be incompatible with teensy as well. ShiftPwm can be found at: http://www.elcojacobs.com/shiftpwm/ if you want an example of what I'm looking for.

Thank you,
Clayton
 
I looked at OBD briefly, and found 3 issues.

#1 - OBD.h was missing #include "Arduino.h", so the byte type was undefined. Maybe you already fixed that?

#2 - hardware/teensy/cores/teensy3/avr/pgmspace.h is missing these lines:

#define strstr_P(a, b) strstr((a), (b))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)

Just add these to pgmspace.h to fix the compile errors. I've added them here, so they'll be in future releases.

#3 - OBD.h defaults to Serial, with this line:

#ifndef OBDUART
#define OBDUART Serial
#endif

You'll need to edit that to Serial1, Serial2 or Serial3, since Serial on Teensy is USB virtual serial to your PC.

Ideally, libraries like ODB should have a begin(Stream) function that lets you set which port to use. Arduino Uno has only 1 port, but pretty much everything else has multiple ports. Even on Uno, a begin(Stream) allows using SoftwareSerial or AltSoftSerial. Maybe Stanley would consider adding it? The XBee 0.4 library has an example of how to do this.

http://code.google.com/p/xbee-arduino/
 
Problems compiling obd.h / obd.cpp for Teensy 3.2

Hello Paul,

I have also compiling problems trying to compile a basic sketch for Teensy 3.2 to be able touse the Freematics OBDII I2C interface.
The sketch compiled and worked well on an Arduino compatible board. But when I want to compile it for a Teensy 3.2, there are a lot of faults in obd.cpp.
Just tried to compile the easiest program to start from
"rpm_led_i2c"
using obd.h & obd.cpp all downloaded from the original Github from stanleyhuangyc.

Here are the faults in attachment.
 

Attachments

  • OBDcpp faults_Teensy32.txt
    12.5 KB · Views: 149
Status
Not open for further replies.
Back
Top