TBF/CameraBinaryFiles2 folder with synchronization for SD v.2.x (!!! file upload NOK).

This commit is contained in:
Milan Hanajik
2020-11-13 10:23:44 +01:00
parent 09da203962
commit a5a139aff6
2 changed files with 63 additions and 41 deletions
@@ -38,10 +38,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
}
const string ClpUserName = "tbf";
string ClpUserName = string.Empty; /// Either "tbf" or "pi" after a successful detection
const string ClpPassword = "C1ern4V0d4";
private static Object fileUploadLock = new Object();
@@ -184,6 +183,8 @@ 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.Length > 0 && sdCardVer[0] == '1') ? "tbf" : "pi";
rtpUdpLocalPort = UdpPortBase + 4 * cameraIdx;
rtcpUdpLocalPort = UdpPortBase + 4 * cameraIdx + 1;
msrmntUdpLocalPort = UdpPortBase + 4 * cameraIdx + 2;
@@ -436,6 +437,22 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{
scpClient.Connect();
DirectoryInfo dirInfo = null;
if (sdCardVer.Length > 0)
{
switch (sdCardVer[0])
{
case '1':
dirInfo = new DirectoryInfo(Path.Combine(System.Windows.Forms.Application.StartupPath, "CameraBinaryFiles"));
break;
case '2':
dirInfo = new DirectoryInfo(Path.Combine(System.Windows.Forms.Application.StartupPath, "CameraBinaryFiles2"));
break;
}
}
if (dirInfo != null)
{
///
/// Synchronize files in camera /home/tbf/clp directory with the files in "TBF/CameraBinaryFiles" project folder
///
@@ -443,11 +460,11 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{
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())
FileInfo[] fileInfos = dirInfo.GetFiles();
foreach (FileInfo fi in fileInfos)
{
lock (fileUploadLock)
{
@@ -463,14 +480,14 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
{
/// 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));
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);
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();
@@ -482,6 +499,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
}
}
}
}
scpConnected = scpClient.IsConnected;
running = true;
@@ -720,6 +738,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
int hgh = hiRes ? 960 : 480;
string command = string.Format("/opt/vc/bin/raspivid -t 0 -cd MJPEG -w {0} -h {1} -fps 30 -b 8000000 -o - | gst-launch-1.0 fdsrc ! \"image/jpeg,framerate=30/1\" ! jpegparse ! rtpjpegpay ! udpsink host={2} port={3}",
wid, hgh, NetAdapter.IPAddress, rtpUdpLocalPort);
//string command = string.Format("~/userland/build/bin/raspivid -t 0 -cd MJPEG -w {0} -h {1} -fps 30 -b 8000000 -o - | gst-launch-1.0 fdsrc ! \"image/jpeg,framerate=30/1\" ! jpegparse ! rtpjpegpay ! udpsink host={2} port={3}",
// wid, hgh, NetAdapter.IPAddress, rtpUdpLocalPort);
return new LiveStreamOp(this, Telnet, command);
}
+3 -1
View File
@@ -3663,7 +3663,9 @@
<Name>Users</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="CameraBinaryFiles2\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.