Skip to content

Instantly share code, notes, and snippets.

@imorrish
Last active December 4, 2016 02:52
Show Gist options
  • Save imorrish/725c3fed673efa96fc2ee2f4ca0ef083 to your computer and use it in GitHub Desktop.
Save imorrish/725c3fed673efa96fc2ee2f4ca0ef083 to your computer and use it in GitHub Desktop.
Amira Camera Tally Test
Function Send-CameraTally
{ Param (
[Parameter(ValueFromPipeline=$true)]
[String[]]$Command,
[string]$CamerIP = "IPAddress",
[string]$Port = "23"
)
#Attach to the remote device, setup streaming requirements
$WaitTime = 200
$Socket = New-Object System.Net.Sockets.TcpClient($CameraIP, $Port)
If ($Socket)
{ $Stream = $Socket.GetStream()
$Writer = New-Object System.IO.StreamWriter($Stream)
$Buffer = New-Object System.Byte[] 1024
$Encoding = New-Object System.Text.AsciiEncoding
$Writer.WriteLine($Command)
$Writer.Flush()
Start-Sleep -Milliseconds $WaitTime
#camera will return Done.
While($Stream.DataAvailable)
{ $Read = $Stream.Read($Buffer, 0, 1024)
$Result += ($Encoding.GetString($Buffer, 0, $Read))
}
}
Else
{ $Result = "Unable to connect to camera: $($CameraIP):$Port"
}
#Done, now save the results to a file
$Result
}
#Test
Get-Telnet -CameraIP "192.168.1.3" -Command "tallyengage 1"
Start-Sleep -Seconds 5
Get-Telnet -CameraIP "192.168.1.3" -Command "tallyengage 0"
@imorrish
Copy link
Author

imorrish commented Dec 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment