background image

W406-CE User’s Manual 

Application Development 

Visual C# Examples 

A device .Net CF 2.0 class library (mxdevice.dll) is provided to simplify application development 
with Visual Studio 2005 tools. This library covers the .Net CF Class Library for the buzzer and 
digital I/O devices. To link the library with your Visual Studio 2005 project environment, perform 
the following steps from your Visual Studio 2005 tool: 

1.

 

Copy the library file 

mxdevice.dll

 to any folder on your local disk. 

This file can be found on the product CD in the folder 

\sdk\dot Net Compact Framework 

Library

, or the file can be downloaded from the FTP site listed in the NOTE at the bottom of this 

page. 

2.

 

Open the Visual Studio 2005 IDE tool, and then add a new C

# Smart device console 

application. 

3.

 

Enter the project name and location path. 

4.

 

In the 

Solution Explorer View

, add 

mxdevice.dll

 to the reference section. 

5.

 

Click 

OK

 

 

 

ATTENTION 

1.

 

The programming examples for Moxa embedded computers are frequently updated. The 
latest examples can be downloaded from the following FTP site: 
ftp://esource.moxa.com/moxasys/WinCE_Examples/C#. 

2.

 

You may need to copy the “mxdevice.dll” within the example when you try to execute the 
program.

 

 

 

 

 

 

 

 

 

B-21

Summary of Contents for W406 WinCE

Page 1: ...W406 WinCE User s Manual Third Edition December 2009 www moxa com product 2009 Moxa Inc All rights reserved Reproduction without permission is prohibited...

Page 2: ...right to make improvements and or changes to this manual or to the products and or the programs described in this manual at any time Information provided in this manual is intended to be accurate and...

Page 3: ...tarting Your W406 Computer 2 2 Resetting Your W406 Computer 2 2 Boot Loader 2 3 Operating Your W406 Computer through the Serial Console 2 3 Changing the Network Settings 2 4 Accessing Files with File...

Page 4: ...re Upgrade Procedure A 1 A Configure HyperTerminal for the Console Port A 2 B Download and Install the TFTP program A 7 C Download and Upgrade the Firmware through HyperTerminal A 8 Appendix B Applica...

Page 5: ...runs disconnected from other computers or distributed as a front end to a centralized host Examples include enterprise tools such as industrial controllers communications hubs point of sale terminals...

Page 6: ...to the C libraries and run times used on a desktop PC running Windows the C libraries and run times on a W406 WinCE are a subset of the WIN32 APIs The system supports a full ANSI C run time standard...

Page 7: ...col TCP User Datagram Protocol UDP name resolution and registration and DHCP Supported Servers and Daemons y Telnet Server A sample server that allows remote administration through a standard Telnet c...

Page 8: ...read only files that are stored on the Flash with the read write files from both applications and users A child directory named NORFlash is created under the root the size of the directory is 3 MB Ex...

Page 9: ...e data freeing up the memory space for further use The embedded computer has limited resources and designers should decide if storing data in a file system is really necessary If it is necessary be su...

Page 10: ...device is plugged into the slot on the back of the computer a directory named USBDisk under the root directory is created in the internal file system as a link to the storage device The embedded comp...

Page 11: ...ion They both support non standard baudrate settings of up to 921 600 bps To configure the interface of the serial ports simply use the setinterface command in telnet or console mode Please note that...

Page 12: ...ers can be carried out using a web based management system The web based management system is described in a later chapter The following topics are covered in this chapter Starting Your W406 Computer...

Page 13: ...g to Factory Defaults If the computer is not working properly and you want to reset it back to factory default settings press and hold the Reset button for at least 5 seconds The buzzer will sound whi...

Page 14: ...rial console Step 1 Power off your W406 device Step 2 Make sure the serial console wire is connected to your PC correctly Step 3 Go to Start Programs Accessories Communication Terminal to create a new...

Page 15: ...r w WINS Server noask e g netconfig n IXP425ETHNPE1 i 192 168 10 101 g 192 168 10 254 netconfig n CS89501 i 192 168 12 101 m 255 255 0 0 Alias LAN1 CS89501 For example if your development workstation...

Page 16: ...dware User s Manual for installation details Please note the SIM card must be installed when the embedded computer is powered off The LED indicators on the top panel can be used to check the signal st...

Page 17: ...the connection fails use the gprs_reconnect exe command to re connect to the GPRS network again For more details please see the command syntax gprs_reconnect h Use gprs_disconnect r to stop the gprs_...

Page 18: ...on problems gprs_diagnose exe allows users to diagnose connection problems during the network connection process This utility will execute a series of steps to check whether the configuration is corre...

Page 19: ...l be locked and the PUK code will be required to unlock the SIM card After ten failed attempts at entering the PUK code the SIM card will be invalidated and no longer usable 1 To input your PIN code s...

Page 20: ...he PIN code of the SIM card sim_change_pin 5 To unlock the SIM card if your SIM card status is Need PUK code sim_unlock Sending Reading and Deleting SMS Messages 1 To send an SMS message sms_send_text...

