< Billy Overton >

Programmer / Technology Consultant

Windows PowerShell and SmartAVI CATSwitch

Posted 2012-05-21 | Billy Overton

I was working on some room automation stuff last year when I found myself in need of a command line tool to control a SmartAVI CATSwitch video switcher. Thankfully they posted the details for their RS-232 protocol at the end of their manual, so I was able to throw together a quick and dirty script for connecting inputs and outputs on the switch. I thought it would be interesting to share what I put together, since it might help someone else.

I was playing around with PowerShell at the time, so that is what the script is written in. It takes two strings as inputs corresponding to the physical ports on the video switcher. For the model I was working with valid inputs were “01” – “16” for both the input and the output string.

$output = $args[1]
$input = $args[0]

$command = '//F00M'
$command += $output
$command += "I"
$command += $input

$errorCode = 0
foreach($character in $command.ToCharArray()) {
    $errorCode = $errorCode -bxor [int][char]$character

$command += [char]$errorCode

$command += "`r"

$port= new-Object System.IO.Ports.SerialPort COM1,9600,None,8,one