Comm Operator v4.5 Released!

September 6th, 2010

Comm Operator is a professional tool for serial port, TCP/IP, UDP communication application’s design, development, debug and test.

It makes it more efficient for the development of hardware-software application, client-server application as well as network application. It can send and receive data at very fast speed. Data can be viewed in text, hex and decimal format. It is also able to create complex structure data, like ZigBee/XBee API data framework or GIS Garmin data package. All data are stored in lists which can be accessed easily from GUI. Data can be sent automatically with flexible auto sending rules. Perl, Python and Ruby script are supported as well as user’s EXE and Plug-in dll. It is also able to create COP file. COP file can be opened by Comm Operator Pal, which is free lite version of Comm Operator.

For system designer, Comm Operator will save your time and money to build prototype. The protocol design can be done with Comm Operator only. The content in send data list can be used as test data for later development.

For software programmer & hardware engineer, Comm Operator can simulate the software/hardware. The system can be developed parallel and find out the problem easily.

For engineers who test and deploy the system, Comm Operator is the right tool for unit test. It can be setup as environment for parts before put the system online.

For support work, Comm Operator can create COP file and help customers fix problem in communication layer easily.

Product Page: http://www.serialporttool.com/CommOpInfo.htm
Download link: http://www.serialporttool.com/download/CommOperator/CommOperator.zip
E-Mail: support@serialporttool.com

How to use Comm Operator as a loopback connection

September 4th, 2010

Echo rule is added to “Auto Send” in Comm Operator. It can be used for loopback test.

The loopback is the most used method to test two-way communication in rs232 or network application. For rs232 application, the loopback can be very simple, just connection RX and TX pin together on remote end, it will echo all data back. For network application, it couldn’t be that simple. Certain program has to be run on remote endpoint. Now it is possible to use “Echo Rule” in Auto Send to echo data back.

How to Add “Echo Rule”

Click [Edit]->[Auto Send] to open the “Auto Send Rule Setting”.

image

Click “New” button.

image Select “Echo” and Click “OK”. The “Echo” setting dialog will be shown.

image

Check the “Always” will make it echo all the data back, otherwise, it only echo one received data.

“Delay” is the delay time to echo data back. The unit is millisecond.

Click OK and make the new auto send rule is valid.

image

Click “OK” button and click “Run” button on toolbar will make the Comm Operator work in Echo mode.

Auto Run Your Own EXE in Comm Operator

September 2nd, 2010

Comm Operator v4.5 supports Exe to process data in “Auto Send” function. You can add you own EXE to Auto Send Rule.

Download Comm Operator v4.5 

Comm Operator Main Interface

Here are the steps to add your own EXE to Auto Send Rule in Comm Operator

1. Click menu [Edit]->[Auto Send] to open the “Auto Send Rule Setting” dialog.

Auto Send Rule Setting Dialog

2. Click “New” button to show “Select Rule Type” dialog.

Select Rule Type - EXE

3. Select “EXE (Console)” and Click “OK”. The “User Exe Rule” dialog will be shown.

User Exe Rule Dialog

4. Select your EXE file.

Tip:

  • If the checkbox”Always” is selected, the script will be run again and again. Otherwise, it won’t be called once it is matched.
  • Comm Operator comes with a demo User Exe called “UserExeSample.exe”. The file can be find in Comm Operator’s install folder. The default folder is “C:\Program Files\Serial Port Tool\Comm Operator\” or “C:\Program Files(x86)\Serial Port Tool\Comm Operator\” for 64 bits OS.

5. Click OK to finish adding your EXE to Auto Send Rule.

How does it work?

Comm Operator process the “Auto Send” in a separate thread. The Exe will be called in every loop. The exe handles the events and determine if there are data need to be sent in “Auto Send”. “Matched” means there is data come back from Exe and need to be sent.

When a user’s exe is called, Comm Operator write the event type as well as data of this event in STDIN. The event type could be one of the following.

“DataReceived”,  raised when data received in Comm Operator in current connection. This data received are followed after the event string in hex string format.

“Start”,  raised when the auto send starts.

“Pause”,  raised when the auto send pauses.

“Resume”,  raised when the auto send resumes.

“Loop”, raised in every loop of the auto send.

Only “DataReceived” has data, the data are hex strings separated by one space. Like “61 62 63 64 “ represents the data “ABCD”. The whole package write to STDIN in this case will be

