BEGIN { # Add the @INC path the directory where the DSSClient module is found. push (@INC, "dss"); } use strict; use warnings; use DSSClient; if (scalar(@ARGV) != 2) { die "Usage: perl perl_client \n"; } my $host = $ARGV[0]; my $port = $ARGV[1]; my $client = new DSSClient($host, $port); my $cmd = undef; my $result = undef; # Connect to the CCS json server. $client->open(); #Send commands to DSS Test Server #---------------- # This command does not exist and should FAIL. $cmd = { "name" => "buggyrun", }; execute_command($cmd); # Connect to the target. $cmd = { "name" => "connect", }; execute_command($cmd); # Demonstrate the use of custom commands (report current timeout value) $cmd = { "name" => "custom_cmd", }; execute_command($cmd); # Demonstrate the use of custom commands (report current timeout value) $cmd = { "name" => "custom_cmd", }; execute_command($cmd); # Disconnect from the target. $cmd = { "name" => "disconnect", }; execute_command($cmd); # Connect to the target. $cmd = { "name" => "connect", }; execute_command($cmd); # Connect to the target. $cmd = { "name" => "connect", }; execute_command($cmd); # Load program. $cmd = { "name" => "loadProgram", "program" => "C:/Tool/JPython/bin/target-config/xwr18xx_mrr_ti_design_mss.xer4f", }; execute_command($cmd); # Load program. $cmd = { "name" => "loadBinaryProgram", "program" => "C:/Tool/JPython/bin/target-config/ROC_LCP_FLASH_debug.bin", "address" => "0x510e0000", }; execute_command($cmd); # We are done now. $client->close(); # Duplicate close call will fail $client->close(); #------------------ # execute command sub execute_command { $result = $client->execute($_[0]); if (defined $result) { print "$_[0]{name}: ". $result->{"status"} . "\n"; # If there is a message, print it if (exists $result->{"message"} ) { print " message: " . $result->{"message"} . "\n"; } # If a value was returned, print it if (exists $result->{"value"} ) { print " value: " . $result->{"value"} . "\n"; } } else { print "$_[0]{name} execution failed\n"; } }