TBF/CameraBinaryFiles2 folder with synchronization for SD v.2.x (!!! file upload NOK).
This commit is contained in:
@@ -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";
|
const string ClpPassword = "C1ern4V0d4";
|
||||||
|
|
||||||
|
|
||||||
private static Object fileUploadLock = new Object();
|
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));
|
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;
|
rtpUdpLocalPort = UdpPortBase + 4 * cameraIdx;
|
||||||
rtcpUdpLocalPort = UdpPortBase + 4 * cameraIdx + 1;
|
rtcpUdpLocalPort = UdpPortBase + 4 * cameraIdx + 1;
|
||||||
msrmntUdpLocalPort = UdpPortBase + 4 * cameraIdx + 2;
|
msrmntUdpLocalPort = UdpPortBase + 4 * cameraIdx + 2;
|
||||||
@@ -436,49 +437,66 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
{
|
{
|
||||||
scpClient.Connect();
|
scpClient.Connect();
|
||||||
|
|
||||||
///
|
DirectoryInfo dirInfo = null;
|
||||||
/// Synchronize files in camera /home/tbf/clp directory with the files in "TBF/CameraBinaryFiles" project folder
|
if (sdCardVer.Length > 0)
|
||||||
///
|
|
||||||
using (var sshClient = new SshClient(connectionInfo))
|
|
||||||
{
|
{
|
||||||
sshClient.Connect();
|
switch (sdCardVer[0])
|
||||||
|
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
lock (fileUploadLock)
|
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
|
||||||
|
///
|
||||||
|
using (var sshClient = new SshClient(connectionInfo))
|
||||||
|
{
|
||||||
|
sshClient.Connect();
|
||||||
|
|
||||||
|
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();
|
||||||
//}
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -718,8 +736,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
|||||||
{
|
{
|
||||||
int wid = hiRes ? 1280 : 640;
|
int wid = hiRes ? 1280 : 640;
|
||||||
int hgh = hiRes ? 960 : 480;
|
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}",
|
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);
|
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);
|
return new LiveStreamOp(this, Telnet, command);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -3663,7 +3663,9 @@
|
|||||||
<Name>Users</Name>
|
<Name>Users</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Folder Include="CameraBinaryFiles2\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
Reference in New Issue
Block a user