Camera binary files are only synchronized for SD v.1.x, ver. 2.26.1528

This commit is contained in:
Milan Hanajik
2020-10-16 14:07:57 +02:00
parent b145c71ee3
commit 91392f9452
2 changed files with 43 additions and 39 deletions
@@ -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)); 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; rtpUdpLocalPort = UdpPortBase + 4 * cameraIdx;
rtcpUdpLocalPort = UdpPortBase + 4 * cameraIdx + 1; rtcpUdpLocalPort = UdpPortBase + 4 * cameraIdx + 1;
@@ -437,49 +437,53 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{ {
scpClient.Connect(); scpClient.Connect();
/// if (sdCardVer.Length > 0 && sdCardVer[0] == '1')
/// Synchronize files in camera /home/tbf/clp directory with the files in "TBF/CameraBinaryFiles" project folder
///
using (var sshClient = new SshClient(connectionInfo))
{ {
sshClient.Connect(); ///
/// Synchronize files in camera /home/tbf/clp directory with the files in "TBF/CameraBinaryFiles" project folder
DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(System.Windows.Forms.Application.StartupPath, "CameraBinaryFiles")); ///
SHA1 sha1calculator = SHA1.Create(); using (var sshClient = new SshClient(connectionInfo))
StringBuilder sha1str = new StringBuilder();
foreach (FileInfo fi in dirInfo.GetFiles())
{ {
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); lock (fileUploadLock)
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 FileStream fs = fi.Open(FileMode.Open);
log.InfoFormat("{0}, IP={1}, Uploading file {2}", Name, IPAddress, fi.Name); fs.Position = 0;
scpClient.Upload(fi, string.Format("clp/{0}", fi.Name)); 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)) if (!sha1sumResponse.Contains(fi.Name))
{ {
/// Change file properties if it was a new file /// Change file properties if it was a new file
string command = string.Format("chmod 755 clp/{0}", fi.Name); string command = string.Format("chmod 755 clp/{0}", fi.Name);
log.InfoFormat("{0}, IP={1}, Executing command '{2}'", Name, IPAddress, command); log.InfoFormat("{0}, IP={1}, Executing command '{2}'", Name, IPAddress, command);
sshClient.CreateCommand(command).Execute(); sshClient.CreateCommand(command).Execute();
//if (fi.Name.Equals("runmeonce")) //if (fi.Name.Equals("runmeonce"))
//{ //{
// log.InfoFormat("{0}, IP={1}, Executing command 'sudo clp/runmeonce'", Name, IPAddress); // log.InfoFormat("{0}, IP={1}, Executing command 'sudo clp/runmeonce'", Name, IPAddress);
// sshClient.CreateCommand("sudo clp/runmeonce").Execute(); // sshClient.CreateCommand("sudo clp/runmeonce").Execute();
//} //}
}
} }
} }
} }
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.26.1527.0")] [assembly: AssemblyVersion("2.26.1528.0")]
[assembly: AssemblyFileVersion("2.26.1527.0")] [assembly: AssemblyFileVersion("2.26.1528.0")]