/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Closes the port. /// /// </summary> /// <history> /// 07 Mar 19 Cynic - Originally written /// </history> public override void ClosePort() { string outfileName = BBBDefinitions.PWM_FILENAME_UNEXPORT.Replace("%chipNum%", ConvertPWMPortEnumToChipNumber(PWMPort).ToString()).Replace("%deviceNum%", ConvertPWMPortEnumToDeviceNumber(PWMPort).ToString()); Console.WriteLine("PWMPort Port Closing: " + outfileName + ", " + ConvertPWMPortEnumToDeviceNumber(PWMPort).ToString()); // do the unexport System.IO.File.WriteAllText(outfileName, ConvertPWMPortEnumToDeviceNumber(PWMPort).ToString()); portIsOpen = false; // the act of writing the PortExportNumber to the unexport file // will remove the directory /sys/class/pwm/pwm<PortExportNumber>: Console.WriteLine("PWMPort Port Closed: " + PWMPort.ToString()); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Opens the port. Throws an exception on failure /// /// </summary> /// <history> /// 07 Mar 19 Cynic - Originally written /// </history> protected override void OpenPort() { string outfileName = BBBDefinitions.PWM_FILENAME_EXPORT.Replace("%chipNum%", ConvertPWMPortEnumToChipNumber(PWMPort).ToString()).Replace("%deviceNum%", ConvertPWMPortEnumToDeviceNumber(PWMPort).ToString()); Console.WriteLine("PWMPort Port Opening: " + outfileName + ", " + ConvertPWMPortEnumToDeviceNumber(PWMPort).ToString()); // do the export System.IO.File.WriteAllText(outfileName, ConvertPWMPortEnumToDeviceNumber(PWMPort).ToString()); portIsOpen = true; // the act of writing the PortExportNumber to the export file // will create a directory /sys/class/pwm/pwm<PortExportNumber> // This directory contains files which we can use to enable the PWM // and set the pulse widths etc Console.WriteLine("PWMPort Port Opened: " + PWMPort.ToString()); }