diff --git a/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs b/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs index 220105e19..64cd0faef 100644 --- a/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs +++ b/TBF/BenchControl/Network/Camera/CLP1611/Camera.cs @@ -183,7 +183,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 { UiBridge.Bridge.OnCameraInfo(this.cameraIdx, string.Format("{0} ver.{1} {2} s/n {3}", Name, sdCardVer, ipAddress, CameraCfg.HardwareAddress)); - ClpUserName = (sdCardVer[0] == '1') ? "tbf" : "pi"; + ClpUserName = (sdCardVer.Length > 0 && sdCardVer[0] == '1') ? "tbf" : "pi"; rtpUdpLocalPort = UdpPortBase + 4 * cameraIdx; rtcpUdpLocalPort = UdpPortBase + 4 * cameraIdx + 1; @@ -437,49 +437,53 @@ namespace TBF.BenchControl.Network.Camera.CLP1611 { scpClient.Connect(); - /// - /// Synchronize files in camera /home/tbf/clp directory with the files in "TBF/CameraBinaryFiles" project folder - /// - using (var sshClient = new SshClient(connectionInfo)) + if (sdCardVer.Length > 0 && sdCardVer[0] == '1') { - sshClient.Connect(); - - DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(System.Windows.Forms.Application.StartupPath, "CameraBinaryFiles")); - SHA1 sha1calculator = SHA1.Create(); - StringBuilder sha1str = new StringBuilder(); - - foreach (FileInfo fi in dirInfo.GetFiles()) + /// + /// Synchronize files in camera /home/tbf/clp directory with the files in "TBF/CameraBinaryFiles" project folder + /// + using (var sshClient = new SshClient(connectionInfo)) { - lock (fileUploadLock) + sshClient.Connect(); + + DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(System.Windows.Forms.Application.StartupPath, "CameraBinaryFiles")); + SHA1 sha1calculator = SHA1.Create(); + StringBuilder sha1str = new StringBuilder(); + + FileInfo[] fileInfos = dirInfo.GetFiles(); + foreach (FileInfo fi in fileInfos) { - FileStream fs = fi.Open(FileMode.Open); - fs.Position = 0; - byte[] sha1 = sha1calculator.ComputeHash(fs); - fs.Close(); - - sha1str.Clear(); - foreach (var b in sha1) sha1str.Append(b.ToString("x2")); - - if (!sha1sumResponse.Contains(string.Format("{0} clp/{1}", sha1str, fi.Name))) + lock (fileUploadLock) { - /// Copy a file to the camera if SHA1 sum is different of the file is missing - log.InfoFormat("{0}, IP={1}, Uploading file {2}", Name, IPAddress, fi.Name); - scpClient.Upload(fi, string.Format("clp/{0}", fi.Name)); + FileStream fs = fi.Open(FileMode.Open); + fs.Position = 0; + byte[] sha1 = sha1calculator.ComputeHash(fs); + fs.Close(); + + sha1str.Clear(); + foreach (var b in sha1) sha1str.Append(b.ToString("x2")); + + if (!sha1sumResponse.Contains(string.Format("{0} clp/{1}", sha1str, fi.Name))) + { + /// Copy a file to the camera if SHA1 sum is different of the file is missing + log.InfoFormat("{0}, IP={1}, Uploading file {2}", Name, IPAddress, fi.Name); + scpClient.Upload(fi, string.Format("clp/{0}", fi.Name)); + } } - } - if (!sha1sumResponse.Contains(fi.Name)) - { - /// Change file properties if it was a new file - string command = string.Format("chmod 755 clp/{0}", fi.Name); - log.InfoFormat("{0}, IP={1}, Executing command '{2}'", Name, IPAddress, command); - sshClient.CreateCommand(command).Execute(); + if (!sha1sumResponse.Contains(fi.Name)) + { + /// Change file properties if it was a new file + string command = string.Format("chmod 755 clp/{0}", fi.Name); + log.InfoFormat("{0}, IP={1}, Executing command '{2}'", Name, IPAddress, command); + sshClient.CreateCommand(command).Execute(); - //if (fi.Name.Equals("runmeonce")) - //{ - // log.InfoFormat("{0}, IP={1}, Executing command 'sudo clp/runmeonce'", Name, IPAddress); - // sshClient.CreateCommand("sudo clp/runmeonce").Execute(); - //} + //if (fi.Name.Equals("runmeonce")) + //{ + // log.InfoFormat("{0}, IP={1}, Executing command 'sudo clp/runmeonce'", Name, IPAddress); + // sshClient.CreateCommand("sudo clp/runmeonce").Execute(); + //} + } } } } diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 1a7fde354..128a9aa39 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.26.1527.0")] -[assembly: AssemblyFileVersion("2.26.1527.0")] +[assembly: AssemblyVersion("2.26.1528.0")] +[assembly: AssemblyFileVersion("2.26.1528.0")]