Page 21: ...ion problems use the following commands 1 gprs_diagnose In the case above the problem is Need PIN Code Simply use the sim_input_pin command to input the PIN code Meanwhile this command also shows the...

Page 22: ...d APN mapping For more information please type setregapn h 3 gprs_connect d This command allows users to check the ISP provider and the APN In the case above users may know the name of the ISP is Chun...

Page 23: ...utilities for file management For example to inspect the file structure of the root directory type DIR dir b Network NORFlash My Documents Program Files Temp Windows User Group Management User Group Y...

Page 24: ...the current system date time or to set a new system date time date The current date is Tuesday November 22 2005 Enter the new date mm dd yy yy 12 23 05 date T Wednesday November 23 2005 time The curr...

Page 25: ...ipconfig all Windows IP configuration Ethernet adapter Local Area Connection IP Address 192 168 30 127 Subnet Mask 255 255 255 0 Adapter Name CS89501 Description CS89501 Adapter Index 2 Address 00 90...

Page 26: ...er when significant events occur by sending a trap y An SNMP manager is an SNMP application that generates queries to SNMP agent applications and receives traps from SNMP agent applications The W406 c...

Page 27: ...t these computers control they often reside in harsh environments away from the system administrator To manage these computers operations such as networking server configuration file management and pr...

Page 28: ...arget computer in the browser s address box When the main page appears click on Web Based Management 2 Enter your user ID and password in the corresponding fields both are case sensitive and then pres...

Page 29: ...tails in the corresponding text fields and then click Update to activate the changes Serial Port Configuration The W406 computer has two high performance serial ports each of which supports RS 232 RS...

Page 30: ...n menu bar You can kill a process by clicking the Kill button next to the process name Launching Processes Automatically To set your application to start on boot up do the following Step 1 Click the P...

Page 31: ...requests To monitor and control these services do the following Step 1 Click the Services item on the main menu bar The running services are displayed Step 2 Click the relevant check box to toggle a s...

Page 32: ...d then follow the on screen instructions y To refresh the current directory click Current Directory at the top of the page In addition the management system offers a mechanism for uploading files The...

Page 33: ...cross over Ethernet cable for upgrading the firmware through a TFTP server and LAN port 5 The firmware for the embedded computer There are three steps in the recovery process A Configure HyperTerminal...

Page 34: ...igure HyperTerminal for the Console Port C The console port is located on 1 Connect the console port with a console port cable to your P the bottom panel 2 Connect your embedded computer to the power...

Page 35: ...on tool to access your embedded computer We suggest that you L use HyperTerminal which is built into Windows XP Navigate to Start Programs Accessories Communications and then select HyperTerminal Afte...

Page 36: ...W406 CE User s Manual Firmware Upgrade Procedure 5 lick Cancel when the Connect To window opens C 6 elect File Properties from the main HyperTerminal screen S A 4...

Page 37: ...ge the COM port number in the Properties window Click Configure for 7 additional configuration options 8 Configure the Port Settings with following parameters l None Bits per second 115200 Data bits 8...

Page 38: ...W406 CE User s Manual Firmware Upgrade Procedure 9 Click the Settings tab and then select VT100 for Emulation Click OK to complete the configuration A 6...

Page 39: ...the boot ing URL d in this path D 2 the files to your PC 1 You will need to download a free TFTP server pac loader utility The utility can be found at the follow ftp papa indstate edu The TFTP program...

Page 40: ...e the Firmware through HyperTerminal m the 1 Connect to Moxa s website at http www moxa com and then select Software fro Support drop down menu Under Search for Software select the product line and th...

Page 41: ...Procedure 3 In the software list select the firmware for your model Choose the appropriate OS and then click the download icon to start downloading the new firmware Note Check the filename it may dif...

Page 42: ...re 4 ut the latest firmware image in the same directory as the TFTP files P 5 Next connect the LAN Port of the embedded computer to your PC using a cross over Ethernet cable The LAN1 port is located o...

Page 43: ...own the DEL key on your PC and power on the embedded computer at the 6 same time You will be guided to the boot loader utility menu as show below In the boot loader utility select 1 Network Configurat...

Page 44: ...ou will need to enter the IP address of the embedded computer and your PC Follow the ork Connections Y steps below to configure the IP addresses A From Start Settings select Netw B Right click on Loc...

Page 45: ...W406 CE User s Manual Firmware Upgrade Procedure C the General tab and select Internet Protocol TCP IP and then click on Click Properties A 13...

Page 46: ...Use the following IP address and enter the IP address and Subnet ple 2 168 1 1 This IP address is only an example you may assign any IP mask For exam IP address 19 address of your choice as long as i...

Page 47: ...ss The local IP address is the IP address of the embedded computer Note that the local IP address must be on the same LAN as the server IP address For example if the server IP address is 192 168 1 1 y...

Page 48: ...please note that all data on the disk will be erased and cannot be recove after a disk format Enter Y if you would like to format the disk or N if you would not When you finish formatting your disk yo...

