Get current gear from rpm and speed through OBD2
First identify the protocol your car is using is it CAN,KWP,J1850 etc. Buy this sparkfun board or build one so that you can communicate with ECU of any above protocol

https://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide

RPM

To obtain RPM you have to give 01 0C
Refer this link for conversion formula of obtained raw data to required value
http://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_01

Current gear

Gear is a proprietary PID so it wont be available from standard PIDs you need the companys PID list.
Else just add only gear app in torque.Then use an OBD splitter cable log the data (request and response) passing to ECU byt torque app and identify the PID.
But you have to figure out the conversion formulas by your own.