PDA

View Full Version : Help porting library



cmat1120
12-27-2012, 07:25 PM
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

PaulStoffregen
12-28-2012, 03:00 AM
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/

PaulStoffregen
06-09-2014, 11:46 PM
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.

Today I ported the ShiftPWM library to Teensy 3.0 & 3.1.

http://www.pjrc.com/teensy/td_libs_ShiftPWM.html
https://github.com/PaulStoffregen/ShiftPWM

If anyone is still watching this old thread, it works now. :)

kcnypmeknaj
02-25-2017, 10:55 AM
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" (https://github.com/stanleyhuangyc/ArduinoOBD/tree/master/libraries/OBD/examples/rpm_led_i2c)
using obd.h (https://github.com/stanleyhuangyc/ArduinoOBD/blob/master/libraries/OBD/OBD.h) & obd.cpp (https://github.com/stanleyhuangyc/ArduinoOBD/blob/master/libraries/OBD/OBD.h) all downloaded from the original Github from stanleyhuangyc.

Here are the faults in attachment.

kcnypmeknaj
03-05-2017, 12:21 PM
Hello,

I solved my problem by combining FEXcan.h with a TI SN65HVD231 CAN transceiver (3.3V) and a Teensy 3.2 board.