DataReceived,61 62 63 64

For other event types, the package only has only the type name followed with a “,”.

In user’s exe, the exe will read package from stdin, and write the data need sent to stdout.

Here is the code of UserExeSample. It is written in C#. Download it from here.

using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace UserExeSample
{
    class Program
    {
        /// <summary>
        ///  The user’s exe will be called in every auto send loop in Comm Operator
        ///  Comm Operator will write data to stdio. User’s exe read those data. Comm Operator will read the retun data from STDOUT and send those data
        /// Format
        /// Type, hex hex hex …
        /// Type: String that represent the type of event, can be 
        ///       "DataReceived"
        ///       "Start"
        ///       "Pause"        
        ///       "Resume"
        /// If the type is "DataReceived", it will follow byte "," and then the data in hex string.
        /// For example, if the Comm Operator recieved string "abcd", it will call script with data like below
        ///   DataReceived, 61 62 63 64
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                //  Read data send from Comm Operator
                string str = Console.ReadLine();
                // Parse data, the data contains two parts. The first part is event type, the seond part are data in hex string
                string[] strs = str.Split(‘,’);

                //test if it is the "DataReceived" event
                if (strs[0] == "DataReceived")
                {
                    Console.WriteLine(strs[1]);
                }

                // test if it is the "Start" event
                if (strs[0] == "Start")
                {
                    Console.WriteLine(ascii_to_hex("Start"));
                }

                // test if it is the "Pause" event
                if (strs[0] == "Resume")
                {
                    Console.WriteLine(ascii_to_hex("Resume"));
                }

                //  test if it is the "Resume" event
                if (strs[0] == "Pause")
                {
                    Console.WriteLine(ascii_to_hex("Pause"));
                }

                //  test if it is the "Loop" event
                if (strs[0] == "Loop")
                {
                    //System.Threading.Thread.Sleep(1000);
                    //Console.WriteLine(ascii_to_hex("Loop"));
                }

            }
            catch
            {

            }
        }

        // Help function, used to process data to Comm Operator
        // convert ascii string to hex string
        // for example "ABCD" –> "41 42 43 44 "
        static string ascii_to_hex(string str)
        {
            StringBuilder sb = new StringBuilder();
            Encoding coding = Encoding.GetEncoding("iso-8859-1");
            byte[] data = coding.GetBytes(str);
            foreach (byte b in data)
            {
                sb.AppendFormat("{0:X2} ", b);
            }
            return sb.ToString();
        }

        // Help function, used to process data from Comm Operator
        // convert hex string t ascii string
        // for example
        // "41 42 43 44 " –> "ABCD"
        static string hex_to_ascii(string str)
        {
            ArrayList list = new ArrayList();
            string[] strs = str.Split(new char[] { ‘ ‘ }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in strs)
            {
                list.Add(Convert.ToByte(s, 16));
            }
            Encoding coding = Encoding.GetEncoding("iso-8859-1");
            byte[] data = (byte[])list.ToArray(typeof(byte));
            return coding.GetString(data, 0, data.Length);

        }
    }
}

See Also

Run Perl Script in Auto Send

Run Python Script in Auto Send

Run Ruby Script in Auto Send

Run Plugin(.net Dll) in Auto Send

Auto Run your own plugin (.net dll) in Comm Operator

September 2nd, 2010

Comm Operator v4.5 supports plug-in (.net dll) in Auto Send function. You can write your own plug-in and add it to Auto Send Rule.

Download Comm Operator v4.5 

Comm Operator Interface

Here are the steps to add Plug-in (.net dll) to Auto Send Rule in Comm Operator.

1. Click menu [Edit]->[Auto Send] to open the “Auto Send Rule Setting” dialog.

Auto Send Rul Setting Dialog

2. Click “New” button to open “Select Rule Type” dialog.

Select Rule Type_Plugin

3. Select “Plug-in (.net dll)” and Click “OK”. The “Auto Send Plugin” setting dialog will be shown.

Auto Send Plugin Dialog 

4. Select the path of your plugin dll and plugin name in that dll.

Tip:

  • If the checkbox”Always” is selected, the plugin will be called again and again. Otherwise, it won’t be called once it is matched.
  • Comm Operator comes with a demo plugin called “EchoPlugin.exe”. The file can be find in Comm Operator’s install folder. The default folder is “C:\Program Files\Serial Port Tool\Comm Operator\” or “C:\Program Files(x86)\Serial Port Tool\Comm Operator\” for 64 bits OS.