Page 49: ...User s Manual Firmware Upgrade Procedure 7 To start the TFPF server double click on the tftpd32 icon to launch the TFTP server 8 When the TFTP server has been launched the following screen will appea...

Page 50: ...W406 CE User s Manual Firmware Upgrade Procedure 9 Go back to the boot loader utility menu and enter the file name of the firmware image 10 he firmware upgrade will then start to run T A 18...

Page 51: ...rmware files to be written to your embedded computer Do not power off your computer 12 hen you return to command line mode the firmware upgrade has completed At this point ou may reboot the embedded c...

Page 52: ...06 CE User s Manual Firmware Upgrade Procedure A 20 13 If you cannot reboot your embedded computer even after following all the steps above contact Moxa s technical support staff for further assistanc...

Page 53: ...enu choose New Project y Choose the Project Type and then select the Smart Device Application as the type of project y Fill in the project name and click OK y Choose Windows CE as the target platform...

Page 54: ...cellular modem handle void cellular_modem_close unsigned int fd Inputs fd the handle Return Values None Remark You must release the cellular modem handle resource if you don t need to use cellular mod...

Page 55: ...ion unsigned int fd char user char password Inputs fd the cellular modem user point to the user id null indicates empty userid password point to the user password null indicates empty password Return...

Page 56: ...ater than 88 degree or less than 35 degree the function will return with GPRS_ERROR_TEMPERATURE Sets the storage base of SIM messages int cellular_modem_sms_set_storage_base unsigned int fd int mode I...

Page 57: ...your SMS message you must construct your PDU data into the SMSMSG msg_text field with exact length SMSMSG msg_length Receives an indexed SMS message int cellular_modem_sms_recv_message unsigned int f...

Page 58: ...en the SIM card status is set to PIN 2 this function retrieves the available PIN code attempt count If the SIM card status is set to PUK 3 this function gets the available PUK code attempt count int c...

Page 59: ...d 1 PIN code enabled otherwise the function fails Remark When the SIM card status is ready 0 and the PIN code is enabled this function assigns a PIN code to the SIM card int cellular_modem_sim_assign_...

Page 60: ...or example user uart_getmode 2 to retrieve the interface of COM2 Sets the UART interface BOOL uart_setmode int port int mode Inputs port the serial port number mode the interface parameter 0 RS 232 1...

Page 61: ...o DO0 DO3 data 1 HIGH 0 LOW Return Values 0 on success otherwise the function fails Remark Gets one of the DIN inputs int mxdio_get_din HANDLE hDIO unsigned int port Inputs hDIO the DIO handle port th...

Page 62: ...ng Watchdog refresh function call BOOL watchdog_refresh HANDLE hWdg DWORD dwRefreshPeriod Inputs hWdg the watchdog handle from watchdog_init returned Return Values TRUE indicates the watchdog refresh...

Page 63: ...Remark You must open the cellular modem first before you use the other GPRS method Closes a cellular modem Class Name GPRS Method void Close Inputs none Return Values none Remark You must close the ce...

Page 64: ...ect int Connect string user string password Inputs user the user id string password the password string Return Values 0 on success otherwise the function fails Remark Aborts a GPRS connection Class Na...

Page 65: ...NGTH 1 5 const GPRS_ERROR_RADIOBAND 1 6 const GPRS_ERROR_MODULE 1 7 If the Cellular modem temperature greater than 88 degree or less than 35 degree the function will return with GPRS_ERROR_TEMPERATURE...

Page 66: ...phone number Class Name GPRS Method int SendSMS uint msg_mode ref SMSMSG pmsg Inputs msg_mode 0 message in text 1 message in PDU psms SMS message structure Return Values 0 on success otherwise the fun...

Page 67: ...e the function fails Remark public struct SMSMSG public uint been_read public string msg_date public string msg_time public string phone_number public uint msg_length public string msg_text If you lik...

Page 68: ...the function fails Remark public enum SIMCardState Ready 0 NoSIMCard NeedPINCode NeedPUKCode When the SIM card status is set to NeedPINCode 2 this function retrieves the available PIN code attempt co...

Page 69: ...string puk_code string new_pin_code Inputs puk_code the PUK passwd code string new_pin_code the new PIN code string Return Values 0 on success otherwise the function fails Remark Gets the PIN code ena...

Page 70: ...uccess otherwise the function fails Remark Gets the modem module temperature Class Name GPRS Method int GetGPRSModuleTemperature Inputs none Return Values the tempture of GPRS module Remark UART Sets...

Page 71: ...0 DI3 Return Values 1 indicates HIGH 0 indicates LOW Remark Gets one of DOUT outputs Class Name DigitalOutput Method int Get int port Inputs port the port index from 0 to 3 mapping to DO0 DO3 Return V...

Page 72: ...refresh failure Remark Closes the watchdog handle Class Name Watchdog Method bool close Inputs None Return Values True indicates the watchdog refresh succeed false indicates refresh failure Remark Bu...

Page 73: ...found on the product CD in the folder sdk dot Net Compact Framework Library or the file can be downloaded from the FTP site listed in the NOTE at the bottom of this page 2 Open the Visual Studio 2005...

Reviews: