<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def position(axis, hardware, cp=None):
 """ Read position from driver into a tuple and map 3-rd value to the axis of a pipette currently used """


    if not ff.use_protocol_api_v2():
        p = hardware._driver.position
        return (p['X'], p['Y'], p[axis])
    else:
        p = hardware.gantry_position(axis, critical_point=cp)
        return (p.x, p.y, p.z)