/** * <summary> * Initializes the Yoctopuce programming library explicitly. * <para> * It is not strictly needed to call <c>yInitAPI()</c>, as the library is * automatically initialized when calling <c>yRegisterHub()</c> for the * first time. * </para> * <para> * When <c>YAPI.DETECT_NONE</c> is used as detection <c>mode</c>, * you must explicitly use <c>yRegisterHub()</c> to point the API to the * VirtualHub on which your devices are connected before trying to access them. * </para> * </summary> * <param name="mode"> * an integer corresponding to the type of automatic * device detection to use. Possible values are * <c>YAPI.DETECT_NONE</c>, <c>YAPI.DETECT_USB</c>, <c>YAPI.DETECT_NET</c>, * and <c>YAPI.DETECT_ALL</c>. * </param> * <param name="errmsg"> * a string passed by reference to receive any error message. * </param> * <returns> * <c>YAPI.SUCCESS</c> when the call succeeds. * </returns> * <para> * On failure, throws an exception or returns a negative error code. * </para> */ public static async Task <int> InitAPI(int mode, YRefParam errmsg) { YAPIContext yctx = imm_GetYCtx(); try { return(await yctx.InitAPI(mode)); } catch (YAPI_Exception ex) { errmsg.Value = ex.Message; return(ex.errorType); } }
/** * <summary> * Initializes the Yoctopuce programming library explicitly. * <para> * It is not strictly needed to call <c>yInitAPI()</c>, as the library is * automatically initialized when calling <c>yRegisterHub()</c> for the * first time. * </para> * <para> * When <c>YAPI.DETECT_NONE</c> is used as detection <c>mode</c>, * you must explicitly use <c>yRegisterHub()</c> to point the API to the * VirtualHub on which your devices are connected before trying to access them. * </para> * </summary> * <param name="mode"> * an integer corresponding to the type of automatic * device detection to use. Possible values are * <c>YAPI.DETECT_NONE</c>, <c>YAPI.DETECT_USB</c>, <c>YAPI.DETECT_NET</c>, * and <c>YAPI.DETECT_ALL</c>. * </param> * <param name="errmsg"> * a string passed by reference to receive any error message. * </param> * <returns> * <c>YAPI.SUCCESS</c> when the call succeeds. * </returns> * <para> * On failure, throws an exception or returns a negative error code. * </para> */ public static async Task <int> InitAPI(int mode) { YAPIContext yctx = imm_GetYCtx(); return(await yctx.InitAPI(mode)); }