/// <summary> /// Write configuration message and wait for the transmission to complete without caring about /// it being acknowledge or not. /// </summary> /// <param name="data">Communication message to be transmitted</param> /// <returns>Task represent the WriteConfigIgnoreResultAsync execution</returns> public async Task WriteConfigIgnoreResultAsync(UBXModelBase data) { if (!UBXModelBase.IsConfigMessage(data)) { throw new NotSupportedException("WriteConfig only available for config type UBX message"); } var notifyToken = new CancellationTokenSource(); // Register to wait for transmission this.transmissionNotification.Add(data, notifyToken); // Put in queue TransmitMessage(data); // Wait until the message is transmitted try { await Task.Delay(-1, notifyToken.Token); } catch (TaskCanceledException) { } // Remove from notification list this.transmissionNotification.Remove(data); }
/// <summary> /// Write configuration message to the device and wait until acknowledge or not-acknowledge message /// arrived /// </summary> /// <param name="data">Communication message to be transmitted </param> /// <returns> /// Task represents the WriteConfigAsync execution, which upon completion returns boolean where /// true means the configuration is acknowledged, and false otherwise. /// </returns> public async Task <bool> WriteConfigAsync(UBXModelBase data) { if (!UBXModelBase.IsConfigMessage(data)) { throw new NotSupportedException("WriteConfig only available for config type UBX message"); } TransmitMessage(data); var attr = UBXModelBase.GetMessageAttribute(data); return(await expectingList.ExpectAcknowledgeAsync(attr.ClassID, attr.MessageID)); }