Moxa Technologies NPort PCG Programmer's Manual
Moxa Technologies NPort PCG Programmer's Manual

Moxa Technologies NPort PCG Programmer's Manual

Programmable communication gateway

Advertisement

Quick Links

Programmable Communication Gateway
Programmer's Guide
First Edition, April 2003
Moxa Technologies Co., Ltd.
Tel:
+866-2-8919-1230
Fax:
+886-2-8919-1231
www.moxa.com
support@moxa.com.tw

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the NPort PCG and is the answer not in the manual?

Questions and answers

Summary of Contents for Moxa Technologies NPort PCG

  • Page 1 Programmable Communication Gateway Programmer’s Guide First Edition, April 2003 Moxa Technologies Co., Ltd. Tel: +866-2-8919-1230 Fax: +886-2-8919-1231 www.moxa.com support@moxa.com.tw...
  • Page 2 Information provided in this manual is intended to be accurate and reliable. However, Moxa Technologies assumes no responsibility for its use, or for any infringements on the rights of fourth parties which may result from its use.
  • Page 3 MOXA Internet Services Customer satisfaction is our number one concern. To ensure that customers receive the full benefit of our products, Moxa Internet Services has been set up to provide technical support, driver updates, product information, and user’s manual updates. The following services are provided: E-mail for technical support address:...
  • Page 4: Table Of Contents

    Embedding a Private Key in your Application.......3-4 Embedding a Private Key from the Command Line ......3-5 Using SDK Manager .................3-6 Searching for NPort PCGs .............3-6 Selecting/Deselecting PCGs............3-10 Configuring an NPort PCG ............3-12 Application Download ..............3-20 Run Application / Debug..............3-22 Example Programs ..................3-25...
  • Page 5 4. Application Deployment ............... 4-1 Changing Default Settings for Multiple PCGs ..........4-1 Creating System Firmware—COM2FRM..........4-2 Command Line Usage..............4-3 Field Utility ..................4-3 Developing a PCG Utility .................4-4 DSCI Library..................4-4 AP ID .....................4-4 5 PCG FAQs..................5-1...
  • Page 6: Introduction

    Standard BSD Sockets for TCP/IP programming with multi-TCP session support SDK (Software Development Kit) To assist in the development of NPort PCG applications, Moxa provides a comprehensive and easy-to-use SDK, designed for use on Windows 95/98/ME/NT/2000/XP platforms. The main features are as follows.
  • Page 7: User Application Space

    User Application Space The user application space available on an NPort PCG is a full 64 KB. This is because the serial I/O, Ethernet, and TCP/IP protocol stack buffers occupy part of the kernel space. In general, this amount of space is sufficient for protocol conversions, and is sufficient for even more complex applications, such as Modbus conversion.
  • Page 8: Installing Sdk

    Installing SDK This chapter covers: How to install SDK utilities and Library How to install the Turbo C compiler and environmental variables The location of Libraries and Example Files System Requirements You will need to have the following items available to use SDK’s development tools: Windows 9x, NT, ME, 2000, or XP operating system At least 64 MB of RAM...
  • Page 9: Installing Sdk

    Installing SDK To install Moxa SDK on a Windows system, insert the software CD-ROM included with the product into your computer’s CD-ROM drive. The installation program should start automatically. Simply follow the onscreen instructions to complete the installation. The installation procedure installs the following files: Directory Sub Directory\Files Description...
  • Page 10: Desktop Icons

    Desktop Icons The SDK installation places three program icons on your computer’s desktop that serve as shortcuts to the following programs: NPort SDK Manager, COM2AP, and Terminal Emulator. Setting Up Environment Variables During the installation procedure, the SDK setup program automatically sets up your environment variables for the Turbo C compiler.
  • Page 11: Developing User Applications

    In order to give you a better understanding of the development flow, we’ll use the example program sdkser23.c to illustrate. Application Development Flow The following flowchart illustrates the standard process for developing your NPort PCG applications. PRG.C Compile tcc.exe PRG..OBJ C0SDK.OBJ...
  • Page 12: Development System

    Development System Before getting started on application development, you need to make sure that all of the required equipment is set up and ready to go. The basic configuration needed for application development is as follows: Windows95/98/ME/NT/2000/XP computer with SDK installed PCG with power adapter Ethernet hub/switch (or use a cross-over Ethernet cable to link the computer and PCG directly)
  • Page 13: Source Code Editing

    You should now be able to view and edit the file sdkser23.c. Compiling and Linking your Application Under NPort PCG’s SDK, compiling and linking is done from DOS command mode. Because of this, you will need to create a make file before compiling and linking a program.
  • Page 14: Generating A Com File

    NPort PCG. For this reason, NPort PCG provides a private key that you can embed into your application (AP). The target NPort PCG should have the same private key with the help of SDK Manager.
  • Page 15: Embedding A Private Key From The Command Line

    Next, take the following steps to complete the process of embedding a private key: 1. Type the private key in the “Private Key” field. E.g., you could choose “1234” as the private key. 2. Click on the folder icon to the right of COM file and then navigate to the COM file you would like to convert (e.g., sdkser23.com).
  • Page 16: Using Sdk Manager

    SDK Manager. SDK Manager is a utility that provides the following functions. Search and locate NPort PCGs. Change the IP, Netmask, Gateway, default serial comm parameters, and operation modes for NPort PCG. AP download Debug window Searching for NPort PCGs The Search Menu provides two different methods to search the network for a PCG.
  • Page 17 The Broadcast window will display the progress of the search. Once the search is complete, the Model Name, Serial No., Server Name, AP ID, MAC Address, IP Address, Subnet Mask, and OP Mode of each PCG that was located will be displayed in the SDK Manager window. Search by IP To access this function, select Search by IP under the Search menu, or click on the Search by IP toolbar icon.
  • Page 18 input box, and then click OK. The Search by IP window will display the progress of the search. Device not found error message. NOTE If you receive the Specified device not found error message, as shown above, and the PCG is located on the same LAN as the host, try using Broadcast Search, or change the host computer’s IP address and/or Netmask so that the computer and PCG are on the same subnet.
  • Page 19 Locate Gateway The Locate Gateway function is used to find the physical location of a PCG unit when there are multiple PCGs on the same network. To use this function, first click on the device you would like to locate to highlight the device’s information, and then select Locate Gateway under the Search menu, or click on the Locate Gateway toolbar icon.
  • Page 20: Selecting/Deselecting Pcgs

    Click on OK to cause the PCG unit’s Ready light to stop blinking. Selecting/Deselecting PCGs The Select All and Deselect All functions are provided to make it easier to configure large numbers of PCGs. NOTE SDK Manager includes a multi-selection capability. Hold down the Ctrl key to select multiple PCGs that are not listed in order, or hold down the Shift key to select all PCGs listed between the first and last PCG that you click on.
  • Page 21 Deselect All The Deselect All function is used to deselect all PCGs listed in the SDK Manager window. To use this function, select Deselect All under the Actions menu, or click on the Deselect All toolbar icon. This will cause all NPort 4511s listed in the SDK Manager window to become unhighlighted.
  • Page 22: Configuring An Nport Pcg

    Configuring an NPort PCG To use this function, select Configuration under the Actions menu, or click on the Configuration toolbar icon. The Configuration window opens with the Comm. Gateway tab selected. Each of the six Configuration window tabs is discussed in the following subsections.
  • Page 23 Server Settings Setting Options Comments Comm. Gateway Alphanumeric Determined by user. Name Disable Disable internal watchdog timer. We suggest that you disable the watchdog timer during the application development stage for easier troubleshooting. Enable Enable internal watchdog timer. The NPort PCG uses the CPU’s internal watchdog timer.
  • Page 24 Ethernet Tab To make changes, first click in the Change Ethernet Settings box, and then select which Ethernet Port to modify from the Ethernet Port drop-down list. When only 1 PCG is selected. When multiple PCGs are selected. 3-14...
  • Page 25 Ethernet Settings Setting Options Comments Ethernet Port eth0 NPort 4511 has only one Ethernet port. Available with multi-selection When multiple target PCGs are Set the Same IP xxx.xxx.xxx.xxx selected, they will all be configured with the same IP address. Available with multi-selection Define a range of IPs by inputting Start and End values.
  • Page 26 Serial Port Tab This section of the Configuration window allow you to modify the serial communication parameters. The modified parameters will be saved in the PCG’s flash ROM. To make changes, first click in the Change Serial Settings box, and then click on the port in the display area in the bottom part of the window to make changes to the configuration of the serial ports.
  • Page 27 Private Key Tab As mentioned above, a private key is required for both the AP and the PCG. To embed the private key in the PCG, first click in the Change Private Key box, and then enter the Private Key in the Private Key input box, and then reenter the Private Key in the Confirm box.
  • Page 28 Password Tab The PCG’s password is saved in the PCG’s flash ROM. The main purpose of the password is to prevent unauthorized access from a host computer. To make changes, first click in the Change Password box, and then enter the password in the Password input box, and then reenter the password in the Confirm box.
  • Page 29 PCG. To solve this problem, NPort PCG automatically reports it’s location to a remote host computer. The Location Report section of the Configuration window allows you to set up the IP address corresponding to the TCP port for a host computer.
  • Page 30: Application Download

    Application Download Up to this point, we have only discussed how to configure the PCG’s network and other parameters. The next thing to do is download the prepared application (AP) to the PCG for testing. Download AP To download the AP, first select Download AP from the Actions menu, or click on the Download AP toolbar icon.
  • Page 31 Download Kernel The kernel for NPort PCG is preloaded before shipment. When you receive an updated kernel from Moxa, you can use the Download Kernel function to update the kernel yourself. To download the kernel to the PCG, first select Download Kernel from the Actions menu, or click on the Download Kernel toolbar icon.
  • Page 32: Run Application / Debug

    Run Application / Debug You should now be ready to run your application, but first we need to discuss the two PCG operation modes. Choose from PCG’s Running Mode and Developing Mode NPort 4511 provides two operation modes selected by DIP switch. Turn SW1 to the ON position for Developing Mode, and to the OFF position for Running Mode.
  • Page 33 The Debugger window will appear as shown in the following figure. From the SDK Debugger window, click on the Start Application button to start running your PCG application. There are three message areas in the Debugger window as shown below. 3-23...
  • Page 34 Comm. Gateway Info Area The PCG’s basic configuration settings are shown in the Comm. Gateway Info. area. The information includes the following: Server Info.—includes Model Name, Serial No., Server Name, Firmware Version, number of Serial Ports, number of Ethernet Ports, Watchdog Mode, and OP Mode AP Info.—includes latest AP Name and file location, Version,...
  • Page 35: Example Programs

    Debug The main debug approach for NPort PCG is to put the debug API in your source code as a debug symbol. The debug message will be sent to SDK’s debug window via the Ethernet console. The “single step” and “break point” debug methods are currently not supported.
  • Page 36: Application Deployment

    Changing Default Settings for Multiple PCGs The default settings for NPort PCG may be different from the settings you want to use when shipping the product to your customers. To make the job easier, SDK Manager can be used to change multiple PCG settings, all at the same time.
  • Page 37: Creating System Firmware-Com2Frm

    Creating System Firmware—COM2FRM In general, the AP file is downloaded to the PCG separate from the kernel. However, NPort PCG’s SDK provides you with another advanced tool, COM2FRM, that is used to merge the kernel and AP file into a system firmware file.
  • Page 38: Command Line Usage

    Field Utility SDK Manager is the main field utility for configuration and troubleshooting, but NPort PCG’s SDK also provides you the DSCI Library that can be used for developing your own proprietary utility. For more information, please refer to next section.
  • Page 39: Developing A Pcg Utility

    In this case, it is necessary for the host utility to identify which application is running on the PCG. NPort PCG uses the AP ID to identify which PCG is associated with which DSCI API. The AP ID is stored in the System Parameter Block within the PCG.
  • Page 40: Pcg Faqs

    Corrrect command: tlink /t /s c0sdk+ap, ap, ap, moxa_sdk 3. In addition to using PCG’s SDK Lib, some standard Turbo C instructions are also used. Refer to Chapter 4 of the “NPort PCG API Reference.” Q. How can I set a password? Ans.
  • Page 41 Q. What is the password of PCG used for? Ans. 1. It protects PCG’s parameters from being modified unwittingly. There could be more than one PCG connected to the network, and users might modify the configuration of the incorrect PCG. 2.
  • Page 42 Q. What is the difference between “Download AP” and “Download Firmware?” Ans. 1. “Download AP” is for downloading the Application Program to the PCG, but “Download Firmware” is downloading a file that combines the Application Program and “Kernel.” 2. The Firmware contains both the PCG’s application program and kernel. This is convenient for developers when distributing the final software package to end users.

Table of Contents