Archive for September, 2010

PTZ Controller v2.8

Tuesday, September 28th, 2010

ptz

PTZ Controller is software to control high speed Pan Tilt Zoom camera through serial port.

  • PTZ Controller includes features below:
  • Support standard protocols for Pelco, AD, Bosch, Sony, Panasonic, Samsung, LG and Canon.
  • Support control for Pan, Tilt, Focus, Zoom, Iris and Menu.
  • Support flexible Auto Scan, which includes preset scan and auto pan.
  • Provide 10 auxiliary and 12 customized buttons in separate panel.
  • Capable of sending user-defined Hex data to PTZ camera.
  • Support keyboard shortcuts to control 255 camera addresses and 127 presets.
  • Support plug-in for gamepad, game joystick and PTZ joystick.
  • Detect all available serial port automatically.
  • Allow to export and import setting file.
  • Compatible with Windows 7.
  • FREE to try full function within 30 days!

PTZ Controller is a good debug tool for test and install PTZ camera. It is more powerful than traditional PTZ keyboard hardware.  

We are trying our best to support more PTZ cameras, and we provide customized service for other PTZ camera’s protocols. Please feel free to contact us.

Comm Operator v4.5 Released!

Monday, September 6th, 2010

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

Comm Operator Main GUI

Comm Operator 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 Loopback Connection

Saturday, 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 popular 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 Comm Operator as loopback for both RS232 and network application. You only need to add “Echo Rule” to Auto Send Rule.

How to Add “Echo Rule”

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

Auto Send Rule Setting

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

Select Rule Type

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

Echo Rule

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.

Auto Send Rule Setting

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

Auto Run Your Own EXE in Comm Operator

Thursday, 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

Thursday, 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

Wednesday, 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