├── .gitignore ├── CAN_Pipe.sln ├── CAN_Pipe ├── App.config ├── ArduinoSketchUploader │ ├── ArduinoUploader.dll │ ├── IntelHexFormatReader.dll │ ├── NLog.dll │ └── RJCP.SerialPortStream.dll ├── CAN_Pipe.csproj ├── CSV │ └── example.csv ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── README.md ├── Resources │ └── jesse2.jpg ├── Wireshark.cs ├── bin │ └── Debug │ │ ├── CAN_Pipe.exe │ │ ├── CAN_Pipe.exe.config │ │ └── CAN_Pipe.pdb ├── can.ico ├── obj │ └── Debug │ │ ├── CAN_Pipe.Form1.resources │ │ ├── CAN_Pipe.Properties.Resources.resources │ │ ├── CAN_Pipe.csproj.FileListAbsolute.txt │ │ ├── CAN_Pipe.csproj.GenerateResource.Cache │ │ ├── CAN_Pipe.csprojResolveAssemblyReference.cache │ │ ├── CAN_Pipe.exe │ │ ├── CAN_Pipe.pdb │ │ ├── CoreCompileInputs.cache │ │ ├── DesignTimeResolveAssemblyReferences.cache │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ └── TempPE │ │ └── Properties.Resources.Designer.cs.dll ├── sender │ ├── sender.ino │ ├── sender.ino.standard.hex │ └── sender.ino.with_bootloader.standard.hex └── sniffer │ ├── sniffer.ino │ ├── sniffer.ino.standard.hex │ └── sniffer.ino.with_bootloader.standard.hex ├── LICENSE └── README.md /.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 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | -------------------------------------------------------------------------------- /CAN_Pipe.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26403.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CAN_Pipe", "CAN_Pipe\CAN_Pipe.csproj", "{069804C7-5B9D-4554-817A-C66D23083286}" 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 | {069804C7-5B9D-4554-817A-C66D23083286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {069804C7-5B9D-4554-817A-C66D23083286}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {069804C7-5B9D-4554-817A-C66D23083286}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {069804C7-5B9D-4554-817A-C66D23083286}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /CAN_Pipe/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CAN_Pipe/ArduinoSketchUploader/ArduinoUploader.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/ArduinoSketchUploader/ArduinoUploader.dll -------------------------------------------------------------------------------- /CAN_Pipe/ArduinoSketchUploader/IntelHexFormatReader.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/ArduinoSketchUploader/IntelHexFormatReader.dll -------------------------------------------------------------------------------- /CAN_Pipe/ArduinoSketchUploader/NLog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/ArduinoSketchUploader/NLog.dll -------------------------------------------------------------------------------- /CAN_Pipe/ArduinoSketchUploader/RJCP.SerialPortStream.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/ArduinoSketchUploader/RJCP.SerialPortStream.dll -------------------------------------------------------------------------------- /CAN_Pipe/CAN_Pipe.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {069804C7-5B9D-4554-817A-C66D23083286} 8 | WinExe 9 | CAN_Pipe 10 | CAN_Pipe 11 | v4.5.2 12 | 512 13 | true 14 | publish\ 15 | true 16 | Disk 17 | false 18 | Foreground 19 | 7 20 | Days 21 | false 22 | false 23 | true 24 | 0 25 | 1.0.0.%2a 26 | false 27 | false 28 | true 29 | 30 | 31 | AnyCPU 32 | true 33 | full 34 | false 35 | bin\Debug\ 36 | DEBUG;TRACE 37 | prompt 38 | 4 39 | 40 | 41 | AnyCPU 42 | pdbonly 43 | true 44 | bin\Release\ 45 | TRACE 46 | prompt 47 | 4 48 | 49 | 50 | CAN_Pipe.Program 51 | 52 | 53 | can.ico 54 | 55 | 56 | 57 | False 58 | ArduinoSketchUploader\ArduinoUploader.dll 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Form 76 | 77 | 78 | Form1.cs 79 | 80 | 81 | 82 | 83 | 84 | Form1.cs 85 | 86 | 87 | ResXFileCodeGenerator 88 | Resources.Designer.cs 89 | Designer 90 | 91 | 92 | True 93 | Resources.resx 94 | True 95 | 96 | 97 | Always 98 | 99 | 100 | SettingsSingleFileGenerator 101 | Settings.Designer.cs 102 | 103 | 104 | True 105 | Settings.settings 106 | True 107 | 108 | 109 | 110 | 111 | Always 112 | 113 | 114 | 115 | Always 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | False 134 | Microsoft .NET Framework 4.5.2 %28x86 and x64%29 135 | true 136 | 137 | 138 | False 139 | .NET Framework 3.5 SP1 140 | false 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /CAN_Pipe/CSV/example.csv: -------------------------------------------------------------------------------- 1 | ADDR,DATA, data delim is space. address is max 0x7FF 2 | 5,5 5 5 5 5 5 5 5 3 | 126,6 6 6 6 6 4 | 12,2 3 4 5 | A, 1 B 3 -------------------------------------------------------------------------------- /CAN_Pipe/Form1.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace CAN_Pipe 2 | { 3 | partial class Form1 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); 32 | this.lblSelectCOMPort = new System.Windows.Forms.Label(); 33 | this.cmbSerialPorts = new System.Windows.Forms.ComboBox(); 34 | this.btnRefresh = new System.Windows.Forms.Button(); 35 | this.lblNameOfPipe = new System.Windows.Forms.Label(); 36 | this.tbPipeName = new System.Windows.Forms.TextBox(); 37 | this.btnStartSniff = new System.Windows.Forms.Button(); 38 | this.btnStopSniff = new System.Windows.Forms.Button(); 39 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 40 | this.groupBoxSniffing = new System.Windows.Forms.GroupBox(); 41 | this.groupBoxReplay = new System.Windows.Forms.GroupBox(); 42 | this.btnStopReplay = new System.Windows.Forms.Button(); 43 | this.btnStartReplay = new System.Windows.Forms.Button(); 44 | this.lblSelectedFileName = new System.Windows.Forms.Label(); 45 | this.btnBrowseForCSV = new System.Windows.Forms.Button(); 46 | this.label1 = new System.Windows.Forms.Label(); 47 | this.btnCANSnifferUpload = new System.Windows.Forms.Button(); 48 | this.groupBoxMain = new System.Windows.Forms.GroupBox(); 49 | this.cbListOnlyArduino = new System.Windows.Forms.CheckBox(); 50 | this.btnCANSenderUpload = new System.Windows.Forms.Button(); 51 | this.ofdFileDialog = new System.Windows.Forms.OpenFileDialog(); 52 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 53 | this.groupBoxSniffing.SuspendLayout(); 54 | this.groupBoxReplay.SuspendLayout(); 55 | this.groupBoxMain.SuspendLayout(); 56 | this.SuspendLayout(); 57 | // 58 | // lblSelectCOMPort 59 | // 60 | this.lblSelectCOMPort.AutoSize = true; 61 | this.lblSelectCOMPort.Location = new System.Drawing.Point(5, 20); 62 | this.lblSelectCOMPort.Name = "lblSelectCOMPort"; 63 | this.lblSelectCOMPort.Size = new System.Drawing.Size(127, 13); 64 | this.lblSelectCOMPort.TabIndex = 0; 65 | this.lblSelectCOMPort.Text = "Select Arduino COM port:"; 66 | // 67 | // cmbSerialPorts 68 | // 69 | this.cmbSerialPorts.FormattingEnabled = true; 70 | this.cmbSerialPorts.Location = new System.Drawing.Point(132, 17); 71 | this.cmbSerialPorts.Name = "cmbSerialPorts"; 72 | this.cmbSerialPorts.Size = new System.Drawing.Size(148, 21); 73 | this.cmbSerialPorts.TabIndex = 1; 74 | // 75 | // btnRefresh 76 | // 77 | this.btnRefresh.Image = ((System.Drawing.Image)(resources.GetObject("btnRefresh.Image"))); 78 | this.btnRefresh.Location = new System.Drawing.Point(286, 11); 79 | this.btnRefresh.Name = "btnRefresh"; 80 | this.btnRefresh.Size = new System.Drawing.Size(26, 30); 81 | this.btnRefresh.TabIndex = 2; 82 | this.btnRefresh.UseVisualStyleBackColor = true; 83 | this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); 84 | // 85 | // lblNameOfPipe 86 | // 87 | this.lblNameOfPipe.AutoSize = true; 88 | this.lblNameOfPipe.Location = new System.Drawing.Point(11, 22); 89 | this.lblNameOfPipe.Name = "lblNameOfPipe"; 90 | this.lblNameOfPipe.Size = new System.Drawing.Size(136, 13); 91 | this.lblNameOfPipe.TabIndex = 3; 92 | this.lblNameOfPipe.Text = "Name your pipe: \\\\?\\pipe\\"; 93 | // 94 | // tbPipeName 95 | // 96 | this.tbPipeName.Location = new System.Drawing.Point(144, 19); 97 | this.tbPipeName.Name = "tbPipeName"; 98 | this.tbPipeName.Size = new System.Drawing.Size(112, 20); 99 | this.tbPipeName.TabIndex = 4; 100 | this.tbPipeName.Text = "canpipe1"; 101 | // 102 | // btnStartSniff 103 | // 104 | this.btnStartSniff.Location = new System.Drawing.Point(14, 45); 105 | this.btnStartSniff.Name = "btnStartSniff"; 106 | this.btnStartSniff.Size = new System.Drawing.Size(75, 23); 107 | this.btnStartSniff.TabIndex = 5; 108 | this.btnStartSniff.Text = "Start pipe"; 109 | this.btnStartSniff.UseVisualStyleBackColor = true; 110 | this.btnStartSniff.Click += new System.EventHandler(this.btnStart_Click); 111 | // 112 | // btnStopSniff 113 | // 114 | this.btnStopSniff.Enabled = false; 115 | this.btnStopSniff.Location = new System.Drawing.Point(95, 45); 116 | this.btnStopSniff.Name = "btnStopSniff"; 117 | this.btnStopSniff.Size = new System.Drawing.Size(75, 23); 118 | this.btnStopSniff.TabIndex = 6; 119 | this.btnStopSniff.Text = "Stop pipe"; 120 | this.btnStopSniff.UseVisualStyleBackColor = true; 121 | this.btnStopSniff.Click += new System.EventHandler(this.btnStop_Click); 122 | // 123 | // pictureBox1 124 | // 125 | this.pictureBox1.BackgroundImage = global::CAN_Pipe.Properties.Resources.jesse2; 126 | this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; 127 | this.pictureBox1.Location = new System.Drawing.Point(267, 22); 128 | this.pictureBox1.Name = "pictureBox1"; 129 | this.pictureBox1.Size = new System.Drawing.Size(38, 53); 130 | this.pictureBox1.TabIndex = 7; 131 | this.pictureBox1.TabStop = false; 132 | this.pictureBox1.Click += new System.EventHandler(this.clickOnJesse); 133 | // 134 | // groupBoxSniffing 135 | // 136 | this.groupBoxSniffing.Controls.Add(this.tbPipeName); 137 | this.groupBoxSniffing.Controls.Add(this.pictureBox1); 138 | this.groupBoxSniffing.Controls.Add(this.btnStopSniff); 139 | this.groupBoxSniffing.Controls.Add(this.btnStartSniff); 140 | this.groupBoxSniffing.Controls.Add(this.lblNameOfPipe); 141 | this.groupBoxSniffing.Location = new System.Drawing.Point(12, 148); 142 | this.groupBoxSniffing.Name = "groupBoxSniffing"; 143 | this.groupBoxSniffing.Size = new System.Drawing.Size(318, 82); 144 | this.groupBoxSniffing.TabIndex = 8; 145 | this.groupBoxSniffing.TabStop = false; 146 | this.groupBoxSniffing.Text = "Sniffing"; 147 | // 148 | // groupBoxReplay 149 | // 150 | this.groupBoxReplay.Controls.Add(this.btnStopReplay); 151 | this.groupBoxReplay.Controls.Add(this.btnStartReplay); 152 | this.groupBoxReplay.Controls.Add(this.lblSelectedFileName); 153 | this.groupBoxReplay.Controls.Add(this.btnBrowseForCSV); 154 | this.groupBoxReplay.Controls.Add(this.label1); 155 | this.groupBoxReplay.Location = new System.Drawing.Point(12, 236); 156 | this.groupBoxReplay.Name = "groupBoxReplay"; 157 | this.groupBoxReplay.Size = new System.Drawing.Size(318, 94); 158 | this.groupBoxReplay.TabIndex = 9; 159 | this.groupBoxReplay.TabStop = false; 160 | this.groupBoxReplay.Text = "Replay"; 161 | // 162 | // btnStopReplay 163 | // 164 | this.btnStopReplay.Enabled = false; 165 | this.btnStopReplay.Location = new System.Drawing.Point(95, 65); 166 | this.btnStopReplay.Name = "btnStopReplay"; 167 | this.btnStopReplay.Size = new System.Drawing.Size(75, 23); 168 | this.btnStopReplay.TabIndex = 4; 169 | this.btnStopReplay.Text = "Stop replay"; 170 | this.btnStopReplay.UseVisualStyleBackColor = true; 171 | this.btnStopReplay.Click += new System.EventHandler(this.btnStopReplay_Click); 172 | // 173 | // btnStartReplay 174 | // 175 | this.btnStartReplay.Location = new System.Drawing.Point(14, 65); 176 | this.btnStartReplay.Name = "btnStartReplay"; 177 | this.btnStartReplay.Size = new System.Drawing.Size(75, 23); 178 | this.btnStartReplay.TabIndex = 3; 179 | this.btnStartReplay.Text = "Start replay"; 180 | this.btnStartReplay.UseVisualStyleBackColor = true; 181 | this.btnStartReplay.Click += new System.EventHandler(this.btnStartReplay_Click); 182 | // 183 | // lblSelectedFileName 184 | // 185 | this.lblSelectedFileName.AutoSize = true; 186 | this.lblSelectedFileName.Location = new System.Drawing.Point(12, 44); 187 | this.lblSelectedFileName.Name = "lblSelectedFileName"; 188 | this.lblSelectedFileName.Size = new System.Drawing.Size(68, 13); 189 | this.lblSelectedFileName.TabIndex = 2; 190 | this.lblSelectedFileName.Text = "Selected file:"; 191 | // 192 | // btnBrowseForCSV 193 | // 194 | this.btnBrowseForCSV.Location = new System.Drawing.Point(87, 15); 195 | this.btnBrowseForCSV.Name = "btnBrowseForCSV"; 196 | this.btnBrowseForCSV.Size = new System.Drawing.Size(75, 23); 197 | this.btnBrowseForCSV.TabIndex = 1; 198 | this.btnBrowseForCSV.Text = "Browse..."; 199 | this.btnBrowseForCSV.UseVisualStyleBackColor = true; 200 | this.btnBrowseForCSV.Click += new System.EventHandler(this.btnBrowseForCSV_Click); 201 | // 202 | // label1 203 | // 204 | this.label1.AutoSize = true; 205 | this.label1.Location = new System.Drawing.Point(12, 20); 206 | this.label1.Name = "label1"; 207 | this.label1.Size = new System.Drawing.Size(67, 13); 208 | this.label1.TabIndex = 0; 209 | this.label1.Text = "Choose CSV"; 210 | // 211 | // btnCANSnifferUpload 212 | // 213 | this.btnCANSnifferUpload.Location = new System.Drawing.Point(8, 67); 214 | this.btnCANSnifferUpload.Name = "btnCANSnifferUpload"; 215 | this.btnCANSnifferUpload.Size = new System.Drawing.Size(204, 21); 216 | this.btnCANSnifferUpload.TabIndex = 10; 217 | this.btnCANSnifferUpload.Text = "Upload CAN Sniffer to Arduino"; 218 | this.btnCANSnifferUpload.UseVisualStyleBackColor = true; 219 | this.btnCANSnifferUpload.Click += new System.EventHandler(this.btnCANSnifferUpload_Click_Click); 220 | // 221 | // groupBoxMain 222 | // 223 | this.groupBoxMain.Controls.Add(this.cbListOnlyArduino); 224 | this.groupBoxMain.Controls.Add(this.btnCANSenderUpload); 225 | this.groupBoxMain.Controls.Add(this.cmbSerialPorts); 226 | this.groupBoxMain.Controls.Add(this.btnRefresh); 227 | this.groupBoxMain.Controls.Add(this.btnCANSnifferUpload); 228 | this.groupBoxMain.Controls.Add(this.lblSelectCOMPort); 229 | this.groupBoxMain.Location = new System.Drawing.Point(12, 12); 230 | this.groupBoxMain.Name = "groupBoxMain"; 231 | this.groupBoxMain.Size = new System.Drawing.Size(318, 130); 232 | this.groupBoxMain.TabIndex = 10; 233 | this.groupBoxMain.TabStop = false; 234 | this.groupBoxMain.Text = "Set up everything here first"; 235 | // 236 | // cbListOnlyArduino 237 | // 238 | this.cbListOnlyArduino.AutoSize = true; 239 | this.cbListOnlyArduino.Location = new System.Drawing.Point(8, 44); 240 | this.cbListOnlyArduino.Name = "cbListOnlyArduino"; 241 | this.cbListOnlyArduino.Size = new System.Drawing.Size(156, 17); 242 | this.cbListOnlyArduino.TabIndex = 13; 243 | this.cbListOnlyArduino.Text = "List only Arduino COM ports"; 244 | this.cbListOnlyArduino.UseVisualStyleBackColor = true; 245 | this.cbListOnlyArduino.CheckedChanged += new System.EventHandler(this.btnRefresh_Click); 246 | // 247 | // btnCANSenderUpload 248 | // 249 | this.btnCANSenderUpload.Location = new System.Drawing.Point(8, 94); 250 | this.btnCANSenderUpload.Name = "btnCANSenderUpload"; 251 | this.btnCANSenderUpload.Size = new System.Drawing.Size(204, 21); 252 | this.btnCANSenderUpload.TabIndex = 11; 253 | this.btnCANSenderUpload.Text = "Upload CAN Sender to Arduino"; 254 | this.btnCANSenderUpload.UseVisualStyleBackColor = true; 255 | this.btnCANSenderUpload.Click += new System.EventHandler(this.btnCANSenderUpload_Click); 256 | // 257 | // ofdFileDialog 258 | // 259 | this.ofdFileDialog.FileName = "openFileDialog1"; 260 | // 261 | // Form1 262 | // 263 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 264 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 265 | this.ClientSize = new System.Drawing.Size(342, 343); 266 | this.Controls.Add(this.groupBoxReplay); 267 | this.Controls.Add(this.groupBoxMain); 268 | this.Controls.Add(this.groupBoxSniffing); 269 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 270 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 271 | this.MaximizeBox = false; 272 | this.Name = "Form1"; 273 | this.Text = "Arduino CAN bus tool"; 274 | this.Load += new System.EventHandler(this.Form1_Load); 275 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 276 | this.groupBoxSniffing.ResumeLayout(false); 277 | this.groupBoxSniffing.PerformLayout(); 278 | this.groupBoxReplay.ResumeLayout(false); 279 | this.groupBoxReplay.PerformLayout(); 280 | this.groupBoxMain.ResumeLayout(false); 281 | this.groupBoxMain.PerformLayout(); 282 | this.ResumeLayout(false); 283 | 284 | } 285 | 286 | #endregion 287 | 288 | private System.Windows.Forms.Label lblSelectCOMPort; 289 | private System.Windows.Forms.ComboBox cmbSerialPorts; 290 | private System.Windows.Forms.Button btnRefresh; 291 | private System.Windows.Forms.Label lblNameOfPipe; 292 | private System.Windows.Forms.TextBox tbPipeName; 293 | private System.Windows.Forms.Button btnStartSniff; 294 | private System.Windows.Forms.Button btnStopSniff; 295 | private System.Windows.Forms.PictureBox pictureBox1; 296 | private System.Windows.Forms.GroupBox groupBoxSniffing; 297 | private System.Windows.Forms.GroupBox groupBoxReplay; 298 | private System.Windows.Forms.Button btnCANSnifferUpload; 299 | private System.Windows.Forms.GroupBox groupBoxMain; 300 | private System.Windows.Forms.Button btnCANSenderUpload; 301 | private System.Windows.Forms.Label lblSelectedFileName; 302 | private System.Windows.Forms.Button btnBrowseForCSV; 303 | private System.Windows.Forms.Label label1; 304 | private System.Windows.Forms.OpenFileDialog ofdFileDialog; 305 | private System.Windows.Forms.Button btnStopReplay; 306 | private System.Windows.Forms.Button btnStartReplay; 307 | private System.Windows.Forms.CheckBox cbListOnlyArduino; 308 | } 309 | } 310 | 311 | -------------------------------------------------------------------------------- /CAN_Pipe/Form1.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.ComponentModel; 29 | using System.Data; 30 | using System.Drawing; 31 | using System.IO.Ports; 32 | using System.Linq; 33 | using System.Text; 34 | using System.Threading.Tasks; 35 | using System.Windows.Forms; 36 | using System.Threading; 37 | using System.Management; 38 | using Wireshark; 39 | using System.IO; 40 | 41 | namespace CAN_Pipe 42 | { 43 | public partial class Form1 : Form 44 | 45 | { 46 | Thread th; 47 | SerialPort port; 48 | WiresharkSender ws; 49 | string[] data; 50 | public Form1() 51 | { 52 | InitializeComponent(); 53 | } 54 | 55 | private void Form1_Load(object sender, EventArgs e) 56 | { 57 | btnRefresh_Click(sender, e); 58 | ofdFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); 59 | ofdFileDialog.FileName = ofdFileDialog.InitialDirectory + "\\CSV\\example.csv"; 60 | } 61 | 62 | private void clickOnJesse(object sender, EventArgs e) 63 | { 64 | Clipboard.SetText(@"\\?\pipe\" + tbPipeName.Text); 65 | } 66 | 67 | 68 | 69 | private void btnRefresh_Click(object sender, EventArgs e) 70 | { 71 | cmbSerialPorts.DataSource = null; 72 | cmbSerialPorts.Items.Clear(); 73 | ManagementObjectCollection ManObjReturn; 74 | ManagementObjectSearcher ManObjSearch; 75 | ManObjSearch = new ManagementObjectSearcher("SELECT * FROM Win32_PnPEntity WHERE Caption like '%(COM%'"); 76 | ManObjReturn = ManObjSearch.Get(); 77 | //this will show only arduino serial ports 78 | foreach (ManagementObject ManObj in ManObjReturn) 79 | { 80 | if (cbListOnlyArduino.Checked) 81 | { 82 | if (!cmbSerialPorts.Items.Contains(ManObj["Name"].ToString()) && (ManObj["Name"].ToString().Contains("Arduino"))) 83 | { 84 | String temp = ManObj["Name"].ToString(); 85 | temp = temp.Remove(0, temp.IndexOf("(")+1); 86 | temp = temp.Remove(temp.IndexOf(")"), temp.Length - temp.IndexOf(")")); 87 | cmbSerialPorts.Items.Add(temp); 88 | } 89 | } 90 | else 91 | { 92 | if (!cmbSerialPorts.Items.Contains(ManObj["Name"].ToString())) 93 | { 94 | String temp = ManObj["Name"].ToString(); 95 | temp = temp.Remove(0, temp.IndexOf("(")+1); 96 | temp = temp.Remove(temp.IndexOf(")"), temp.Length- temp.IndexOf(")") ); 97 | cmbSerialPorts.Items.Add(temp); 98 | } 99 | } 100 | } 101 | if (cmbSerialPorts.Items.Count != 0) cmbSerialPorts.SelectedIndex = 0; 102 | 103 | 104 | } 105 | 106 | 107 | private void btnStart_Click(object sender, EventArgs e) 108 | { 109 | btnStartSniff.Enabled = false; 110 | btnStopSniff.Enabled = true; 111 | th = new Thread(startSniffing); 112 | th.Start(); 113 | } 114 | 115 | private void btnStop_Click(object sender, EventArgs e) 116 | { 117 | btnStartSniff.Enabled = true; 118 | btnStopSniff.Enabled = false; 119 | ws.WiresharkPipe.Close(); 120 | th.Abort(); 121 | if (port.IsOpen) port.Close(); 122 | port.Dispose(); 123 | } 124 | 125 | private void startSniffing() 126 | { 127 | string text = ""; 128 | this.Invoke((MethodInvoker)delegate () 129 | { 130 | text = cmbSerialPorts.SelectedItem.ToString(); 131 | }); 132 | port = new SerialPort(text, 115200); 133 | bgw_DoSniffing(); 134 | 135 | } 136 | private void bgw_DoSniffing() 137 | { 138 | try 139 | { 140 | port.Open(); 141 | ws = new Wireshark.WiresharkSender(tbPipeName.Text, 227); 142 | while (true) 143 | { 144 | if (ws.isConnected) 145 | { 146 | try 147 | { 148 | string line = port.ReadLine(); 149 | line = line.Replace("\r", string.Empty); 150 | string[] lines = line.Split('|'); 151 | Int32 canid = Convert.ToInt32(lines[0]); 152 | byte[] id = new byte[4]; 153 | id = BitConverter.GetBytes(canid); 154 | lines = lines[1].Split(' '); 155 | byte[] data = new byte[lines.Length - 1]; 156 | for (int i = 0; i < data.Length; i++) 157 | { 158 | if (lines[i] != "") 159 | { 160 | data[i] = Convert.ToByte(lines[i]); 161 | } 162 | } 163 | byte[] pcap = new byte[4 + 4 + data.Length]; 164 | pcap[0] = id[3]; 165 | pcap[1] = id[2]; 166 | pcap[2] = id[1]; 167 | pcap[3] = id[0]; 168 | pcap[4] = Convert.ToByte(data.Length); 169 | pcap[5] = 0; 170 | pcap[6] = 0; 171 | pcap[7] = 0; 172 | for (int i = 8; i < pcap.Length; i++) 173 | { 174 | pcap[i] = data[i - 8]; 175 | } 176 | ws.SendToWireshark(pcap, 0, pcap.Length); 177 | } 178 | catch (Exception ex) 179 | { 180 | MessageBox.Show(ex.Message); 181 | } 182 | } 183 | } 184 | } 185 | catch (Exception ex2) 186 | { 187 | MessageBox.Show(ex2.Message); 188 | } 189 | } 190 | 191 | private void btnCANSnifferUpload_Click_Click(object sender, EventArgs e) 192 | { 193 | try 194 | { 195 | ArduinoUploader.ArduinoSketchUploaderOptions options = new ArduinoUploader.ArduinoSketchUploaderOptions(); 196 | options.ArduinoModel = ArduinoUploader.Hardware.ArduinoModel.UnoR3; 197 | options.PortName = cmbSerialPorts.SelectedItem.ToString(); 198 | options.PortName = options.PortName.Substring(options.PortName.IndexOf("COM"), options.PortName.Length-options.PortName.LastIndexOf(")")+4); 199 | options.FileName = Directory.GetCurrentDirectory() + "\\sniffer\\sniffer.ino.standard.hex"; 200 | ArduinoUploader.ArduinoSketchUploader up = new ArduinoUploader.ArduinoSketchUploader(options); 201 | up.UploadSketch(); 202 | MessageBox.Show("Upload complete without errors"); 203 | } 204 | catch (Exception ex) 205 | { 206 | MessageBox.Show("Error: " + ex.Message); 207 | throw; 208 | } 209 | } 210 | 211 | private void btnCANSenderUpload_Click(object sender, EventArgs e) 212 | { 213 | try 214 | { 215 | ArduinoUploader.ArduinoSketchUploaderOptions options = new ArduinoUploader.ArduinoSketchUploaderOptions(); 216 | options.ArduinoModel = ArduinoUploader.Hardware.ArduinoModel.UnoR3; 217 | options.PortName = cmbSerialPorts.SelectedItem.ToString(); 218 | options.PortName = options.PortName.Substring(options.PortName.IndexOf("COM"), options.PortName.Length - options.PortName.LastIndexOf(")") + 4); 219 | options.FileName = Directory.GetCurrentDirectory() + "\\sender\\sender.ino.standard.hex"; 220 | ArduinoUploader.ArduinoSketchUploader up = new ArduinoUploader.ArduinoSketchUploader(options); 221 | up.UploadSketch(); 222 | MessageBox.Show("Upload complete without errors"); 223 | } 224 | catch (Exception ex) 225 | { 226 | MessageBox.Show("Error: " + ex.Message); 227 | throw; 228 | } 229 | } 230 | 231 | private void btnBrowseForCSV_Click(object sender, EventArgs e) 232 | { 233 | ofdFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); 234 | ofdFileDialog.FileName = ofdFileDialog.InitialDirectory + "\\CSV\\example.csv"; 235 | ofdFileDialog.ShowDialog(); 236 | lblSelectedFileName.Text = lblSelectedFileName.Text+" "+ofdFileDialog.SafeFileName; 237 | } 238 | 239 | private void btnStartReplay_Click(object sender, EventArgs e) 240 | { 241 | btnStartReplay.Enabled = false; 242 | btnStopReplay.Enabled = true; 243 | data = File.ReadAllLines(ofdFileDialog.FileName); 244 | th = new Thread(startReplay); 245 | th.Start(); 246 | } 247 | 248 | private void startReplay() 249 | { 250 | string text = ""; 251 | this.Invoke((MethodInvoker)delegate () 252 | { 253 | text = cmbSerialPorts.SelectedItem.ToString(); 254 | }); 255 | port = new SerialPort(text, 115200); 256 | bgw_DoReplay(); 257 | 258 | } 259 | 260 | private void bgw_DoReplay() 261 | { 262 | try 263 | { 264 | port.Open(); 265 | while (true) 266 | { 267 | for (int i = 1; i < data.Length; i++) 268 | { 269 | 270 | Thread.Sleep(10); //Time to send data dn let arduino parse it; 271 | port.Write(data[i]+"\n"); 272 | } 273 | 274 | } 275 | } 276 | catch (Exception ex2) 277 | { 278 | MessageBox.Show(ex2.Message); 279 | } 280 | } 281 | 282 | private void btnStopReplay_Click(object sender, EventArgs e) 283 | { 284 | btnStartReplay.Enabled = true; 285 | btnStopReplay.Enabled = false; 286 | th.Abort(); 287 | if (port.IsOpen) port.Close(); 288 | port.Dispose(); 289 | } 290 | } 291 | } 292 | 293 | 294 | -------------------------------------------------------------------------------- /CAN_Pipe/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace CAN_Pipe 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CAN_Pipe/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("CAN_Pipe")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CAN_Pipe")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 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("069804c7-5b9d-4554-817a-c66d23083286")] 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 | -------------------------------------------------------------------------------- /CAN_Pipe/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 CAN_Pipe.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CAN_Pipe.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap jesse2 { 67 | get { 68 | object obj = ResourceManager.GetObject("jesse2", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /CAN_Pipe/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 | 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 | 121 | 122 | ..\Resources\jesse2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /CAN_Pipe/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 CAN_Pipe.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CAN_Pipe/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CAN_Pipe/README.md: -------------------------------------------------------------------------------- 1 | # CAN-pipe 2 | A tool for creating a windows named pipe to capture CAN bus traffic using wireshark. 3 | 4 | # Requirements: 5 | - An arduino with a CAN shield/Device. 6 | Note: upload sketch only works for UnoR3, it does not work with arduino CLONES, 7 | please use original arduino HW to support the cause. 8 | - Arduino IDE 9 | - An MCP2515 based arduino shield. 10 | - knowledge on how to prgram an arduino. 11 | - a windows based computer. 12 | - Some C# coding skills. (recommended for debugging) 13 | 14 | # THINGS YOU NEED TO KNOW 15 | 1. The code was written using visual studio 2017 community edition. 16 | 2. This solution has an arudino sketch designed for use with an UNO but can be modified to fit any other arduino, be aware of the correct pin to use for your choice of CAN bus shield. 17 | 3. When using wireshark, you might want to use 'wireshark legacy' as that is the only option to use that supports saving of named pipes in windows. 18 | 19 | # If you get a Wireshark error, it is likley there is no data on the CAN bus you are trying to sniff 20 | -------------------------------------------------------------------------------- /CAN_Pipe/Resources/jesse2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/Resources/jesse2.jpg -------------------------------------------------------------------------------- /CAN_Pipe/Wireshark.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Runtime.InteropServices; 28 | using System.IO; 29 | using System.Diagnostics; 30 | using System.IO.Pipes; 31 | using System.Threading; 32 | using System.Windows.Forms; 33 | // 34 | // object creation could be done with 35 | // var ws=new Wireshark.WiresharkSender("bacnet",165); // pipe name is \\.\pipe\bacnet 36 | // 37 | // data to wireshark could be sent with something like that 38 | // if (ws.isConnected) 39 | // ws.SendToWireshark(new byte[]{0x55,0xFF,0,5,6,0,0,4}, 0, 8); 40 | // 41 | // Wireshark can be launch with : Wireshark -ni \\.\pipe\bacnet 42 | // 43 | // ... enjoy 44 | // 45 | namespace Wireshark 46 | { 47 | // Pcap Global Header 48 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 49 | struct pcap_hdr_g 50 | { 51 | UInt32 magic_number; /* magic number */ 52 | UInt16 version_major; /* major version number */ 53 | UInt16 version_minor; /* minor version number */ 54 | Int32 thiszone; /* GMT to local correction */ 55 | UInt32 sigfigs; /* accuracy of timestamps */ 56 | UInt32 snaplen; /* max length of captured packets, in octets */ 57 | UInt32 network; /* data link type */ 58 | 59 | public pcap_hdr_g(UInt32 snaplen, UInt32 network) 60 | { 61 | magic_number = 0xa1b2c3d4; 62 | version_major = 2; 63 | version_minor = 4; 64 | thiszone = 0; 65 | sigfigs = 0; 66 | this.snaplen = snaplen; 67 | this.network = network; 68 | } 69 | 70 | // struct Marshaling 71 | // Maybe a 'manual' byte by byte serialization could be required on some systems 72 | // work well on Win32, Win64 .NET 3.0 to 4.5 73 | public byte[] ToByteArray() 74 | { 75 | int rawsize = Marshal.SizeOf(this); 76 | byte[] rawdatas = new byte[rawsize]; 77 | GCHandle handle = GCHandle.Alloc(rawdatas, GCHandleType.Pinned); 78 | IntPtr buffer = handle.AddrOfPinnedObject(); 79 | Marshal.StructureToPtr(this, buffer, false); 80 | handle.Free(); 81 | return rawdatas; 82 | } 83 | } 84 | 85 | // Pcap Packet Header 86 | [StructLayout(LayoutKind.Sequential, Pack = 1)] 87 | struct pcap_hdr_p 88 | { 89 | UInt32 ts_sec; /* timestamp seconds */ 90 | UInt32 ts_usec; /* timestamp microseconds */ 91 | UInt32 incl_len; /* number of octets of packet saved in file */ 92 | UInt32 orig_len; /* actual length of packet */ 93 | 94 | public pcap_hdr_p(UInt32 lenght, UInt32 datetime, UInt32 microsecond) 95 | { 96 | incl_len = orig_len = lenght; 97 | ts_sec = datetime; 98 | ts_usec = microsecond; 99 | } 100 | 101 | // struct Marshaling 102 | // Maybe a 'manual' byte by byte serialise could be required on some system 103 | public byte[] ToByteArray() 104 | { 105 | int rawsize = Marshal.SizeOf(this); 106 | byte[] rawdatas = new byte[rawsize]; 107 | GCHandle handle = GCHandle.Alloc(rawdatas, GCHandleType.Pinned); 108 | IntPtr buffer = handle.AddrOfPinnedObject(); 109 | Marshal.StructureToPtr(this, buffer, false); 110 | handle.Free(); 111 | return rawdatas; 112 | } 113 | } 114 | 115 | public class WiresharkSender 116 | { 117 | public NamedPipeServerStream WiresharkPipe; 118 | 119 | bool IsConnected = false; 120 | 121 | string pipe_name; 122 | UInt32 pcap_netid; 123 | 124 | object verrou = new object(); 125 | 126 | public WiresharkSender(string pipe_name, UInt32 pcap_netid) 127 | { 128 | this.pipe_name = pipe_name; 129 | this.pcap_netid = pcap_netid; 130 | 131 | // Open the pipe and wait to Wireshark on a background thread 132 | Thread th = new Thread(PipeCreate); 133 | th.IsBackground = true; 134 | th.Start(); 135 | } 136 | 137 | private void PipeCreate() 138 | { 139 | 140 | try 141 | { 142 | WiresharkPipe = new NamedPipeServerStream(pipe_name, PipeDirection.Out, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous); 143 | // Wait 144 | WiresharkPipe.WaitForConnection(); 145 | 146 | // Wireshark Global Header 147 | pcap_hdr_g p = new pcap_hdr_g(65535, pcap_netid); 148 | byte[] bh = p.ToByteArray(); 149 | WiresharkPipe.Write(bh, 0, bh.Length); 150 | 151 | IsConnected = true; 152 | 153 | } 154 | catch (Exception ex) 155 | { 156 | //MessageBox.Show(ex.Message); 157 | } 158 | 159 | } 160 | 161 | public bool isConnected 162 | { 163 | get { return IsConnected; } 164 | } 165 | 166 | private UInt32 DateTimeToUnixTimestamp(DateTime dateTime) 167 | { 168 | return (UInt32)(dateTime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds; 169 | } 170 | 171 | public bool SendToWireshark(byte[] buffer, int offset, int lenght) 172 | { 173 | return SendToWireshark(buffer, offset, lenght, DateTime.Now); 174 | } 175 | 176 | public bool SendToWireshark(byte[] buffer, int offset, int lenght, DateTime date) 177 | { 178 | UInt32 date_sec, date_usec; 179 | 180 | // Suppress all values for ms, us and ns 181 | DateTime d2 = new DateTime((date.Ticks / (long)10000000) * (long)10000000); 182 | 183 | date_sec = DateTimeToUnixTimestamp(date); 184 | date_usec = (UInt32)((date.Ticks - d2.Ticks) / 10); 185 | 186 | return SendToWireshark(buffer, offset, lenght, date_sec, date_usec); 187 | } 188 | 189 | public bool SendToWireshark(byte[] buffer, int offset, int lenght, UInt32 date_sec, UInt32 date_usec) 190 | { 191 | if (IsConnected == false) 192 | return false; 193 | 194 | if (buffer == null) return false; 195 | if (buffer.Length < (offset + lenght)) return false; 196 | 197 | pcap_hdr_p pHdr = new pcap_hdr_p((UInt32)lenght, date_sec, date_usec); 198 | byte[] b = pHdr.ToByteArray(); 199 | 200 | try 201 | { 202 | // Wireshark Header 203 | WiresharkPipe.Write(b, 0, b.Length); 204 | // Bacnet packet 205 | WiresharkPipe.Write(buffer, offset, lenght); 206 | } 207 | catch (System.IO.IOException) 208 | { 209 | // broken pipe, try to restart 210 | IsConnected = false; 211 | WiresharkPipe.Close(); 212 | WiresharkPipe.Dispose(); 213 | Thread th = new Thread(PipeCreate); 214 | th.IsBackground = true; 215 | th.Start(); 216 | return false; 217 | } 218 | catch (Exception) 219 | { 220 | // Unknow error, not due to the pipe 221 | // No need to restart it 222 | return false; 223 | } 224 | 225 | return true; 226 | } 227 | 228 | } 229 | } -------------------------------------------------------------------------------- /CAN_Pipe/bin/Debug/CAN_Pipe.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/bin/Debug/CAN_Pipe.exe -------------------------------------------------------------------------------- /CAN_Pipe/bin/Debug/CAN_Pipe.exe.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CAN_Pipe/bin/Debug/CAN_Pipe.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/bin/Debug/CAN_Pipe.pdb -------------------------------------------------------------------------------- /CAN_Pipe/can.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/can.ico -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CAN_Pipe.Form1.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/CAN_Pipe.Form1.resources -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CAN_Pipe.Properties.Resources.resources: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/CAN_Pipe.Properties.Resources.resources -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CAN_Pipe.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\bin\Debug\CAN_Pipe.exe.config 2 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\bin\Debug\CAN_Pipe.exe 3 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\bin\Debug\CAN_Pipe.pdb 4 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\obj\Debug\CAN_Pipe.csprojResolveAssemblyReference.cache 5 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\obj\Debug\CAN_Pipe.Form1.resources 6 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\obj\Debug\CAN_Pipe.Properties.Resources.resources 7 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\obj\Debug\CAN_Pipe.csproj.GenerateResource.Cache 8 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\obj\Debug\CAN_Pipe.exe 9 | c:\users\mshkatov\documents\visual studio 2017\Projects\CAN_Pipe\CAN_Pipe\obj\Debug\CAN_Pipe.pdb 10 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\CAN_Pipe.exe.config 11 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\CAN_Pipe.exe 12 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\CAN_Pipe.pdb 13 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\obj\Debug\CAN_Pipe.csprojResolveAssemblyReference.cache 14 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\obj\Debug\CAN_Pipe.Form1.resources 15 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\obj\Debug\CAN_Pipe.Properties.Resources.resources 16 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\obj\Debug\CAN_Pipe.csproj.GenerateResource.Cache 17 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\obj\Debug\CAN_Pipe.exe 18 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\obj\Debug\CAN_Pipe.pdb 19 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\ArduinoUploader.dll 20 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\IntelHexFormatReader.dll 21 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\RJCP.SerialPortStream.dll 22 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\NLog.dll 23 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\Sniffer\sniffer.ino.standard.hex 24 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\Sender\sender.ino.standard.hex 25 | C:\Users\mshkatov\Source\Repos\CAN-pipe\CAN_Pipe\bin\Debug\CSV\example.csv 26 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CSV\example.csv 27 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\Sender\sender.ino.standard.hex 28 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\Sniffer\sniffer.ino.standard.hex 29 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CAN_Pipe.exe.config 30 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CAN_Pipe.exe 31 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CAN_Pipe.pdb 32 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\ArduinoUploader.dll 33 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\IntelHexFormatReader.dll 34 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\NLog.dll 35 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\RJCP.SerialPortStream.dll 36 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.csprojResolveAssemblyReference.cache 37 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.Form1.resources 38 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.Properties.Resources.resources 39 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.csproj.GenerateResource.Cache 40 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.exe 41 | C:\Users\MShkatov\Source\Repos\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.pdb 42 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CSV\example.csv 43 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\Sender\sender.ino.standard.hex 44 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\Sniffer\sniffer.ino.standard.hex 45 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CAN_Pipe.exe.config 46 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CAN_Pipe.exe 47 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\CAN_Pipe.pdb 48 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\ArduinoUploader.dll 49 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\IntelHexFormatReader.dll 50 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\NLog.dll 51 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\bin\Debug\RJCP.SerialPortStream.dll 52 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.csprojAssemblyReference.cache 53 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.Form1.resources 54 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.Properties.Resources.resources 55 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.csproj.GenerateResource.cache 56 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.csproj.CoreCompileInputs.cache 57 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.csproj.CopyComplete 58 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.exe 59 | C:\Users\Mickey\Documents\GitHub\CAN-Bus-Arduino-Tool\CAN_Pipe\obj\Debug\CAN_Pipe.pdb 60 | -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CAN_Pipe.csproj.GenerateResource.Cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/CAN_Pipe.csproj.GenerateResource.Cache -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CAN_Pipe.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/CAN_Pipe.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CAN_Pipe.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/CAN_Pipe.exe -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CAN_Pipe.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/CAN_Pipe.pdb -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | c10e71a5470a34b101fcbac3301ccfac09107ab8 2 | -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /CAN_Pipe/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HackingThings/CAN-Bus-Arduino-Tool/8ed9df6fb3c4c0bc97564025edab04c1d523b008/CAN_Pipe/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll -------------------------------------------------------------------------------- /CAN_Pipe/sender/sender.ino: -------------------------------------------------------------------------------- 1 | // demo: CAN-BUS Shield, send data 2 | #include 3 | #include 4 | 5 | // the cs pin of the version after v1.1 is default to D9 6 | // v0.9b and v1.0 is default D10 7 | const int SPI_CS_PIN = 9; 8 | const int ledHIGH = 1; 9 | const int ledLOW = 0; 10 | 11 | MCP_CAN CAN(SPI_CS_PIN); // Set CS pin 12 | 13 | void setup() 14 | { 15 | Serial.begin(115200); 16 | 17 | while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k 18 | { 19 | Serial.println("CAN BUS Shield init fail"); 20 | Serial.println(" Init CAN BUS Shield again"); 21 | delay(100); 22 | } 23 | Serial.println("CAN BUS Shield init ok!"); 24 | } 25 | 26 | unsigned char stmp[8] = {ledHIGH, 1, 2, 3, ledLOW, 5, 6, 7}; 27 | 28 | void loop() 29 | { 30 | String readString = ""; 31 | while (Serial.available() > 0) 32 | { 33 | delay(1); 34 | char recieved = Serial.read(); 35 | if (recieved!=' ') readString += recieved; 36 | // Process message when new line character is recieved 37 | if (recieved == '\n') 38 | { 39 | int addr =0; 40 | //Parse address to bytes 41 | int marker = readString.indexOf(','); 42 | //Serial.print(readString.substring(0,marker)); 43 | addr = (int)strtol(readString.substring(0,marker).c_str(), 0, 16); 44 | //Serial.println(addr); 45 | String dataString = readString.substring(readString.indexOf(',')+1); 46 | byte data[dataString.length()-1]; //-1 bacause of \n 47 | for (int i=0; i 7 | #include "mcp_can.h" 8 | 9 | 10 | // the cs pin of the version after v1.1 is default to D9 11 | // v0.9b and v1.0 is default D10 12 | const int SPI_CS_PIN = 9; 13 | const int LED=8; 14 | boolean ledON=1; 15 | MCP_CAN CAN(SPI_CS_PIN); // Set CS pin 16 | 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | Serial.println("0|0 0 0 0 0 0 0 0"); 21 | 22 | while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k 23 | { 24 | delay(100); 25 | Serial.println("0|0 0 0 0 0 0 0 0"); 26 | } 27 | } 28 | 29 | 30 | void loop() 31 | { 32 | unsigned char len = 0; 33 | unsigned char buf[8]; 34 | 35 | if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming 36 | { 37 | CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf 38 | 39 | unsigned long canId = CAN.getCanId(); 40 | 41 | Serial.print(canId); 42 | Serial.print("|"); 43 | 44 | for(int i = 0; i