5. Click OK to finish adding plugin to Auto Send Rule.

How does it work?

Comm Operator process the “Auto Send” in a seperate thread. The plugin will be called in auto send thread loop. The plugin has to be the type of IAutoSendPlugin. The IAutoSendPlugin type is defined in IAutoSendPlugin.dll, which can be found in Comm Operator’s install folder. The plugin is load dynamically. User need implement the ProcessEvent method to process the data. The method is called by Comm Operator in auto send thread loop. It passes the event type and data. The event type are defined in IAutoSendPlugin too.

Here is the sample code of EchoPlugin. Down the EchoPlugin File here.

/// <summary>
/// EchoPlugin is a sample of implement IAutoSendPlugin.
/// EchoPlugin will send the same data back
/// </summary>
public class EchoPlugin : IAutoSendPlugin
{
    /// <summary>
    /// Implement the interface of processEvent
    /// </summary>
    /// <param name="eventType">Event type</param>
    /// <param name="data">data for that event. Only ReceivedData event has data</param>
    /// <returns></returns>
    public byte[] ProcessEvent(EventType eventType, byte[] data)
    {
        byte[] returnData = null;
        if (eventType == EventType.DataReceived)
        {
            if(data != null)
            {
                if (data.Length > 0)
                {
                    returnData = new byte[data.Length];
                    Array.Copy(data, returnData, data.Length);
                    return returnData;
                }
            }
        }
        return returnData;
    }

    /// <summary>
    /// Implement this interface if there is setting dialog needed for this
    /// for future usage
    /// </summary>
    /// <param name="parent"></param>
    /// <returns></returns>
    public bool Setting(Form parent)     // call setting dialog
    {
        return false;
    }

    /// <summary>
    /// method of if the setting dialog available, for future usage
    /// </summary>
    /// <returns></returns>
    public bool IsSettingAvailable()      // if setting is available
    {
        return false;
    }

}

See Also

Run Perl Script in Auto Send

Run Python Script in Auto Send

Run Ruby Script in Auto Send

Run User Exe in Auto Send

Run Python Script Automatically in Comm Operator

September 1st, 2010

Comm Operator v4.5 supports Python Script in “Auto Send” function. Python Script can be run automatically.

Download Comm Operator v4.5 

Comm Operator Screenshot

Here are the steps to add Python script to Auto Send Rule in Comm Operator.

1. Valid Python interpreter has to be installed. It can be downloaded from http://www.python.org/

2. Click menu [Tools]->[Options]->[Script] page to set the path of  Python script interpreter “python.exe”.

Options - Script

3. Click menu [Edit]->[Auto Send] to open the “Auto Send Rule Setting” dialog.

Auto Send Rule Setting

4. Click “New” button to show “Select Rule Type” dialog.

Select Rule Type - Python

5. Select “Python Script” and Click “OK”. The “Python Script Rule” dialog will be popup.

Python Script Rule Dialog 

6. Select the path of your Python script. Click “View” button will open the script with Windows Notepad.

Tip:

  • If the checkbox”Always” is selected, the script will be run again and again. Otherwise, it won’t be called once it is matched.
  • Comm Operator comes with a demo python script called “Sample.py”. The file can be find in Comm Operator’s install folder. The default folder is “C:\Program Files\Serial Port Tool\Comm Operator\” or “C:\Program Files(x86)\Serial Port Tool\Comm Operator\” for 64 bits OS.

7. Click OK to finish adding Python Script Rule.

How does it work?

Comm Operator process the “Auto Send” in a separate thread. The script will be called in every loop. The script handles the events and determine if there are data need to be sent in “Auto Send”. “Matched” means there is data come back from script and need to be sent.

When a script is called, Comm Operator write the event type as well as data of this event in STDIN. The event type could be one of the following.

“DataReceived”,  raised when data received in Comm Operator in current connection. This data received are followed after the event string in hex string format.

“Start”,  raised when the auto send starts.

“Pause”,  raised when the auto send pauses.

“Resume”,  raised when the auto send resumes.

“Loop”, raised in every loop of the auto send.

Only “DataReceived” has data, the data are hex strings separated by one space. Like “61 62 63 64 “ represents the data “ABCD”. The whole package write to STDIN in this case will be

DataReceived,61 62 63 64

For other event types, the package only has only the type name followed with a “,”.

