Forum Discussion

elfen's avatar
elfen
New Contributor
10 years ago
Solved

TCP/client Channel switch HDMI

Hi, would anyone please help me figure out what I'm missing in this following script? My script is based from this one: 

http://support.smartbear.com/viewarticle/9003/?_ga=1.179080356.1202715610.1400699782

What I'm trying to do is to switch my sources (input) and my channel (output) according from which parameters/variables I'm sending.

 

Thank you!

 

Sam.

 

function HDMI_SWITCH()
{
var ipaddr = "10.5.9.101";
var port = 5000; // or 4000
//var source = 01;
//var destination = 02;

//var message = "SBI02O01;"
//var message = "Link 01;" ;
//var command = "SBI0" + source + "O0" + destination;
//var command = "*255CI" + source + "O" + destination +"1";
//var command = "OUTPUTALL 01";


var command = "Output01 02;";
Log.Message("command = " + command);
//var expResult = "SBUD0" + source + "O" + destination;
var expResult = "SB5688 00";
Log.Message("expResult = " + expResult);

client = dotNET.System_Net_Sockets.TcpClient.zctor();
//client.Connect_4(ipaddr,port);
try {
client.Connect_4(ipaddr,port);

}
catch (exception)
{
Log.Error("Connection was not established")
return;
}
stream = client.GetStream();
var buffer = dotNET.System_Text.Encoding.ASCII.GetBytes_2(command + "\n");
// var buffer = dotNET.System_Text.Encoding.ASCII.GetBytes_2(message + "\n" + command + "\n");
stream.Write(buffer, 0, buffer.Length);

sleep(1000);

maxLength = 1024;
byteType = dotNET.System.Type.GetType("System.Byte");
binaryData = dotNET.System.Array.CreateInstance(byteType, maxLength);

slength = stream.Read(binaryData, 0, binaryData.Length);
rcv = dotNET.System_Text.Encoding.ASCII.GetString(binaryData, 0, binaryData.Length);

stream.Close();
client.Close();

Log.Message("rcv = " + rcv);
result = aqString.Compare(rcv, expResult, true);
if (result == 0) {
Log.Message("source " + source + " set to destination " + destination);
} else {
Log.Message("Fail to set source " + source + " to destination " + destination);
}
}

  • I forgot to mention but while debugging, the Testcomplete stops at stream.Write(buffer, 0, buffer.Length); and the application exits. I wonder if I'm sending an invalid buffer? 

1 Reply

  • elfen's avatar
    elfen
    New Contributor

    I forgot to mention but while debugging, the Testcomplete stops at stream.Write(buffer, 0, buffer.Length); and the application exits. I wonder if I'm sending an invalid buffer?