diff --git a/CommonControls/BaseForm.cs b/CommonControls/BaseForm.cs index f07f440..1fc9d1e 100644 --- a/CommonControls/BaseForm.cs +++ b/CommonControls/BaseForm.cs @@ -7,7 +7,9 @@ using System.Net; using System.Net.Sockets; using System.Text; +using System.Threading.Tasks; using System.Windows.Forms; +using static System.Windows.Forms.LinkLabel; namespace Modbus.Common { @@ -597,6 +599,25 @@ private void buttonPauseLog_Click(object sender, EventArgs e) buttonPauseLog.Text = _logPaused ? "Resume" : "Pause"; } + private async void buttonSaveLog_ClickAsync(object sender, EventArgs e) + { + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.FileName = "ModbusLog"; + saveFileDialog.OverwritePrompt = true; + saveFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; + saveFileDialog.DefaultExt = "txt"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + using (StreamWriter writer = new StreamWriter(saveFileDialog.FileName, append: true)) + { + foreach (string line in listBoxCommLog.Items) + { + await writer.WriteLineAsync(line); + } + } + } + } + protected void DriverIncommingData(byte[] data, int len) { if (_logPaused) @@ -632,7 +653,7 @@ protected void AppendLog(String log) var tmpStr = ">" + now.ToLongTimeString() + ": " + log; listBoxCommLog.Items.Add(tmpStr); listBoxCommLog.SelectedIndex = listBoxCommLog.Items.Count - 1; - listBoxCommLog.SelectedIndex = -1; + //listBoxCommLog.SelectedIndex = -1; } #endregion @@ -734,8 +755,9 @@ void dataTab_OnApply(object sender, EventArgs e) private void donate_Click(object sender, EventArgs e) { - string url = "https://paypal.me/classicdiy?country.x=CA&locale.x=en_US"; + string url = "https://www.buymeacoffee.com/r4K2HIB"; System.Diagnostics.Process.Start(url); } + } } diff --git a/CommonControls/BaseForm.designer.cs b/CommonControls/BaseForm.designer.cs index 05efa5c..c7c7e22 100644 --- a/CommonControls/BaseForm.designer.cs +++ b/CommonControls/BaseForm.designer.cs @@ -32,6 +32,7 @@ protected void InitializeComponent() Modbus.Common.DataTab dataTab2; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BaseForm)); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.buttonSave = new System.Windows.Forms.Button(); this.buttonPauseLog = new System.Windows.Forms.Button(); this.listBoxCommLog = new System.Windows.Forms.ListBox(); this.buttonClear = new System.Windows.Forms.Button(); @@ -89,8 +90,34 @@ protected void InitializeComponent() this.tabPage2.SuspendLayout(); this.SuspendLayout(); // + // dataTab1 + // + dataTab1.DataLength = ((ushort)(127)); + dataTab1.DisplayFormat = Modbus.Common.DisplayFormat.Integer; + dataTab1.Location = new System.Drawing.Point(3, 3); + dataTab1.Name = "dataTab1"; + dataTab1.RegisterData = new ushort[0]; + dataTab1.ShowDataLength = false; + dataTab1.Size = new System.Drawing.Size(839, 406); + dataTab1.StartAddress = ((ushort)(4100)); + dataTab1.TabIndex = 0; + // + // dataTab2 + // + dataTab2.DataLength = ((ushort)(127)); + dataTab2.DisplayFormat = Modbus.Common.DisplayFormat.LED; + dataTab2.Location = new System.Drawing.Point(3, 3); + dataTab2.Name = "dataTab2"; + dataTab2.RegisterData = new ushort[] { + ((ushort)(0))}; + dataTab2.ShowDataLength = false; + dataTab2.Size = new System.Drawing.Size(839, 406); + dataTab2.StartAddress = ((ushort)(4100)); + dataTab2.TabIndex = 0; + // // groupBox4 // + this.groupBox4.Controls.Add(this.buttonSave); this.groupBox4.Controls.Add(this.buttonPauseLog); this.groupBox4.Controls.Add(this.listBoxCommLog); this.groupBox4.Controls.Add(this.buttonClear); @@ -101,9 +128,18 @@ protected void InitializeComponent() this.groupBox4.TabStop = false; this.groupBox4.Text = "Communication Log"; // + // buttonSave + // + this.buttonSave.Location = new System.Drawing.Point(760, 19); + this.buttonSave.Name = "buttonSave"; + this.buttonSave.Size = new System.Drawing.Size(86, 28); + this.buttonSave.TabIndex = 26; + this.buttonSave.Text = "Save"; + this.buttonSave.Click += new System.EventHandler(this.buttonSaveLog_ClickAsync); + // // buttonPauseLog // - this.buttonPauseLog.Location = new System.Drawing.Point(660, 19); + this.buttonPauseLog.Location = new System.Drawing.Point(576, 19); this.buttonPauseLog.Name = "buttonPauseLog"; this.buttonPauseLog.Size = new System.Drawing.Size(86, 28); this.buttonPauseLog.TabIndex = 25; @@ -123,7 +159,7 @@ protected void InitializeComponent() // // buttonClear // - this.buttonClear.Location = new System.Drawing.Point(752, 19); + this.buttonClear.Location = new System.Drawing.Point(668, 19); this.buttonClear.Name = "buttonClear"; this.buttonClear.Size = new System.Drawing.Size(86, 28); this.buttonClear.TabIndex = 24; @@ -514,7 +550,7 @@ protected void InitializeComponent() // // donate // - this.donate.Image = global::Modbus.Common.Properties.Resources.btn_donateCC_LG; + this.donate.Image = global::Modbus.Common.Properties.Resources.default_yellowS2; this.donate.Location = new System.Drawing.Point(691, 77); this.donate.Name = "donate"; this.donate.Size = new System.Drawing.Size(154, 61); @@ -546,18 +582,6 @@ protected void InitializeComponent() this.tabPage1.Text = "Address1"; this.tabPage1.UseVisualStyleBackColor = true; // - // dataTab1 - // - dataTab1.DataLength = ((ushort)(127)); - dataTab1.DisplayFormat = Modbus.Common.DisplayFormat.Integer; - dataTab1.Location = new System.Drawing.Point(3, 3); - dataTab1.Name = "dataTab1"; - dataTab1.RegisterData = new ushort[0]; - dataTab1.ShowDataLength = false; - dataTab1.Size = new System.Drawing.Size(839, 406); - dataTab1.StartAddress = ((ushort)(4100)); - dataTab1.TabIndex = 0; - // // tabPage2 // this.tabPage2.Controls.Add(dataTab2); @@ -569,19 +593,6 @@ protected void InitializeComponent() this.tabPage2.Text = "..."; this.tabPage2.UseVisualStyleBackColor = true; // - // dataTab2 - // - dataTab2.DataLength = ((ushort)(127)); - dataTab2.DisplayFormat = Modbus.Common.DisplayFormat.LED; - dataTab2.Location = new System.Drawing.Point(3, 3); - dataTab2.Name = "dataTab2"; - dataTab2.RegisterData = new ushort[] { - ((ushort)(0))}; - dataTab2.ShowDataLength = false; - dataTab2.Size = new System.Drawing.Size(839, 406); - dataTab2.StartAddress = ((ushort)(4100)); - dataTab2.TabIndex = 0; - // // BaseForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -662,5 +673,6 @@ protected void InitializeComponent() private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.Button donate; + protected System.Windows.Forms.Button buttonSave; } } \ No newline at end of file diff --git a/CommonControls/BaseForm.resx b/CommonControls/BaseForm.resx index 6cd4879..0568b09 100644 --- a/CommonControls/BaseForm.resx +++ b/CommonControls/BaseForm.resx @@ -117,18 +117,18 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - - - 157, 17 - False False + + 17, 17 + + + 157, 17 + diff --git a/CommonControls/Modbus.Common.csproj b/CommonControls/Modbus.Common.csproj index fe47681..5336f76 100644 --- a/CommonControls/Modbus.Common.csproj +++ b/CommonControls/Modbus.Common.csproj @@ -10,7 +10,7 @@ Properties Modbus.Common Modbus.Common - v4.5.2 + v4.8 512 @@ -103,6 +103,9 @@ + + + - \ No newline at end of file + diff --git a/ModbusSlave/Properties/AssemblyInfo.cs b/ModbusSlave/Properties/AssemblyInfo.cs index 3a9715c..5b0e8db 100644 --- a/ModbusSlave/Properties/AssemblyInfo.cs +++ b/ModbusSlave/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.3.0")] -[assembly: AssemblyFileVersion("2.0.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.1.3.0")] +[assembly: AssemblyFileVersion("2.1.3.0")] \ No newline at end of file diff --git a/ModbusSlave/SlaveForm.Designer.cs b/ModbusSlave/SlaveForm.Designer.cs index a8a173c..c669006 100644 --- a/ModbusSlave/SlaveForm.Designer.cs +++ b/ModbusSlave/SlaveForm.Designer.cs @@ -36,6 +36,10 @@ private void InitializeComponent() this.grpExchange.SuspendLayout(); this.SuspendLayout(); // + // grpStart + // + this.grpStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left))); + // // label8 // this.label8.Visible = false; @@ -65,7 +69,8 @@ private void InitializeComponent() // SlaveForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.ClientSize = new System.Drawing.Size(869, 887); + this.AutoScroll = true; + this.ClientSize = new System.Drawing.Size(869, 896); this.Controls.Add(this.buttonDisconnect); this.Controls.Add(this.btnConnect); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); diff --git a/ModbusSlave/SlaveForm.cs b/ModbusSlave/SlaveForm.cs index 7542ff2..4873e66 100644 --- a/ModbusSlave/SlaveForm.cs +++ b/ModbusSlave/SlaveForm.cs @@ -154,6 +154,13 @@ private void DoDisconnect() _uart.Dispose(); _uart = null; } + + if (_socket != null) + { + _socket.Dispose(); + _socket = null; + } + if (_thread != null && _thread.IsAlive) { if (_thread.Join(2000) == false) @@ -162,11 +169,6 @@ private void DoDisconnect() _thread = null; } } - if (_socket != null) - { - _socket.Dispose(); - _socket = null; - } } #endregion diff --git a/ModbusSlave/app.config b/ModbusSlave/app.config index de82893..786a845 100644 --- a/ModbusSlave/app.config +++ b/ModbusSlave/app.config @@ -1,3 +1,3 @@ - + diff --git a/Pictures/Master.PNG b/Pictures/Master.PNG index 5689569..8829f69 100644 Binary files a/Pictures/Master.PNG and b/Pictures/Master.PNG differ diff --git a/Pictures/Slave.PNG b/Pictures/Slave.PNG index 9979f81..2992217 100644 Binary files a/Pictures/Slave.PNG and b/Pictures/Slave.PNG differ diff --git a/Pictures/default-yellowS2.png b/Pictures/default-yellowS2.png new file mode 100644 index 0000000..8926bd7 Binary files /dev/null and b/Pictures/default-yellowS2.png differ diff --git a/README.md b/README.md index adc519c..3de3497 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # ModbusTool ## A modbus TCP and RTU master and slave tool with import and export functionality. -|If you find this project useful or interesting, please help support further development!|[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/classicdiy?country.x=CA&locale.x=en_US)| -|---|---| +Buy Me A Coffee [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FClassicDIY%2FModbusTool&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com) @@ -12,14 +11,39 @@ [![GitHub issues](https://img.shields.io/github/issues-raw/ClassicDIY/ModbusTool?style=for-the-badge)](https://github.com/ClassicDIY/ModbusTool/issues) [![GitHub](https://img.shields.io/github/license/ClassicDIY/ModbusTool?style=for-the-badge)](https://github.com/ClassicDIY/ModbusTool/blob/master/LICENSE) -

-Please refer to the ModbusTool wiki for the installation procedure. -

-

+## Installation + +There are two options available to download and install ModbusTool. + +### Option 1: Download from Github Releases + +1. Visit the [Github Releases page](https://github.com/ClassicDIY/ModbusTool/releases) of ModbusTool. +2. Choose `ModbusTool.msi` to downloaad. +3. Once the file is downloaded, double-click on it to initiate the installation process. +4. Follow the on-screen instructions to complete the installation. + +For detailed installation instructions and additional information, refer to the [Github Wiki tutorial](https://github.com/ClassicDIY/ModbusTool/wiki) dedicated to this option. + +### Option 2: Install using `winget` + +> `Winget` is a command-line package manager for Windows that allows users to quickly and easily install, manage, and uninstall software applications from the terminal. + +1. Ensure that you have `winget` installed on your system. If not, follow the instructions to install `winget` from the official Microsoft [documentation](https://learn.microsoft.com/en-us/windows/package-manager/winget/). +2. Open a powershell or terminal window. +3. Execute the following command to install ModbusTool using `winget`: + +```shell +winget install ClassicDIY.ModbusTool +``` + +4. Wait for the installation process to complete. + +Once installed, you can launch ModbusTool and start using its master and slave test functionalities with import and export capabilities. + ## License ``` @@ -40,7 +64,7 @@ Please refer to the Modb ``` -Release notes: +## Release notes -----------------