The package ends with a CR. In python script, the following code will read the whole data package.

input=sys.stdin.readline()

As  the event and data are separated by “,”, it can be parsed easily by the following code.

data = input.split(",")

data[0] is the event type and data[1] contains the data related.

The data send back to Comm Operator is written to STDOUT, the data are formatted in hex string.

Here is the sample code that echo all data received.

if data[0] == "DataReceived" :
  print data[1]   

Here is the help function for creating hex string from ascii string.

##help function
##Convert each ASCII character to a two-digit hex number seperated with a space char
## like "ABCD" to "65 66 67 68 "
def ascii_to_hex(str):
  return ”.join(['{0:2x} '.format(ord(s)) for s in str])

Here is the sample code to send string “Hello” to Comm Operator.

print ascii_to_hex("Hello")

Here is the help function for converting hex string to ascii string. It is useful to parse the data comes from Comm Operator.

##help function
##Convert each two-digit hex number back to an ASCII character.
## the string format like "A5 B3 ", there is a space char between two hex numbers
## like "65 66 67 68 " to "ABCD"
def hex_to_ascii(str):
  return ”.join([chr(int(s, 16)) for s in str])

Here is the code of “Sample.py”.

## To make this script run, please setup the Ruby path correctly in "Tools->Options"
## sample python script to Comm Operator
## Comm Operator will write data to STDIN
## Format
## Type, hex hex hex …
## Type: String that represent the type of event, can be 
##       "DataReceived"
##       "Start"
##       "Pause"        
##       "Resume"
## If the type is "DataReceived", it will follow byte "," and then the data in hex string.
## For example, if the Comm Operator recieved string "abcd", it will call script with data like below
##   DataReceived, 61 62 63 64

import sys
import time

##help function
##Convert each ASCII character to a two-digit hex number seperated with a space char
## like "ABCD" to "65 66 67 68 "
def ascii_to_hex(str):
  return ”.join(['{0:2x} '.format(ord(s)) for s in str])

##help function
##Convert each two-digit hex number back to an ASCII character.
## the string format like "A5 B3 ", there is a space char between two hex numbers
## like "65 66 67 68 " to "ABCD"
def hex_to_ascii(str):
  return ”.join([chr(int(s, 16)) for s in str])

## Read data send from Comm Operator
input=sys.stdin.readline()

## Parse data, the data contains two parts. The first part is event type, the seond part are data in hex string
data = input.split(",")

## test if it is the "DataReceived" event
if data[0] == "DataReceived" :
  ## echo back the data received, replace it with you own code
  print data[1]       

## test if it is the "Start" event
if data[0] == "Start" :
  ## send string "Start", replace it with you own code
  print ascii_to_hex("Start")

## test if it is the "Pause" event
if data[0] == "Pause" :
  ## send string "Pause", replace it with you own code
  print ascii_to_hex("Pause")

## test if it is the "Resume" event
if data[0] == "Resume":
  ## send string "Resume", replace it with you own code
  print ascii_to_hex("Resume")

## test if it is the "Loop" event
#if data[0] == "Loop":
  ## process data here is not recommended.
  #time.sleep( 1)
  #print ascii_to_hex("Loop")

Run Perl Script in Auto Send

Run Plugin(.net Dll) in Auto Send

Run Ruby Script in Auto Send

Run User Exe in Auto Send

Run Ruby Script Automatically in Comm Operator

August 31st, 2010

Comm Operator v4.5 supports Ruby Script in “Auto Send” function. Ruby Script will be run automatically.

Download Comm Operator v4.5 

Comm Operator Screenshot

Here are the steps to add Ruby Script to Auto Send Rule in Comm Operator.

1. Valid Ruby interpreter has to be installed. It can be downloaded from http://www.ruby-lang.org/en/

2. Click menu [Tools]->[Options]->[Script] page to set the path of Ruby interpreter “Ruby.exe” correctly.

Options - Script

3. Click menu [Edit]->[Auto Send] to open the “Auto Send Rule Setting” dialog.

Auto Send Rule Setting

4. Click “New” button to show “Select Rule Type” dialog.

Select Rule Type - Ruby

5. Select “Ruby Script” and Click “OK”. The “Ruby Script Rule” dialog will be shown.

Ruby Script Rule

6. Choose your Ruby script. Click “View” button will open the script with Windows Notepad.

