Added getIODeviceById function with appropriate error handling