├── .gitattributes ├── .gitignore ├── ComPortProxy.sln ├── ComPortProxy ├── ComPortProxy.Ui │ ├── App.config │ ├── ComPortProxy.Ui.csproj │ ├── FormMain.Designer.cs │ ├── FormMain.cs │ ├── FormMain.resx │ ├── Program.cs │ └── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings ├── ComPortProxy.sln └── ComPortProxy │ ├── App.config │ ├── ComPortProxy.csproj │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ └── SerialProgress.cs ├── LICENSE ├── README.md ├── Screenshots └── 01.png └── _config.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /ComPortProxy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComPortProxy", "ComPortProxy\ComPortProxy.csproj", "{E6BC9FA3-FF5D-4DB1-8977-E1BC3030C44B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E6BC9FA3-FF5D-4DB1-8977-E1BC3030C44B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {E6BC9FA3-FF5D-4DB1-8977-E1BC3030C44B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {E6BC9FA3-FF5D-4DB1-8977-E1BC3030C44B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {E6BC9FA3-FF5D-4DB1-8977-E1BC3030C44B}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {4DA8F254-EFF5-4E65-A7E4-8FB6CB64213A} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 9600 21 | 22 | 23 | 9600 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/ComPortProxy.Ui.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8CE00435-832D-4F12-BFFD-8E696DD715E9} 8 | WinExe 9 | ComPortProxy.Ui 10 | ComPortProxy.Ui 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | Form 50 | 51 | 52 | FormMain.cs 53 | 54 | 55 | 56 | 57 | FormMain.cs 58 | 59 | 60 | ResXFileCodeGenerator 61 | Resources.Designer.cs 62 | Designer 63 | 64 | 65 | True 66 | Resources.resx 67 | 68 | 69 | SettingsSingleFileGenerator 70 | Settings.Designer.cs 71 | 72 | 73 | True 74 | Settings.settings 75 | True 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | {68018e31-6ee4-4357-85bc-f0ffdf23a5f3} 84 | ComPortProxy 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/FormMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace ComPortProxy.Ui { 2 | partial class FormMain { 3 | /// 4 | /// Required designer variable. 5 | /// 6 | private System.ComponentModel.IContainer components = null; 7 | 8 | /// 9 | /// Clean up any resources being used. 10 | /// 11 | /// true if managed resources should be disposed; otherwise, false. 12 | protected override void Dispose(bool disposing) { 13 | if (disposing && (components != null)) { 14 | components.Dispose(); 15 | } 16 | base.Dispose(disposing); 17 | } 18 | 19 | #region Windows Form Designer generated code 20 | 21 | /// 22 | /// Required method for Designer support - do not modify 23 | /// the contents of this method with the code editor. 24 | /// 25 | private void InitializeComponent() { 26 | this.btnConnect = new System.Windows.Forms.Button(); 27 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 28 | this.btnClear1 = new System.Windows.Forms.Button(); 29 | this.txtData1 = new System.Windows.Forms.TextBox(); 30 | this.panel1 = new System.Windows.Forms.Panel(); 31 | this.rbDisabled1 = new System.Windows.Forms.RadioButton(); 32 | this.rbAscii1 = new System.Windows.Forms.RadioButton(); 33 | this.rbHex1 = new System.Windows.Forms.RadioButton(); 34 | this.label5 = new System.Windows.Forms.Label(); 35 | this.cmbPort1Speed = new System.Windows.Forms.ComboBox(); 36 | this.label2 = new System.Windows.Forms.Label(); 37 | this.label1 = new System.Windows.Forms.Label(); 38 | this.cmbPort1 = new System.Windows.Forms.ComboBox(); 39 | this.lblPort1to2 = new System.Windows.Forms.Label(); 40 | this.groupBox2 = new System.Windows.Forms.GroupBox(); 41 | this.btnClear2 = new System.Windows.Forms.Button(); 42 | this.txtData2 = new System.Windows.Forms.TextBox(); 43 | this.panel2 = new System.Windows.Forms.Panel(); 44 | this.rbDisabled2 = new System.Windows.Forms.RadioButton(); 45 | this.rbAscii2 = new System.Windows.Forms.RadioButton(); 46 | this.rbHex2 = new System.Windows.Forms.RadioButton(); 47 | this.label6 = new System.Windows.Forms.Label(); 48 | this.cmbPort2Speed = new System.Windows.Forms.ComboBox(); 49 | this.label3 = new System.Windows.Forms.Label(); 50 | this.label4 = new System.Windows.Forms.Label(); 51 | this.cmbPort2 = new System.Windows.Forms.ComboBox(); 52 | this.lblPort2to1 = new System.Windows.Forms.Label(); 53 | this.btnDisconnect = new System.Windows.Forms.Button(); 54 | this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 55 | this.groupBox1.SuspendLayout(); 56 | this.panel1.SuspendLayout(); 57 | this.groupBox2.SuspendLayout(); 58 | this.panel2.SuspendLayout(); 59 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); 60 | this.splitContainer1.Panel1.SuspendLayout(); 61 | this.splitContainer1.Panel2.SuspendLayout(); 62 | this.splitContainer1.SuspendLayout(); 63 | this.SuspendLayout(); 64 | // 65 | // btnConnect 66 | // 67 | this.btnConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 68 | this.btnConnect.Location = new System.Drawing.Point(614, 401); 69 | this.btnConnect.Name = "btnConnect"; 70 | this.btnConnect.Size = new System.Drawing.Size(80, 23); 71 | this.btnConnect.TabIndex = 0; 72 | this.btnConnect.Text = "Connect"; 73 | this.btnConnect.UseVisualStyleBackColor = true; 74 | this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click); 75 | // 76 | // groupBox1 77 | // 78 | this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 79 | | System.Windows.Forms.AnchorStyles.Left) 80 | | System.Windows.Forms.AnchorStyles.Right))); 81 | this.groupBox1.Controls.Add(this.btnClear1); 82 | this.groupBox1.Controls.Add(this.txtData1); 83 | this.groupBox1.Controls.Add(this.panel1); 84 | this.groupBox1.Controls.Add(this.label5); 85 | this.groupBox1.Controls.Add(this.cmbPort1Speed); 86 | this.groupBox1.Controls.Add(this.label2); 87 | this.groupBox1.Controls.Add(this.label1); 88 | this.groupBox1.Controls.Add(this.cmbPort1); 89 | this.groupBox1.Controls.Add(this.lblPort1to2); 90 | this.groupBox1.Location = new System.Drawing.Point(3, 3); 91 | this.groupBox1.Name = "groupBox1"; 92 | this.groupBox1.Size = new System.Drawing.Size(331, 375); 93 | this.groupBox1.TabIndex = 1; 94 | this.groupBox1.TabStop = false; 95 | this.groupBox1.Text = "Port 1"; 96 | // 97 | // btnClear1 98 | // 99 | this.btnClear1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 100 | this.btnClear1.Location = new System.Drawing.Point(273, 346); 101 | this.btnClear1.Name = "btnClear1"; 102 | this.btnClear1.Size = new System.Drawing.Size(54, 23); 103 | this.btnClear1.TabIndex = 14; 104 | this.btnClear1.Text = "Clear"; 105 | this.btnClear1.UseVisualStyleBackColor = true; 106 | this.btnClear1.Click += new System.EventHandler(this.btnClear1_Click); 107 | // 108 | // txtData1 109 | // 110 | this.txtData1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 111 | | System.Windows.Forms.AnchorStyles.Left) 112 | | System.Windows.Forms.AnchorStyles.Right))); 113 | this.txtData1.Font = new System.Drawing.Font("Ubuntu Mono", 12F); 114 | this.txtData1.Location = new System.Drawing.Point(6, 107); 115 | this.txtData1.Multiline = true; 116 | this.txtData1.Name = "txtData1"; 117 | this.txtData1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 118 | this.txtData1.Size = new System.Drawing.Size(319, 233); 119 | this.txtData1.TabIndex = 12; 120 | // 121 | // panel1 122 | // 123 | this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 124 | | System.Windows.Forms.AnchorStyles.Right))); 125 | this.panel1.Controls.Add(this.rbDisabled1); 126 | this.panel1.Controls.Add(this.rbAscii1); 127 | this.panel1.Controls.Add(this.rbHex1); 128 | this.panel1.Location = new System.Drawing.Point(9, 346); 129 | this.panel1.Name = "panel1"; 130 | this.panel1.Size = new System.Drawing.Size(258, 23); 131 | this.panel1.TabIndex = 13; 132 | // 133 | // rbDisabled1 134 | // 135 | this.rbDisabled1.AutoSize = true; 136 | this.rbDisabled1.Location = new System.Drawing.Point(0, 2); 137 | this.rbDisabled1.Name = "rbDisabled1"; 138 | this.rbDisabled1.Size = new System.Drawing.Size(66, 17); 139 | this.rbDisabled1.TabIndex = 10; 140 | this.rbDisabled1.Text = "Disabled"; 141 | this.rbDisabled1.UseVisualStyleBackColor = true; 142 | this.rbDisabled1.CheckedChanged += new System.EventHandler(this.rbDisabled1_CheckedChanged); 143 | // 144 | // rbAscii1 145 | // 146 | this.rbAscii1.AutoSize = true; 147 | this.rbAscii1.Checked = true; 148 | this.rbAscii1.Location = new System.Drawing.Point(72, 2); 149 | this.rbAscii1.Name = "rbAscii1"; 150 | this.rbAscii1.Size = new System.Drawing.Size(52, 17); 151 | this.rbAscii1.TabIndex = 9; 152 | this.rbAscii1.TabStop = true; 153 | this.rbAscii1.Text = "ASCII"; 154 | this.rbAscii1.UseVisualStyleBackColor = true; 155 | this.rbAscii1.CheckedChanged += new System.EventHandler(this.rbAscii1_CheckedChanged); 156 | // 157 | // rbHex1 158 | // 159 | this.rbHex1.AutoSize = true; 160 | this.rbHex1.Location = new System.Drawing.Point(130, 2); 161 | this.rbHex1.Name = "rbHex1"; 162 | this.rbHex1.Size = new System.Drawing.Size(47, 17); 163 | this.rbHex1.TabIndex = 8; 164 | this.rbHex1.Text = "HEX"; 165 | this.rbHex1.UseVisualStyleBackColor = true; 166 | this.rbHex1.CheckedChanged += new System.EventHandler(this.rbHex1_CheckedChanged); 167 | // 168 | // label5 169 | // 170 | this.label5.AutoSize = true; 171 | this.label5.Location = new System.Drawing.Point(6, 75); 172 | this.label5.Name = "label5"; 173 | this.label5.Size = new System.Drawing.Size(62, 13); 174 | this.label5.TabIndex = 5; 175 | this.label5.Text = "Throughput"; 176 | // 177 | // cmbPort1Speed 178 | // 179 | this.cmbPort1Speed.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 180 | this.cmbPort1Speed.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::ComPortProxy.Ui.Properties.Settings.Default, "cmbPort1Speed", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); 181 | this.cmbPort1Speed.FormattingEnabled = true; 182 | this.cmbPort1Speed.Items.AddRange(new object[] { 183 | "2400", 184 | "4800", 185 | "9600", 186 | "19200", 187 | "38400", 188 | "57600", 189 | "115200"}); 190 | this.cmbPort1Speed.Location = new System.Drawing.Point(204, 46); 191 | this.cmbPort1Speed.Name = "cmbPort1Speed"; 192 | this.cmbPort1Speed.Size = new System.Drawing.Size(121, 21); 193 | this.cmbPort1Speed.TabIndex = 2; 194 | this.cmbPort1Speed.Text = global::ComPortProxy.Ui.Properties.Settings.Default.cmbPort1Speed; 195 | // 196 | // label2 197 | // 198 | this.label2.AutoSize = true; 199 | this.label2.Location = new System.Drawing.Point(6, 49); 200 | this.label2.Name = "label2"; 201 | this.label2.Size = new System.Drawing.Size(58, 13); 202 | this.label2.TabIndex = 1; 203 | this.label2.Text = "Baud Rate"; 204 | // 205 | // label1 206 | // 207 | this.label1.AutoSize = true; 208 | this.label1.Location = new System.Drawing.Point(6, 22); 209 | this.label1.Name = "label1"; 210 | this.label1.Size = new System.Drawing.Size(53, 13); 211 | this.label1.TabIndex = 1; 212 | this.label1.Text = "COM Port"; 213 | // 214 | // cmbPort1 215 | // 216 | this.cmbPort1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 217 | this.cmbPort1.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::ComPortProxy.Ui.Properties.Settings.Default, "cmbPort1", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); 218 | this.cmbPort1.FormattingEnabled = true; 219 | this.cmbPort1.Location = new System.Drawing.Point(204, 19); 220 | this.cmbPort1.Name = "cmbPort1"; 221 | this.cmbPort1.Size = new System.Drawing.Size(121, 21); 222 | this.cmbPort1.TabIndex = 0; 223 | this.cmbPort1.Text = global::ComPortProxy.Ui.Properties.Settings.Default.cmbPort1; 224 | // 225 | // lblPort1to2 226 | // 227 | this.lblPort1to2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 228 | this.lblPort1to2.Location = new System.Drawing.Point(204, 75); 229 | this.lblPort1to2.Name = "lblPort1to2"; 230 | this.lblPort1to2.Size = new System.Drawing.Size(121, 13); 231 | this.lblPort1to2.TabIndex = 4; 232 | this.lblPort1to2.Text = "0 bytes/s"; 233 | this.lblPort1to2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 234 | // 235 | // groupBox2 236 | // 237 | this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 238 | | System.Windows.Forms.AnchorStyles.Left) 239 | | System.Windows.Forms.AnchorStyles.Right))); 240 | this.groupBox2.Controls.Add(this.btnClear2); 241 | this.groupBox2.Controls.Add(this.txtData2); 242 | this.groupBox2.Controls.Add(this.panel2); 243 | this.groupBox2.Controls.Add(this.label6); 244 | this.groupBox2.Controls.Add(this.cmbPort2Speed); 245 | this.groupBox2.Controls.Add(this.label3); 246 | this.groupBox2.Controls.Add(this.label4); 247 | this.groupBox2.Controls.Add(this.cmbPort2); 248 | this.groupBox2.Controls.Add(this.lblPort2to1); 249 | this.groupBox2.Location = new System.Drawing.Point(4, 3); 250 | this.groupBox2.Name = "groupBox2"; 251 | this.groupBox2.Size = new System.Drawing.Size(334, 375); 252 | this.groupBox2.TabIndex = 3; 253 | this.groupBox2.TabStop = false; 254 | this.groupBox2.Text = "Port 2"; 255 | // 256 | // btnClear2 257 | // 258 | this.btnClear2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 259 | this.btnClear2.Location = new System.Drawing.Point(274, 345); 260 | this.btnClear2.Name = "btnClear2"; 261 | this.btnClear2.Size = new System.Drawing.Size(54, 23); 262 | this.btnClear2.TabIndex = 15; 263 | this.btnClear2.Text = "Clear"; 264 | this.btnClear2.UseVisualStyleBackColor = true; 265 | this.btnClear2.Click += new System.EventHandler(this.btnClear2_Click); 266 | // 267 | // txtData2 268 | // 269 | this.txtData2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 270 | | System.Windows.Forms.AnchorStyles.Left) 271 | | System.Windows.Forms.AnchorStyles.Right))); 272 | this.txtData2.Font = new System.Drawing.Font("Ubuntu Mono", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 273 | this.txtData2.Location = new System.Drawing.Point(6, 107); 274 | this.txtData2.Multiline = true; 275 | this.txtData2.Name = "txtData2"; 276 | this.txtData2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 277 | this.txtData2.Size = new System.Drawing.Size(322, 232); 278 | this.txtData2.TabIndex = 12; 279 | // 280 | // panel2 281 | // 282 | this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 283 | | System.Windows.Forms.AnchorStyles.Right))); 284 | this.panel2.Controls.Add(this.rbDisabled2); 285 | this.panel2.Controls.Add(this.rbAscii2); 286 | this.panel2.Controls.Add(this.rbHex2); 287 | this.panel2.Location = new System.Drawing.Point(9, 345); 288 | this.panel2.Name = "panel2"; 289 | this.panel2.Size = new System.Drawing.Size(256, 23); 290 | this.panel2.TabIndex = 13; 291 | // 292 | // rbDisabled2 293 | // 294 | this.rbDisabled2.AutoSize = true; 295 | this.rbDisabled2.Location = new System.Drawing.Point(0, 2); 296 | this.rbDisabled2.Name = "rbDisabled2"; 297 | this.rbDisabled2.Size = new System.Drawing.Size(66, 17); 298 | this.rbDisabled2.TabIndex = 11; 299 | this.rbDisabled2.Text = "Disabled"; 300 | this.rbDisabled2.UseVisualStyleBackColor = true; 301 | this.rbDisabled2.CheckedChanged += new System.EventHandler(this.rbDisabled2_CheckedChanged); 302 | // 303 | // rbAscii2 304 | // 305 | this.rbAscii2.AutoSize = true; 306 | this.rbAscii2.Checked = true; 307 | this.rbAscii2.Location = new System.Drawing.Point(72, 2); 308 | this.rbAscii2.Name = "rbAscii2"; 309 | this.rbAscii2.Size = new System.Drawing.Size(52, 17); 310 | this.rbAscii2.TabIndex = 9; 311 | this.rbAscii2.TabStop = true; 312 | this.rbAscii2.Text = "ASCII"; 313 | this.rbAscii2.UseVisualStyleBackColor = true; 314 | this.rbAscii2.CheckedChanged += new System.EventHandler(this.rbAscii2_CheckedChanged); 315 | // 316 | // rbHex2 317 | // 318 | this.rbHex2.AutoSize = true; 319 | this.rbHex2.Location = new System.Drawing.Point(130, 2); 320 | this.rbHex2.Name = "rbHex2"; 321 | this.rbHex2.Size = new System.Drawing.Size(47, 17); 322 | this.rbHex2.TabIndex = 8; 323 | this.rbHex2.Text = "HEX"; 324 | this.rbHex2.UseVisualStyleBackColor = true; 325 | this.rbHex2.CheckedChanged += new System.EventHandler(this.rbHex2_CheckedChanged); 326 | // 327 | // label6 328 | // 329 | this.label6.AutoSize = true; 330 | this.label6.Location = new System.Drawing.Point(7, 75); 331 | this.label6.Name = "label6"; 332 | this.label6.Size = new System.Drawing.Size(62, 13); 333 | this.label6.TabIndex = 6; 334 | this.label6.Text = "Throughput"; 335 | // 336 | // cmbPort2Speed 337 | // 338 | this.cmbPort2Speed.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 339 | this.cmbPort2Speed.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::ComPortProxy.Ui.Properties.Settings.Default, "cmbPort2Speed", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); 340 | this.cmbPort2Speed.FormattingEnabled = true; 341 | this.cmbPort2Speed.Items.AddRange(new object[] { 342 | "2400", 343 | "4800", 344 | "9600", 345 | "19200", 346 | "38400", 347 | "57600", 348 | "115200"}); 349 | this.cmbPort2Speed.Location = new System.Drawing.Point(207, 46); 350 | this.cmbPort2Speed.Name = "cmbPort2Speed"; 351 | this.cmbPort2Speed.Size = new System.Drawing.Size(121, 21); 352 | this.cmbPort2Speed.TabIndex = 2; 353 | this.cmbPort2Speed.Text = global::ComPortProxy.Ui.Properties.Settings.Default.cmbPort2Speed; 354 | // 355 | // label3 356 | // 357 | this.label3.AutoSize = true; 358 | this.label3.Location = new System.Drawing.Point(7, 49); 359 | this.label3.Name = "label3"; 360 | this.label3.Size = new System.Drawing.Size(58, 13); 361 | this.label3.TabIndex = 1; 362 | this.label3.Text = "Baud Rate"; 363 | // 364 | // label4 365 | // 366 | this.label4.AutoSize = true; 367 | this.label4.Location = new System.Drawing.Point(6, 22); 368 | this.label4.Name = "label4"; 369 | this.label4.Size = new System.Drawing.Size(53, 13); 370 | this.label4.TabIndex = 1; 371 | this.label4.Text = "COM Port"; 372 | // 373 | // cmbPort2 374 | // 375 | this.cmbPort2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 376 | this.cmbPort2.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::ComPortProxy.Ui.Properties.Settings.Default, "cmbPort2", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); 377 | this.cmbPort2.FormattingEnabled = true; 378 | this.cmbPort2.Location = new System.Drawing.Point(207, 19); 379 | this.cmbPort2.Name = "cmbPort2"; 380 | this.cmbPort2.Size = new System.Drawing.Size(121, 21); 381 | this.cmbPort2.TabIndex = 0; 382 | this.cmbPort2.Text = global::ComPortProxy.Ui.Properties.Settings.Default.cmbPort2; 383 | // 384 | // lblPort2to1 385 | // 386 | this.lblPort2to1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 387 | this.lblPort2to1.Location = new System.Drawing.Point(207, 75); 388 | this.lblPort2to1.Name = "lblPort2to1"; 389 | this.lblPort2to1.Size = new System.Drawing.Size(121, 13); 390 | this.lblPort2to1.TabIndex = 5; 391 | this.lblPort2to1.Text = "0 bytes/s"; 392 | this.lblPort2to1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 393 | // 394 | // btnDisconnect 395 | // 396 | this.btnDisconnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 397 | this.btnDisconnect.Enabled = false; 398 | this.btnDisconnect.Location = new System.Drawing.Point(528, 401); 399 | this.btnDisconnect.Name = "btnDisconnect"; 400 | this.btnDisconnect.Size = new System.Drawing.Size(80, 23); 401 | this.btnDisconnect.TabIndex = 12; 402 | this.btnDisconnect.Text = "Disconnect"; 403 | this.btnDisconnect.UseVisualStyleBackColor = true; 404 | this.btnDisconnect.Click += new System.EventHandler(this.btnDisconnect_Click); 405 | // 406 | // splitContainer1 407 | // 408 | this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 409 | | System.Windows.Forms.AnchorStyles.Left) 410 | | System.Windows.Forms.AnchorStyles.Right))); 411 | this.splitContainer1.Location = new System.Drawing.Point(12, 12); 412 | this.splitContainer1.Name = "splitContainer1"; 413 | // 414 | // splitContainer1.Panel1 415 | // 416 | this.splitContainer1.Panel1.Controls.Add(this.groupBox1); 417 | // 418 | // splitContainer1.Panel2 419 | // 420 | this.splitContainer1.Panel2.Controls.Add(this.groupBox2); 421 | this.splitContainer1.Size = new System.Drawing.Size(685, 381); 422 | this.splitContainer1.SplitterDistance = 339; 423 | this.splitContainer1.TabIndex = 13; 424 | // 425 | // FormMain 426 | // 427 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 428 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 429 | this.ClientSize = new System.Drawing.Size(707, 431); 430 | this.Controls.Add(this.splitContainer1); 431 | this.Controls.Add(this.btnDisconnect); 432 | this.Controls.Add(this.btnConnect); 433 | this.Name = "FormMain"; 434 | this.Text = "Com Port Proxy"; 435 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormMain_FormClosing); 436 | this.Load += new System.EventHandler(this.FormMain_Load); 437 | this.groupBox1.ResumeLayout(false); 438 | this.groupBox1.PerformLayout(); 439 | this.panel1.ResumeLayout(false); 440 | this.panel1.PerformLayout(); 441 | this.groupBox2.ResumeLayout(false); 442 | this.groupBox2.PerformLayout(); 443 | this.panel2.ResumeLayout(false); 444 | this.panel2.PerformLayout(); 445 | this.splitContainer1.Panel1.ResumeLayout(false); 446 | this.splitContainer1.Panel2.ResumeLayout(false); 447 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); 448 | this.splitContainer1.ResumeLayout(false); 449 | this.ResumeLayout(false); 450 | 451 | } 452 | 453 | #endregion 454 | 455 | private System.Windows.Forms.Button btnConnect; 456 | private System.Windows.Forms.GroupBox groupBox1; 457 | private System.Windows.Forms.ComboBox cmbPort1; 458 | private System.Windows.Forms.Label label1; 459 | private System.Windows.Forms.ComboBox cmbPort1Speed; 460 | private System.Windows.Forms.Label label2; 461 | private System.Windows.Forms.GroupBox groupBox2; 462 | private System.Windows.Forms.ComboBox cmbPort2Speed; 463 | private System.Windows.Forms.Label label3; 464 | private System.Windows.Forms.Label label4; 465 | private System.Windows.Forms.ComboBox cmbPort2; 466 | private System.Windows.Forms.Label lblPort1to2; 467 | private System.Windows.Forms.Label lblPort2to1; 468 | private System.Windows.Forms.Label label5; 469 | private System.Windows.Forms.Label label6; 470 | private System.Windows.Forms.Button btnDisconnect; 471 | private System.Windows.Forms.SplitContainer splitContainer1; 472 | private System.Windows.Forms.Button btnClear1; 473 | private System.Windows.Forms.TextBox txtData1; 474 | private System.Windows.Forms.Panel panel1; 475 | private System.Windows.Forms.RadioButton rbAscii1; 476 | private System.Windows.Forms.RadioButton rbHex1; 477 | private System.Windows.Forms.Button btnClear2; 478 | private System.Windows.Forms.TextBox txtData2; 479 | private System.Windows.Forms.Panel panel2; 480 | private System.Windows.Forms.RadioButton rbAscii2; 481 | private System.Windows.Forms.RadioButton rbHex2; 482 | private System.Windows.Forms.RadioButton rbDisabled1; 483 | private System.Windows.Forms.RadioButton rbDisabled2; 484 | } 485 | } 486 | 487 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/FormMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Diagnostics; 4 | using System.IO.Ports; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading; 8 | using System.Windows.Forms; 9 | 10 | namespace ComPortProxy.Ui { 11 | 12 | public partial class FormMain : Form { 13 | 14 | public FormMain() { 15 | InitializeComponent(); 16 | } 17 | 18 | private void FormMain_Load(object sender, EventArgs e) { 19 | cmbPort1.Items.AddRange(SerialPort.GetPortNames()); 20 | cmbPort2.Items.AddRange(SerialPort.GetPortNames()); 21 | 22 | t1.Tick += T1_Tick; 23 | t1.Enabled = true; 24 | t1.Interval = 1000; 25 | 26 | bw1.WorkerSupportsCancellation = true; 27 | bw1.WorkerReportsProgress = true; 28 | bw1.DoWork += Bw1_DoWork; 29 | bw1.ProgressChanged += Bw1_ProgressChanged; 30 | 31 | bw2.DoWork += Bw2_DoWork; 32 | bw2.WorkerSupportsCancellation = true; 33 | bw2.WorkerReportsProgress = true; 34 | bw2.ProgressChanged += Bw2_ProgressChanged; 35 | 36 | sp1.ReadTimeout = sp1.WriteTimeout = sp2.ReadTimeout = sp2.ReadTimeout = 1000; 37 | } 38 | 39 | private void FormMain_FormClosing(object sender, FormClosingEventArgs e) { 40 | Properties.Settings.Default.Save(); 41 | } 42 | 43 | public static SerialPort sp1 = new SerialPort(); 44 | public static SerialPort sp2 = new SerialPort(); 45 | 46 | public static BackgroundWorker bw1 = new BackgroundWorker(); 47 | public static BackgroundWorker bw2 = new BackgroundWorker(); 48 | 49 | public static System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer(); 50 | public static long bps1 = 0; 51 | public static long bps2 = 0; 52 | 53 | private void T1_Tick(object sender, EventArgs e) { 54 | lblPort1to2.Text = $"{bps1} bytes/s"; 55 | lblPort2to1.Text = $"{bps2} bytes/s"; 56 | bps1 = 0; 57 | bps2 = 0; 58 | } 59 | 60 | private static void Bw1_DoWork(object sender, DoWorkEventArgs e) { 61 | var buffer = new byte[4096]; 62 | 63 | while (!bw1.CancellationPending) { 64 | 65 | try { 66 | if (!sp1.IsOpen) sp1.Open(); 67 | 68 | var c = sp1.Read(buffer, 0, buffer.Length); 69 | sp2.Write(buffer, 0, c); 70 | 71 | bps1 += c; 72 | 73 | bw1.ReportProgress(0, new SerialProgress() { Data = buffer.Take(c).ToArray() }); 74 | 75 | } catch (Exception ex) { 76 | Console.WriteLine(ex.Message); 77 | } 78 | 79 | } 80 | 81 | Debug.WriteLine("Bw1_DoWork complete"); 82 | } 83 | 84 | private static void Bw2_DoWork(object sender, DoWorkEventArgs e) { 85 | var buffer = new byte[4096]; 86 | 87 | while (!bw2.CancellationPending) { 88 | 89 | try { 90 | if (!sp2.IsOpen) sp2.Open(); 91 | 92 | var c = sp2.Read(buffer, 0, buffer.Length); 93 | sp1.Write(buffer, 0, c); 94 | 95 | bps2 += c; 96 | 97 | bw2.ReportProgress(0, new SerialProgress() { Data = buffer.Take(c).ToArray() }); 98 | 99 | } catch (Exception ex) { 100 | Console.WriteLine(ex.Message); 101 | } 102 | 103 | } 104 | 105 | Debug.WriteLine("Bw2_DoWork complete"); 106 | } 107 | 108 | public enum LogDataType { 109 | Disabled, 110 | Ascii, 111 | Utf8, 112 | Hex 113 | } 114 | 115 | private void Bw1_ProgressChanged(object sender, ProgressChangedEventArgs e) { 116 | var sp = e.UserState as SerialProgress; 117 | 118 | var ldt = LogDataType.Disabled; 119 | if (rbAscii1.Checked) ldt = LogDataType.Ascii; 120 | if (rbHex1.Checked) ldt = LogDataType.Hex; 121 | 122 | if (ldt != LogDataType.Disabled) LogData(ldt, txtData1, sp.Data); 123 | } 124 | 125 | private void Bw2_ProgressChanged(object sender, ProgressChangedEventArgs e) { 126 | var sp = e.UserState as SerialProgress; 127 | 128 | var ldt = LogDataType.Disabled; 129 | if (rbAscii2.Checked) ldt = LogDataType.Ascii; 130 | if (rbHex2.Checked) ldt = LogDataType.Hex; 131 | 132 | if (ldt != LogDataType.Disabled) LogData(ldt, txtData2, sp.Data); 133 | } 134 | 135 | public void LogData(LogDataType ldt, TextBox txt, byte[] data) { 136 | switch (ldt) { 137 | case LogDataType.Ascii: 138 | txt.AppendText(Encoding.ASCII.GetString(data)); 139 | Debug.Write(Encoding.ASCII.GetString(data)); 140 | break; 141 | 142 | case LogDataType.Hex: 143 | txt.AppendText(BitConverter.ToString(data).Replace("-", " ")); 144 | txt.AppendText(" "); 145 | Debug.Write(BitConverter.ToString(data).Replace("-", " ")); 146 | Debug.Write(" "); 147 | break; 148 | } 149 | } 150 | 151 | private void btnConnect_Click(object sender, EventArgs e) { 152 | try { 153 | sp1.BaudRate = int.Parse(cmbPort1Speed.Text); 154 | sp1.PortName = cmbPort1.Text; 155 | 156 | sp2.BaudRate = int.Parse(cmbPort2Speed.Text); 157 | sp2.PortName = cmbPort2.Text; 158 | 159 | sp1.Open(); 160 | sp2.Open(); 161 | 162 | t1.Start(); 163 | bw1.RunWorkerAsync(); 164 | bw2.RunWorkerAsync(); 165 | 166 | btnConnect.Enabled = false; 167 | btnDisconnect.Enabled = true; 168 | 169 | } catch (Exception ex) { 170 | if (sp1.IsOpen) sp1.Close(); 171 | if (sp2.IsOpen) sp2.Close(); 172 | 173 | btnConnect.Enabled = true; 174 | btnDisconnect.Enabled = false; 175 | 176 | MessageBox.Show(ex.Message, "Error"); 177 | } 178 | } 179 | 180 | private void btnDisconnect_Click(object sender, EventArgs e) { 181 | btnDisconnect.Enabled = false; 182 | 183 | bw1.CancelAsync(); 184 | bw2.CancelAsync(); 185 | 186 | while (bw1.IsBusy || bw2.IsBusy) { 187 | Application.DoEvents(); 188 | } 189 | 190 | sp1.Close(); 191 | sp2.Close(); 192 | 193 | t1.Stop(); 194 | 195 | lblPort1to2.Text = "0 bytes/s"; 196 | lblPort2to1.Text = "0 bytes/s"; 197 | 198 | bps1 = 0; 199 | bps2 = 0; 200 | 201 | btnConnect.Enabled = true; 202 | } 203 | 204 | private void btnClear1_Click(object sender, EventArgs e) { 205 | txtData1.Clear(); 206 | } 207 | 208 | private void btnClear2_Click(object sender, EventArgs e) { 209 | txtData2.Clear(); 210 | } 211 | 212 | private void rbDisabled1_CheckedChanged(object sender, EventArgs e) { 213 | txtData1.Enabled = !rbDisabled1.Checked; 214 | txtData1.Clear(); 215 | } 216 | 217 | private void rbDisabled2_CheckedChanged(object sender, EventArgs e) { 218 | txtData2.Enabled = !rbDisabled2.Checked; 219 | txtData2.Clear(); 220 | } 221 | 222 | private void rbAscii1_CheckedChanged(object sender, EventArgs e) { 223 | txtData1.Clear(); 224 | } 225 | 226 | private void rbAscii2_CheckedChanged(object sender, EventArgs e) { 227 | txtData2.Clear(); 228 | } 229 | 230 | private void rbHex1_CheckedChanged(object sender, EventArgs e) { 231 | txtData1.Clear(); 232 | } 233 | 234 | private void rbHex2_CheckedChanged(object sender, EventArgs e) { 235 | txtData2.Clear(); 236 | } 237 | } 238 | } -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/FormMain.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace ComPortProxy.Ui { 5 | 6 | internal static class Program { 7 | 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | private static void Main() { 13 | Application.EnableVisualStyles(); 14 | Application.SetCompatibleTextRenderingDefault(false); 15 | Application.Run(new FormMain()); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ComPortProxy.Ui")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ComPortProxy.Ui")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8ce00435-832d-4f12-bffd-8e696dd715e9")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ComPortProxy.Ui.Properties { 12 | 13 | 14 | /// 15 | /// A strongly-typed resource class, for looking up localized strings, etc. 16 | /// 17 | // This class was auto-generated by the StronglyTypedResourceBuilder 18 | // class via a tool like ResGen or Visual Studio. 19 | // To add or remove a member, edit your .ResX file then rerun ResGen 20 | // with the /str option, or rebuild your VS project. 21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 24 | internal class Resources { 25 | 26 | private static global::System.Resources.ResourceManager resourceMan; 27 | 28 | private static global::System.Globalization.CultureInfo resourceCulture; 29 | 30 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 31 | internal Resources() { 32 | } 33 | 34 | /// 35 | /// Returns the cached ResourceManager instance used by this class. 36 | /// 37 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 38 | internal static global::System.Resources.ResourceManager ResourceManager 39 | { 40 | get 41 | { 42 | if ((resourceMan == null)) { 43 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ComPortProxy.Ui.Properties.Resources", typeof(Resources).Assembly); 44 | resourceMan = temp; 45 | } 46 | return resourceMan; 47 | } 48 | } 49 | 50 | /// 51 | /// Overrides the current thread's CurrentUICulture property for all 52 | /// resource lookups using this strongly typed resource class. 53 | /// 54 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 55 | internal static global::System.Globalization.CultureInfo Culture 56 | { 57 | get 58 | { 59 | return resourceCulture; 60 | } 61 | set 62 | { 63 | resourceCulture = value; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace ComPortProxy.Ui.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.6.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("")] 29 | public string cmbPort1 { 30 | get { 31 | return ((string)(this["cmbPort1"])); 32 | } 33 | set { 34 | this["cmbPort1"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("")] 41 | public string cmbPort2 { 42 | get { 43 | return ((string)(this["cmbPort2"])); 44 | } 45 | set { 46 | this["cmbPort2"] = value; 47 | } 48 | } 49 | 50 | [global::System.Configuration.UserScopedSettingAttribute()] 51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 52 | [global::System.Configuration.DefaultSettingValueAttribute("9600")] 53 | public string cmbPort1Speed { 54 | get { 55 | return ((string)(this["cmbPort1Speed"])); 56 | } 57 | set { 58 | this["cmbPort1Speed"] = value; 59 | } 60 | } 61 | 62 | [global::System.Configuration.UserScopedSettingAttribute()] 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 64 | [global::System.Configuration.DefaultSettingValueAttribute("9600")] 65 | public string cmbPort2Speed { 66 | get { 67 | return ((string)(this["cmbPort2Speed"])); 68 | } 69 | set { 70 | this["cmbPort2Speed"] = value; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.Ui/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 9600 13 | 14 | 15 | 9600 16 | 17 | 18 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComPortProxy", "ComPortProxy\ComPortProxy.csproj", "{68018E31-6EE4-4357-85BC-F0FFDF23A5F3}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComPortProxy.Ui", "ComPortProxy.Ui\ComPortProxy.Ui.csproj", "{8CE00435-832D-4F12-BFFD-8E696DD715E9}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {68018E31-6EE4-4357-85BC-F0FFDF23A5F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {68018E31-6EE4-4357-85BC-F0FFDF23A5F3}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {68018E31-6EE4-4357-85BC-F0FFDF23A5F3}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {68018E31-6EE4-4357-85BC-F0FFDF23A5F3}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {8CE00435-832D-4F12-BFFD-8E696DD715E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {8CE00435-832D-4F12-BFFD-8E696DD715E9}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {8CE00435-832D-4F12-BFFD-8E696DD715E9}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {8CE00435-832D-4F12-BFFD-8E696DD715E9}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {40E81E1F-BED0-4514-ABEE-7FE4E9C1F5EA} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy/ComPortProxy.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {68018E31-6EE4-4357-85BC-F0FFDF23A5F3} 8 | Exe 9 | ComPortProxy 10 | ComPortProxy 11 | v4.6.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.IO.Ports; 4 | using System.Linq; 5 | using System.Windows.Forms; 6 | 7 | namespace ComPortProxy { 8 | 9 | internal class Program { 10 | 11 | public static SerialPort sp1 = new SerialPort("COM4", 115200); // ESP 12 | public static SerialPort sp2 = new SerialPort("COM3", 115200); // Nextion 13 | 14 | public static BackgroundWorker bw1 = new BackgroundWorker(); 15 | public static BackgroundWorker bw2 = new BackgroundWorker(); 16 | 17 | public static Timer t1 = new Timer(); 18 | public static long bps1 = 0; 19 | 20 | private static void Main(string[] args) { 21 | t1.Enabled = true; 22 | t1.Interval = 1000; 23 | t1.Tick += T1_Tick; 24 | t1.Start(); 25 | 26 | bw1.DoWork += Bw1_DoWork; 27 | bw2.DoWork += Bw2_DoWork; 28 | 29 | bw2.WorkerReportsProgress = true; 30 | bw2.ProgressChanged += Bw2_ProgressChanged; 31 | 32 | bw1.RunWorkerAsync(); 33 | bw2.RunWorkerAsync(); 34 | 35 | Console.ReadLine(); 36 | } 37 | 38 | private static void T1_Tick(object sender, EventArgs e) { 39 | Console.WriteLine($"Bytes per second: {bps1}"); 40 | bps1 = 0; 41 | } 42 | 43 | private static void Bw1_DoWork(object sender, DoWorkEventArgs e) { 44 | var buffer = new byte[1024]; 45 | 46 | while (!bw1.CancellationPending) { 47 | 48 | try { 49 | var c = sp1.Read(buffer, 0, buffer.Length); 50 | sp2.Write(buffer, 0, c); 51 | 52 | bps1 += c; 53 | 54 | //Console.Write(Encoding.UTF8.GetString(new byte[] { b })); 55 | 56 | } catch (Exception ex) { 57 | Console.WriteLine(ex.Message); 58 | throw; 59 | } 60 | 61 | } 62 | } 63 | 64 | private static void Bw2_DoWork(object sender, DoWorkEventArgs e) { 65 | var buffer = new byte[1024]; 66 | 67 | while (!bw1.CancellationPending) { 68 | 69 | try { 70 | var c = sp2.Read(buffer, 0, buffer.Length); 71 | sp1.Write(buffer, 0, c); 72 | 73 | bw2.ReportProgress(0, new SerialProgress() { Data = buffer.Take(c).ToArray() }); 74 | 75 | } catch (Exception ex) { 76 | Console.WriteLine(ex.Message); 77 | throw; 78 | } 79 | 80 | } 81 | } 82 | 83 | private static void Bw2_ProgressChanged(object sender, ProgressChangedEventArgs e) { 84 | var sp = e.UserState as SerialProgress; 85 | 86 | //Console.Write(Encoding.UTF8.GetString(new byte[] { b })); 87 | Console.Write(BitConverter.ToString(sp.Data).Replace("-", " ")); 88 | Console.Write(" "); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ComPortProxy")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ComPortProxy")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("68018e31-6ee4-4357-85bc-f0ffdf23a5f3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ComPortProxy/ComPortProxy/SerialProgress.cs: -------------------------------------------------------------------------------- 1 | namespace ComPortProxy { 2 | 3 | public class SerialProgress { 4 | public byte[] Data { get; set; } 5 | } 6 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Hein Andre Grønnestad 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # COM Port Proxy 2 | 3 | COM Port Proxy is a simple C# Windows.Forms application to inspect and forward serial data from one serial port to another. 4 | 5 | ![Screenshot](Screenshots/01.png) -------------------------------------------------------------------------------- /Screenshots/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hagronnestad/com-port-proxy/4b1fe10dde1cffb549b3a292b221aff33a3759d5/Screenshots/01.png -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | title: COM Port Proxy 2 | theme: jekyll-theme-architect 3 | --------------------------------------------------------------------------------