Tip:

  • If the checkbox”Always” is selected, the script will be run again and again. Otherwise, it won’t be called once it is matched.
  • The Comm Operator comes with a demo Ruby script called “Sample.rb”. The file can be find in Comm Operator’s install folder. The default folder is “C:\Program Files\Serial Port Tool\Comm Operator\” or “C:\Program Files(x86)\Serial Port Tool\Comm Operator\” for 64 bits OS.

7. Click OK to finish adding Ruby Script Rule.

How does it work?

Comm Operator process the “Auto Send” in a separate thread. The script will be called in every loop. The script handles the events and determine if there are data need to be sent in “Auto Send”. “Matched” means there is data come back from script and need to be sent.

When a script is called, Comm Operator write the event type as well as data of this event in STDIN. The event type could be one of the following.

“DataReceived”,  raised when data received in Comm Operator in current connection. The data received are followed after the event string in hex string format.

“Start”,  raised when the auto send starts.

“Pause”,  raised when the auto send pauses.

“Resume”,  raised when the auto send resumes.

“Loop”, raised in every loop of the auto send.

Only “DataReceived” has data, the data are hex strings separated by one space. Like “61 62 63 64 “ represents the data “ABCD”. The whole package write to STDIN in this case will be

DataReceived,61 62 63 64

For other event types, the package only has only the type name followed with a “,”.

The package ends with a CR. In Ruby script, the following code will read the whole data package.

str = gets()

As  the event and data are separated by “,”, it can be parsed easily by the following code.

data = str.split(‘,’)

data[0] is the event type and data[1] contains the data related.

The data send back to Comm Operator is written to STDOUT, the data are formatted in hex string.

Here is the sample code that echo all data received.

if(data[0] == "DataReceived") then
  puts data[1]
end

Here is the help function for creating hex string from ascii string.

##Convert each ASCII character to a two-digit hex number seperated with a space char
## like "ABCD" to "65 66 67 68 "
def ascii_to_hex (str)
  hexStr = ""
  str.each_byte{
    |c| hexStr += " %02x"%c
  }
  return hexStr
end

Here is the sample code to send string “Hello” to Comm Operator.

puts ascii_to_hex(“Hello”)

Here is the help function for converting hex string to ascii string. It is useful to parse the data comes from Comm Operator.

##Convert each two-digit hex number back to an ASCII character.
## the string format like "A5 B3 ", there is a space char between two hex numbers
## like "65 66 67 68 " to "ABCD"
def hex_to_ascii (str)
  bytesStr = str.split(‘ ‘)
  bytes = Array.new()
  bytesStr.each{|x| bytes.push(x.hex) }
  str = bytes.pack("c*")
  return str;
end

Here is the code of “Sample.rb”.

## To make this script run, please setup the Ruby path correctly in "Tools->Options"
## sample ruby script to Comm Operator
## Comm Operator will write data to STDIN
## Format
## Type, hex hex hex …
## Type: String that represent the type of event, can be 
##       "DataReceived"
##       "Start"
##       "Pause"        
##       "Resume"
## If the type is "DataReceived", it will follow byte "," and then the data in hex string.
## For example, if the Comm Operator recieved string "abcd", it will call script with data like below
##   DataReceived, 61 62 63 64

##Convert each ASCII character to a two-digit hex number seperated with a space char
## like "ABCD" to "65 66 67 68 "
def ascii_to_hex (str)
  hexStr = ""
  str.each_byte{
    |c| hexStr += " %02x"%c
  }
  return hexStr
end

##Convert each two-digit hex number back to an ASCII character.
## the string format like "A5 B3 ", there is a space char between two hex numbers
## like "65 66 67 68 " to "ABCD"
def hex_to_ascii (str)
  bytesStr = str.split(‘ ‘)
  bytes = Array.new()
  bytesStr.each{|x| bytes.push(x.hex) }
  str = bytes.pack("c*")
  return str;
end

## Read data send from Comm Operator
str = gets()
## Parse data, the data contains two parts. The first part is event type, the seond part are data in hex string
data = str.split(‘,’)

## test if it is the "DataReceived" event
if(data[0] == "DataReceived") then
  ## echo back the data received, replace it with you own code
  puts data[1]
end

## test if it is the "Start" event
if(data[0] == "Start") then
  ## send string "Start", replace it with you own code
  puts ascii_to_hex("Start")
end

