If you have an OBD2 scanner, you could watch the engine speed and the vehicle speed in each gear and derive a ratio of RPM / speed for each gear.
For example my old Jeep 5 speed in 5th gear at 1900 RPM is going 50 MPH. 1900 / 50 = 38, so if my RPM / speed < 40 && > 36, I'm in 5th.
In 4th, with RPM 2700 and speed 50 the ratio is 54 and so on.
Oh, I'm not looking to replace the engine ECU. I'm looking to see what compatible cable I should buy to work with the CAN Shield adapater I linked above.
You're clearly a lot braver and/or automotively savvy than I am. I'd be nervous about interfacing with my 328i's ECU and suspect that's the point @b707 was making?