protected override void OnInitialize() { //First check if the pin has already been exported if (!FileUtils.DirectoryExists($"/sys/class/gpio/gpio{this.NumberText}")) { FileUtils.AppendText(LinuxPinController.ExportFilePath, NumberText); } var directionFilePath = $"/sys/class/gpio/gpio{this.NumberText}/direction"; FileUtils.AppendText(directionFilePath, LinuxPinController.InputDirectionValue); }
protected override void OnInitialize() { //First check if the pin has already been exported if (FileUtils.DirectoryExists($"/sys/class/gpio/gpio{this.NumberText}")) { Logger.LogInfo(() => $"GPIO {NumberText} already being exported. Will not export it."); } else { Logger.LogInfo(() => $"Setting up GPIO {NumberText} for export"); FileUtils.AppendText(LinuxPinController.ExportFilePath, NumberText); } var directionFilePath = $"/sys/class/gpio/gpio{this.NumberText}/direction"; FileUtils.AppendText(directionFilePath, LinuxPinController.InputDirectionValue); }
public static void AppendErrorLogs(string filePath, List <TextLogInfo> logs) { if (logs == null || logs.Count <= 0) { return; } if (!FileUtils.IsFileExists(filePath)) { FileUtils.WriteText(filePath, Encoding.UTF8, string.Empty); } var builder = new StringBuilder(); foreach (var log in logs) { builder.AppendLine(); builder.Append(log); builder.AppendLine(); } FileUtils.AppendText(filePath, Encoding.UTF8, builder.ToString()); }