## test if it is the "Pause" event
if(data[0] == "Pause") then
  ## send string "Pause", replace it with you own code
  puts ascii_to_hex("Pause")
end

## test if it is the "Resume" event
if(data[0] == "Resume") then
  ## send string "Resume", replace it with you own code
  puts ascii_to_hex("Resume")
end

## test if it is the "Loop" event
if(data[0] == "Loop") then
  ## process data here is not recommended.
  #sleep 1
  #puts ascii_to_hex("Loop")
end

See Also

Run Perl Script in Auto Send

Run Python Script in Auto Send

Run User Exe in Auto Send

Run Plugin(.net Dll) in Auto Send

Run Perl Script Automatically in Comm Operator

August 31st, 2010

Comm Operator v4.5 supports Perl script in “Auto Send” function. Per Script will be run automatically.

Download Comm Operator v4.5 

Comm Operator Screenshot

Here are the steps to add Perl Script to Auto Send Rule in Comm Operator.

1. Valid Perl interpreter need to be installed. It can be downloaded from http://www.perl.org

2. Click menu [Tools]->[Options] to open Options dialog. The path of Perl interpreter “Perl.exe”  has to be setup correctly on Script page.

Options - Script

3. Click menu [Edit]->[Auto Send] to open the “Auto Send Rule Setting” dialog.

Auto Send Rule Setting

4. Click “New” button to show “Select Rule Type” dialog.

Select Rule Type - Perl

5. Select “Perl Script” and Click “OK”. The “Perl Script Rule” dialog will be shown.

Per Script Rule Dialog

6. Choose your Perl script. Click “View” button will open the script with Windows Notepad.

Tip:

  • If the checkbox”Always” is selected, the script will be run again and again. Otherwise, it won’t be called once it is matched.
  • Comm Operator comes with a demo Perl script called “Sample.pl”. The file can be find in Comm Operator’s install folder. The default folder is “C:\Program Files\Serial Port Tool\Comm Operator\” or “C:\Program Files(x86)\Serial Port Tool\Comm Operator\” for 64 bits OS.

7. Click OK to finish adding Perl Script Rule.

How does it work?

Comm Operator process the “Auto Send” in a separate thread. The script will be called in every loop. The script handles the events and determine if there are data need to be sent in “Auto Send”. “Matched” means there is data come back from script and need to be sent.

When a script is called, Comm Operator write the event type as well as data of this event in STDIN. The event type could be one of the following.

“DataReceived”,  raised when data received in Comm Operator in current connection. The data received are followed after the event string in hex string format.

“Start”,  raised when the auto send starts.

“Pause”,  raised when the auto send pauses.

“Resume”,  raised when the auto send resumes.

“Loop”, raised in every loop of the auto send.

Only “DataReceived” has data, the data are hex strings separated by one space. Like “61 62 63 64 “ represents the data “ABCD”. The whole package write to STDIN in this case will be

DataReceived,61 62 63 64

For other event types, the package only has only the type name followed with a “,”.

The package ends with a CR. In perl script, the following code will read the whole data package.

$input=<STDIN>

As  the event and data are separated by “,”, it can be parsed easily by the following code.

@data = split(/,/, $input);

data[0] is the event type and data[1] contains the data related.

The data send back to Comm Operator is written to STDOUT, the data are formatted in hex string.

Here is the sample code that echo all data received.

if(@data[0] eq "DataReceived"){ 
    print $data[1];
}

Here is the help function for creating hex string from ascii string.

##Convert each ASCII character to a two-digit hex number separated with a space char
## like "A5 B3 "
sub ascii_to_hex ($)
{
    (my $str = shift) =~ s/(.|\n)/sprintf("%2lx ", ord $1)/eg;
    return $str;
}

Here is the sample code to send string “Hello” to Comm Operator.

print ascii_to_hex(“Hello”);

Here is the help function for converting hex string to ASCII string. It is useful to parse the data comes from Comm Operator.

##Convert each two-digit hex number back to an ASCII character.
## the string format like "A5 B3 ", there is a space char between two hex numbers
sub hex_to_ascii ($)
{
    (my $str = shift) =~ s/([a-fA-F0-9 ]{3})/chr(hex $1)/eg;
    return $str;
}

Here is the code of “Sample.pl”.

## To make this script run, please setup the Perl path correctly in "Tools->Options"
## sample ruby script to Comm Operator
## Comm Operator will write data to STDIN
## Format
## Type, hex hex hex …
## Type: String that represent the type of event, can be 
##       "DataReceived"
##       "Start"
##       "Pause"        
##       "Resume"
## If the type is "DataReceived", it will follow byte "," and then the data in hex string.
## For example, if the Comm Operator recieved string "abcd", it will call script with data like below
##   DataReceived, 61 62 63 64

## Read data send from Comm Operator
$input=<STDIN>;

## Parse data, the data contains two parts. The first part is event type, the seond part are data in hex string
@data = split(/,/, $input);

## test if it is the "DataReceived" event
if(@data[0] eq "DataReceived"){
    ## echo back the data received, replace it with you own code
    print $data[1];
}

## test if it is the "Start" event
if(@data[0] eq  "Start"){
    ## send string "Start", replace it with you own code
    print ascii_to_hex("start");
}

## test if it is the "Pause" event
if(@data[0] eq  "Pause"){
    ## send string "Pause", replace it with you own code
    print ascii_to_hex("Pause");
}

## test if it is the "Resume" event
if(@data[0] eq  "Resume"){
    ## send string "Resume", replace it with you own code
    print ascii_to_hex("Resume");
}

## test if it is the "Loop" event
if(@data[0] eq "Loop") {
  ## process data here is not recommended.
  #sleep 1
  #print ascii_to_hex("Loop")
}

##Convert each ASCII character to a two-digit hex number separated with a space char
## like "A5 B3 "
sub ascii_to_hex ($)
{
    (my $str = shift) =~ s/(.|\n)/sprintf("%2lx ", ord $1)/eg;
    return $str;
}

##Convert each two-digit hex number back to an ASCII character.
## the string format like "A5 B3 ", there is a space char between two hex numbers
sub hex_to_ascii ($)
{
    (my $str = shift) =~ s/([a-fA-F0-9 ]{3})/chr(hex $1)/eg;
    return $str;
}

See Also

Run User Exe in Auto Send

Run Python Script in Auto Send

Run Ruby Script in Auto Send

Run Plugin(.net Dll) in Auto Send

USB PTZ Joystick Plug-in for PTZ Controller v2.8

August 20th, 2010

PTZ Controller v2.8 supports PTZ Joystick plug-in.

Download PTZ Joystick Plug-in

How to use PTZ Joystick to control PTZ Camera

  1. Download and Install PTZ Controller v2.8 (http://www.serialporttool.com/PTZ.htm)

  2. Download PTZ Joystick plug-in

  3. Connect PTZ Camera with your PC through RS232 serial port

  4. Connect USB PTZ Joystick with your PC

  5. Run PTZ Controller v2.8

  6. Run PtzJoystick.exe

  7. Control PTZ Camera with the PTZ Joystick now!

Note:

Please update your Windows and install DirectX. Here is the download link.

http://www.microsoft.com/downloads/details.aspx?familyid=0CEF8180-E94A-4F56-B157-5AB8109CB4F5&displaylang=en

  • PTZ Joystick   PTZ Joystick

       

PTZ Joystick uses X/Y Axis for Pan/Tilt and rotates handle for Zoom out/in.

There are 12 buttons, 2 on handle and 10 on base housing.

Here is the table of the button’s functions.

Button # Function  
1 Focus Far  
2 Focus Near  
3 Iris Open  
4 Iris Close  
5 Next Preset  
6 Previous Preset  
7 Next Camera  
8 Previous Camera  
9 Customized Button 1  
10 Customized Button 2  
11 Customized Button 3  
12 Customized Button 4  

 

 

 

 

 

 

 

 

Note: The Customized Buttons indicate the buttons on Customize panel of PTZ Controller.

customizedButton

Here are links for USB PTZ Joystick.

* If you want to use a less expensive solution for PTZ Joystick, you may choose USB Game Joystick or USB Gamepad.

USB Game Joystick Plug-in for PTZ Controller v2.8

USB Game Pad Plug-in for PTZ Controller v2.8

USB Gamepad Plug-in for PTZ Controller v2.8

August 20th, 2010

PTZ Controller v2.8 supports Gamepad plug-in now.

Download Gamepad Plug-in

We recommend Logitech Cordless RumblePad. It is available from NewEgg.com at the price about $30. It’s also works well with other gamepad.

Logitech Cordless RumblePad       Logitech Cordless RumblePad

How to use Gamepad to control PTZ Camera

  1. Download and Install PTZ Controller v2.8 (http://www.serialporttool.com/PTZ.htm)
  2. Download Gamepad plug-in
  3. Connect PTZ Camera with your PC through RS232 serial port
  4. Connect USB Gamepad with your PC
  5. Run PTZ Controller v2.8
  6. Run GamepadPlugin.exe
  7. Control PTZ Camera with the Gamepad now!

Note:

Please update your Windows and install DirectX. Here is the download link.

http://www.microsoft.com/downloads/details.aspx?familyid=0CEF8180-E94A-4F56-B157-5AB8109CB4F5&displaylang=en

  • Gamepad Plug-in   Logitech Cordless RumblePad

Here is the function list for Logitech Cordless RumblePad.

Buttons Function
A Up Previous Camera Address
A Down Next Camera Address
A Left Previous Preset
A Right Next Preset
B Up Tilt Up (Tilt Down when Flip checkbox is selected)
B Down Tilt Down (Tilt Up when Flip checkbox is selected)
B Left Pan Left (Pan Right When Mirror checkbox is selected)
B Right Pan Right (Pan Left When Mirror checkbox is selected)
C Up Zoom Out (Variable Speed)
C Down Zoom In (Variable Speed)
C Left Focus Far
C Right Focus Near
Button 1 Zoom Out
Button 2 Zoom In
Button 3 Iris Close
Button 4 Iris Open
Button 5 Customized Button 1
Button 6 Customized Button 2
Button 7 Customized Button 3
Button 8 Customized Button 4
Button 9 Customized Button 5
Button 10 Customized Button 6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note: The Customized Buttons indicate the buttons on Customize panel of PTZ Controller.

Customized Buttons

Related Link

USB Game Joystick Plug-in for PTZ Controller v2.8

USB PTZ Joystick Plug-in for PTZ Controller v2.8

USB Game Joystick Plug-in for PTZ Controller v2.8

August 20th, 2010

We got many feature request emails about support USB game joystick for PTZ Controller. Compare to PTZ joystick, game joystick is much less expensive solution.

PTZ Controller supports plug-in from version 2.8. The first plug-in is USB Game Joystick Plug-in.

Download Game Joystick Plug-in

We recommend Logitech’s extreme 3D joystick. It is available from NewEgg.com at the price about $30.  It also works well with other game joysticks.                

How to use Game Joystick to control PTZ Camera

  1. Download and Install PTZ Controller v2.8 (http://www.serialporttool.com/PTZ.htm)
  2. Download Game Joystick plug-in
  3. Connect PTZ Camera with your PC through RS232 serial port
  4. Connect USB Game Joystick with your PC
  5. Run PTZ Controller v2.8
  6. Run GamePtzJoystick.exe
  7. Control PTZ Camera with the Game Joystick now!

Note:

Please update your Windows and install DirectX. Here is the download link.

http://www.microsoft.com/downloads/details.aspx?familyid=0CEF8180-E94A-4F56-B157-5AB8109CB4F5&displaylang=en

  • Game Joystick Plug-in   Logitech Joystick

         The joystick works just like a professional PTZ camera Keyboard. It can control pan, tilt, iris, focus and zoom with PTZ Controller. The rotate of the joystick is Zoom, just same as PTZ Keyboard. There are 12 buttons available, with those buttons, it is possible to switch camera address and set preset by one hand!

Function Mapping

  • X Axis Pan
  • Y AXis Tilt
  • Z Axis Zoom

Pov are mapping to Iris and Focus.

  • Pov Up         Iris –
  • Pov Down    Iris +
  • Pov Left       Focus –
  • Pov Right     Focus +

Logitech Game Joystick       Logitech Game Joystick

Button’s Function

  • Button 1      Next Preset
  • Button 2      Previous Preset
  • Button 3      Next Camera
  • Button 4      Previous Camera
  • Button 5      —
  • Button 6      —
  • Button 7      Customized Button 1
  • Button 8      Customized Button 2
  • Button 9      Customized Button 3
  • Button 10    Customized Button 4
  • Button 11    Customized Button 5
  • Button 12    Customized Button 6

Logitech Game Joystick Buttons

The Customized Buttons indicate the buttons on Customize panel of PTZ Controller.

Customized Buttons

 

Related Link

USB Game Pad Plug-in for PTZ Controller v2.8

USB PTZ Joystick Plug-in for PTZ Controller v2.8