IA261/262 WinCE User’s Manual Second Edition, April 2009 www.moxa.com/product © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited.
IA261/262 WinCE User’s Manual The software described in this manual is furnished under a license agreement and may be used only in accordance with the terms of that agreement. Copyright Notice Copyright © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited. Trademarks MOXA is a registered trademark of The Moxa Inc. All other trademarks or registered marks in this manual belong to their respective manufacturers.
Table of Contents Chapter 1 Introduction ..................................................................................................1-1 Overview.................................................................................................................................. 1-2 Model Descriptions and Package Checklist............................................................................. 1-3 Product Features ......................................................................................
1 Chapter 1 Introduction Microsoft® Windows® CE 6.0 is an open, scalable, 32-bit operating system (OS) that allows you to build a wide range of innovative, small footprint devices. A typical Windows® CE-based device is designed for a specific use, and often runs disconnected from other computers, or distributed as a front-end to a centralized host.
IA261/262 WinCE User’s Manual Introduction Overview The IA261/IA262 embedded computers, which are ideal for industrial automation applications, feature 4 RS-232/422/485 serial ports (2 for IA262), dual CAN ports (IA262 only), dual Ethernet ports, 8 digital input channels, 8 digital output channels, VGA output, 2 USB hosts and a CompactFlash socket in a compact, industrial-strength aluminum rugged casing.
IA261/262 WinCE User’s Manual Introduction Model Descriptions and Package Checklist The IA261/262 Series includes the following models: IA261-I-CE RISC-based Embedded Computer with VGA, 4 Serial Ports, Dual LANs, DIO, CompactFlash, USB, WinCE 6.0, isolation protection for all IO. IA261-I-T-CE RISC-based Embedded Computer with VGA, 4 Serial Ports, Dual LANs, DIO, CompactFlash, USB, WinCE 6.0, Wide Temperature, isolation protection for all IO.
IA261/262 WinCE User’s Manual Introduction Product Hardware Specifications System CPU: DRAM: Flash: Storage Expansion: USB: Console/Debugging Port: Others: OS: Display Graphics Controller: Cirrus Logic EP9315 ARM9 CPU, 200 MHz 128 MB onboard 32 MB Flash onboard CompactFlash socket x 1 for storage expansion USB Host x 2 compliant to USB 2.0 (OHCI), Type A connector RS-232 x 1 (TxD, RxD, GND), 4-pin header output RTC, buzzer, Watchdog Timer, Reset button built-in WinCE 6.
IA261/262 WinCE User’s Manual Digital input levels: Protection: Connector Type: Digital Output Output Channels: On-state Voltage: Output Current Rating: Protection: Connector Type: LEDs System: LAN: Serial: Power Requirements Power Input: Power Consumption: Mechanical Outlook Shape: Dimensions (WxDxH): Gross Weight: Construction Material: Mounting: Environmental Operating Temperature: Storage Temperature: Regulatory Approvals EMC: Safety: Others: Warranty: Introduction Dry contact: Logic level 0: Close
IA261/262 WinCE User’s Manual Introduction Product Software Specifications IA261/262 WinCE ready-to-run embedded computers are network centric / head-less computers that are designed to be programmable for embedded communication applications.
IA261/262 WinCE User’s Manual Introduction y Network Utilities (IpConfig, Ping, Route) - Utilities for troubleshooting various network problems. y TCP/IP - Includes IP, Address Resolution (ARP), Internet Control Message (ICMP), Internet Group Membership (IGMP), Transmission Control (TCP), User Datagram (UDP), name resolution and registration, and DHCP. Supporting Servers and Daemons In addition to the development and communication capability, IA26X-CE embeds the services and daemons as stated next.
IA261/262 WinCE User’s Manual Introduction The additional file systems on USB and CompactFlash storage devices are placed at the root of the internal file system. If you intend to use these devices to port data between your PC and the IA26X-CE computer, please format them as the FAT file system on your PC. Hive-Based Registry-Contrast to RAM-Based Registry The registry for the IA26X-CE is a hive-based registry in contrast to a RAM-based registry.
IA261/262 WinCE User’s Manual Introduction RS-232/422/485 Serial Ports The IA261-CE computer comes with 4 high performance serial ports, named “COM1:”, “COM2:”, “COM3:” and “COM4”. And the IA262-CE computers has 2 high performance serial ports only named “COM1:” and “COM2:” all of them are designed to provide reliability, high-speed and 3-in-1 (i.e., RS-232, RS-422, and RS-485) operation mode switch for your diverse applications. Each of these ports supports baud rate settings up to 921600 bps.
2 Chapter 2 Getting Start In this chapter, we explain how to operate an IA26X-CE computer via a PC near you. For clarity, this PC is called a development workstation and the IA26X-CE computer is called a target computer. In addition, manual steps are described to facilitate operations such as system time adjustment, troubleshooting network connectivity, etc.
IA261/262 WinCE User’s Manual Getting Start Powering on IA261/262 Connect the power source located at the top side of the unit to boot up the system. It takes about 5 seconds for the system to boot up and you can hear a clear “BEEP” voice. Once the system is ready, the “Ready” LED will light up and stay on till you shutdown the computer. Resetting Your IA26X-CE Computer Warm-Start: In power-on state, push the “Reset” and release it in 1 second. The computer reboots itself.
IA261/262 WinCE User’s Manual Getting Start Operating IA26X-CE Computer Via Serial Console The serial console port gives users a convenient way of connecting the development workstation to the console utility of the target computer. This method is particularly useful when using the computer for the first time. After you have wired a serial cable, go back to the development workstation and start a terminal program (e.g., HyperTerminal) by using the settings shown below for the serial console port.
IA261/262 WinCE User’s Manual Getting Start 2. Right-Click the LAN icon and click the [property]. 3. Click “OK” button after configuration is done. Operating Your IA26X-CE Computer via Telnet Client Before operating your IA26X-CE computer using the Telnet client, we suggest that you change the network settings of the computer (see the earlier section) to have at least one of the two network ports situated in the same LAN as your development workstation.
IA261/262 WinCE User’s Manual Getting Start User/Group Management User Group: You should assign specific services, such as ftp and telnet, to defined user groups such that these services are accessible only by the users within the permissible user group. Three user groups, namely “ftpd”, “telnetd”, and “httpd”, are already created by default for your convenience. Adding a Group: Use the command useradd –g to create a user group. \> useradd –g yyyy group yyyy has been added.
IA261/262 WinCE User’s Manual Getting Start Adjusting Time Zone Windows CE 6.0 supports Time Zone. You can use [Control Panel]Æ[Date/Time] to adjunct your current Time Zone. It also supports Daylight Date and Daylight Time. Adjusting System Time Setting the System Time Manually: Use the date, and time commands to query the current system date/time or to set a new system date/time.
IA261/262 WinCE User’s Manual Getting Start Troubleshooting Network Connectivity The ipconfig tool prints the TCP/IP-related configuration data of a host including the IP addresses, gateway and DNS servers. \> ipconfig /all Windows IP configuration Ethernet adapter Local Area Connection: IP Address: 192.168.4.127 Subnet Mask: 255.255.255.
IA261/262 WinCE User’s Manual Getting Start To delete a routing item, \> route DELETE 192.168.0.0 Simple Network Management Protocol (SNMP) SNMP is the Internet Standard protocol for network management and part of the TCP/IP protocol suite. SNMP was developed to monitor and manage networks. It uses a distributed architecture that consists of agents and managers: SNMP agent The SNMP agent is an SNMP application that monitors network traffic and responds to queries from SNMP manager applications.
IA261/262 WinCE User’s Manual Getting Start current baud rate:1000K Send message: canapp <-tx > \> canapp 1 –tx 0 123456 88888888 Write msg from port:1 len:8 identifier:123456 Data:38 38 38 38 38 38 38 38 Send Msg Success! Receive message: canapp <-rx > \> canapp 2 –rx Read msg from port:2 ReceiveData: 38 38 38 38 38 38 38 38 Set acceptance code: canapp <-ac > \> canapp 2 –ac 0 4294967295 Set accepta
3 Chapter 3 Management Tools The IA26X-CE series ready-to-run embedded computers are network-centric platforms and are designed to serve as excellent front-ends for data acquisition and industrial control. Due to the distributed characteristics of the devices, that these computers control, they often reside in harsh areas as the devices themselves and are away from system administrators.
IA261/262 WinCE User’s Manual Management Tools System Information The first page displays the system information of the IA26X-CE computer, including the firmware version of the computer, .Net CF version, the system time, and system resources including main memory and file system usage. In this page user can click on the “Enable Ultra DMA” check box to enable or disable Ultra DMA for CF card. If system can not detect some CF cards please disable this setting.
IA261/262 WinCE User’s Manual Management Tools Serial Port Configuration The IA261-CE contains 4 and IA262-CE contains 2 high-performance serial ports. When the system starts up you can specify the default operation mode (RS-232, 422 or 485). The factory default mode would be RS-232. Following figure indicates condition of IA261-CE. Following figure indicates condition of IA262-CE.
IA261/262 WinCE User’s Manual Management Tools Process (Thread) Monitoring/Control At runtime, the IA26X-CE computer manages up to 32,000 applications. You can use the management system to monitor and control them. To view current processes, please click the Processes item on the tab bar. The running processes are then displayed. You can kill a process by clicking the “kill” button next to the process name.
IA261/262 WinCE User’s Manual Management Tools Services Monitoring/Control Some services run on the background to provide services, such as FTP, Telnet and HTTP, for user requests. You can click on a check box to toggle a start/stop operation for a service. You can also adjust the time automatically by using SNTP. Click on the check box to enable the service and click the button to activate. Some listed services cannot be stopped in order to maintain normal operation of the computer.
IA261/262 WinCE User’s Manual Management Tools Display The IA26X-CE VGA output works through DB15 Female CRT connector to display the Windows CE desktop into a LCD monitor or a CRT monitor. The default setting is “800x600”, 16 bit and 60Hz. For general purpose, you should tune the setting to match your LCD or CRT in specification. In the Display setting window you can adjust the setting and press “Apply” to save the setting. Note: You must restart (reboot) your IA26X-CE to make the setting take effect.
IA261/262 WinCE User’s Manual Management Tools User/Group Management You can add users by click the “Add” button to assign specific services, such as ftp and telnet, to define user groups such that these services are accessible and remove users by click the “Remove” button. User can change login Password by click expectative name twice.
IA261/262 WinCE User’s Manual Management Tools Auto Launch Configuration You can specify programs to execute automatically after booting up. Click “Add” button to add the program and restart IA26X-CE to execute these programs.
IA261/262 WinCE User’s Manual Management Tools Web Server Configuration You need a Windows 2000 or Windows XP for Web administration. Try to open a “IE” and go to URL http://192.168.3.127/WebAdmin (e.g. the IA26X-CE network IP address is 192.168.3.127). After the logon information you could see the standard Web server Administration page. In this administration page, you can create a new web site or create a virtual web path for your web application.
IA261/262 WinCE User’s Manual Management Tools You can also change the authentication for each web virtual directory.
A Appendix A Firmware Upgrade Procedure To upgrade the IA26X-CE firmware, you must download the firmware upgrade installation file. This firmware installation file is on the software CD. You can also download the newest version from the Moxa Download Center. The URL is shown below. http://web4.moxa.com/support/download_center.asp Use the following steps to upgrade the firmware. Before you start, make sure your PC has the TFTP server software installed correctly. 1. Locate the firmware file (e.g.
ThinkCore IA261/262 WinCE User’s Manual Firmware Upgrade Procedure Next select option (2) User Configure Input the local IP address (IA26X-CE) and server IP address (TFTP host IP Address) Select option (3) Show Configure to check the configuration of the local IP and server IP. After confirming the IP configuration, press [ESC] to return to the main menu.
ThinkCore IA261/262 WinCE User’s Manual Firmware Upgrade Procedure 3. Select option (1) Firmware Update. Select option (1) Load from LAN2, and input the firmware file name (e.g., IA262CE_V1.0_0704210.hfm) and press [Enter].
ThinkCore IA261/262 WinCE User’s Manual Firmware Upgrade Procedure A-4
B Appendix B CANopen Library The Moxa IA262-CE comes with dual CAN ports as well as the CANopen protocol library support. This chapter will guide you on how to use the CANopen library to program CAN communication applications. The following topics are covered in this appendix.
IA261/262 WinCE User’s Manual CANopen Library CANopen Introduction CANopen is a field bus protocol based on the Controller Area Network (CAN). As the name implies, it is a open network standard accepted throughout the world. While created as a field bus protocol for industrial automation, CANopen finds use in a wide range of other non-industrial applications. There are so many possibilities, in fact, that it is possible to write volumes on specialized uses of the protocol.
IA261/262 WinCE User’s Manual CANopen Library The CANopen specification defines several possible endpoints. The five endpoint objects listed below are implemented in this protocol; others may be made available in the future. • The Server SDO • Four Static PDOs • Synchronization Consumer • Network Management Slave • Node Guard or Heartbeat SERVER SDO COMMUNICATION The default server SDO (Service Data Object) is provided.
IA261/262 WinCE User’s Manual CANopen Library NETWORK MANAGEMENT CONSUMER A Network Management (NMT) slave is provided as required by the specification. The NMT Object receives commands to change the state of the device or reset the device’s application and/or communications. NODE GUARD/HEARTBEAT There is a single Node Guard or Heartbeat endpoint as required by the CANopen specifications. They both exist in our protocol. SYNCHRONIZATION CONSUMER One synchronization consumer (SYNC) is provided.
IA261/262 WinCE User’s Manual CANopen Library 2) Main view The top list lets you choose a dictionary section. The bottom left list is the index selected from that dictionary, and the bottom right list contains edited sub-indexes. 3) Create new node Edit your node name, ID, and type. Choose your specific inherited profile.
IA261/262 WinCE User’s Manual CANopen Library 4) Node info Edit your node name, ID, and type.
IA261/262 WinCE User’s Manual CANopen Library 5) Profile editor Choose the profile to Edit. Pick up optional chosen profile entries.
IA261/262 WinCE User’s Manual CANopen Library 6) User types Use User Types to implement value boundaries, and string length. 7) Mapped variable Add your own specific dictionary entries and associated mapped variables.
IA261/262 WinCE User’s Manual CANopen Library 8) Generating the object Dictionary Once the object dictionary has been edited and saved, you need to generate the object dictionary C code for your CANopen node. Select the Menu entry “File/Build Dictionary”. Choose a C file to create or overwrite. The header file will also be created with the same prefix as the C file. Function Description All the functions provided by CANopen library are listed in the following.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. y Return Values None. 3. moxa_heartbeatStop Stop Producer/Consumer Heartbeat time. y Syntax void moxa_heartbeatStop(CO_Data* d) y Parameters d: [input] Node handle pointer. y Return Values None. 4. moxa_proceedNODE_GUARD Use the function to process receiving NMT Node Guarding request from the master.
IA261/262 WinCE User’s Manual CANopen Library 5. moxa_masterSendNMTstateChange The function is used to change the state of a slave. y Syntax UNS8 moxa_masterSendNMTstateChange (CO_Data* d, UNS8 Node_ID, UNS8 cs) y Parameters d: [input] Node handle pointer. ID: [input] Slave device Node-ID (1~127). Set this parameter to 0 to indicate all slave devices. cs: [input] NMT command specifier.
IA261/262 WinCE User’s Manual y CANopen Library Syntax void moxa_masterRequestNodeState(CO_Data* d, UNS8 nodeId) y Parameters d: [input] Node handle pointer. nodeId: [input] Slave device Node-ID (1~127). Set this parameter to 0 to indicate all slave devices. y Return Values None. 8. moxa_proceedNMTstateChange The function is used to change the state of a slave. y Syntax void moxa_proceedNMTstateChange(CO_Data* d, Message * m) y Parameters d: [input] Node handle pointer.
IA261/262 WinCE User’s Manual y CANopen Library Syntax UNS32 moxa_getODentry( CO_Data* d, UNS16 wIndex, UNS8 bSubindex, void * pDestData, UNS8 * pExpectedSize, UNS8 * pDataType, UNS8 checkAccess) y Parameters d: [input] Node handle pointer. wIndex: [input] The index in the object dictionary where you want to read an entry. bSubindex: [input] The subindex of the Index. pDestData: [input] Pointer to the variable where the value of this object dictionary entry should be copied.
IA261/262 WinCE User’s Manual y CANopen Library Syntax UNS32 moxa_setODentry( CO_Data* d, UNS16 wIndex, UNS8 bSubindex, void * pSourceData, UNS8 * pExpectedSize, UNS8 checkAccess) y Parameters d: [input] Node handle pointer. wIndex: [input] The index in the object dictionary where you want to write an entry. bSubindex: [input] The subindex of the Index. pSourceData: [input] Pointer to the variable that holds the value that should be copied into the object dictionary.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. wIndex: [input] The index in the object dictionary where you want to write an entry. bSubindex: [input] The subindex of the Index. Callback: [input] assigned callback function. y Return Values NULL if index not found, else: return the table part of the object dictionary. 13. moxa_sendPDO This function is used to send PDO.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. Cobid: [input] COB-ID. y Return Values The result of the function moxa_sendPDO or 0xFF if error 15. moxa_buildPDO Prepare the PDO defined at index to be sent by moxa_PDOmGR. y Syntax UNS8 moxa_buildPDO (CO_Data* d, UNS16 index) y Parameters d: [input] Node handle pointer. Index: [input] The index in the object dictionary. y Return Values 0 if success or 0xFF if error 16.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. m: [input] CAN message structure. y Return Values 0xFF if error, else return 0 18. moxa_SDOlineToObjdict Copy the data received from the SDO line transfert to the object dictionary. y Syntax UNS32 moxa_SDOlineToObjdict (CO_Data* d, UNS8 line) y Parameters d: [input] Node handle pointer. line: [input ]SDO channel. y Return Values SDO error code if error. Else, returns 0 19.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. line: [input] SDO channel. nbBytes: [input] size of data data: [input] specified data which want to copy to sdo. y Return Values 0xFF if error. Else, returns 0 21. moxa_SDOtoLine Add data to an existent line. y Syntax UNS8 moxa_SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data) y Parameters d: [input] Node handle pointer.
IA261/262 WinCE User’s Manual CANopen Library index: [input] The index in the object dictionary where you want to handle. subIndex: [input] The subindex of the Index. abortCode: [input] SDO abort code y Return Values 0xFF if unable to send the SDO abort, else return 0. 23. moxa_resetSDO Reset all SDO buffers. y Syntax void moxa_resetSDO (CO_Data* d) y Parameters d: [input] Node handle pointer. y Return Values None. 24. moxa_resetSDOline Reset an unused line.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. line: [input] SDO channel. nodeId: [input]specified node id. index: [input] The index in the object dictionary where you want to handle. subIndex: [input]The subindex of the Index. State: [input] SDO_RESET /* Transmission not started. Init state. */ SDO_FINISHED /* data are available */ SDO_ABORTED_RCV /* Received an abort message. Data not available */ SDO_ABORTED_INTERNAL /* Aborted message.
IA261/262 WinCE User’s Manual y CANopen Library Syntax UNS8 moxa_getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line) y Parameters d: [input] Node handle pointer. whoami: [input] SDO_SERVER or SDO_CLIENT. line: [output] on use SDO channel. y Return Values 0xFF if error. Else, return 0 28. moxa_closeSDOtransfer Close a transmission. y Syntax UNS8 moxa_closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami) y Parameters d: [input] Node handle pointer.
IA261/262 WinCE User’s Manual y CANopen Library Return Values 0 30. moxa_setSDOlineRestBytes Store in the line structure the nb of bytes which must be transmitted (or received). y Syntax UNS8 moxa_setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes) y Parameters d: [input] Node handle pointer. line: [input] SDO channel. nbBytes: [input] Number of data received or to be sent. y Return Values Return 0 if success, 0xFF if error 31.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. Whoami: [input] SDO_CLIENT or SDO_SERVER. index: [input] The index in the object dictionary where you want to handle. subIndex: [input] The subindex of the Index. abortCode:[input] SDO abort code. y Return Values Return 1 if success, 0xFF and 0 if error 33. moxa_proceedSDO Handle a receiving SDO frame. y Syntax UNS8 moxa_proceedSDO (CO_Data* d, Message *m) y Parameters d: [input] Node handle pointer.
IA261/262 WinCE User’s Manual CANopen Library count: [input] nb of bytes to write in the dictionary. dataType: [input] defined in objdictdef.h data: [input] specified data. y Return Values 0xFF if error, else return 0 35. writeNetworkDictCallBack Used by the application to send a SDO request frame with callback functions and write the data at the index and subIndex indicated.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. nodeId: [input] nodeId:specified node id index: [input] The index in the object dictionary where you want to handle. subIndex: [input]The subindex of the Index. dataType: [input] defined in objdictdef.h y Return Values 0xFF if error, else return 0. 37. moxa_readNetworkDictCallback Used to send a SDO request frame to read a object from dictionary.
IA261/262 WinCE User’s Manual y CANopen Library Parameters d: [input] Node handle pointer. nodeId: [input]specified node id data: [output] specified data pointer. size: [output] size of data. abortCode: [output] 0 = not available. Else: SDO abort code. y Return Values SDO_FINISHED // data is available SDO_ABORTED_RCV // Transfert failed. (abort SDO received) SDO_ABORTED_INTERNAL // Transfert failed. Internal abort.
IA261/262 WinCE User’s Manual CANopen Library 40. moxa_getState Return the state of the node. y Syntax e_nodeState moxa_getState (CO_Data* d) y Parameters d: [input] Node handle pointer. y Return Values Initialisation = 0x00, Disconnected = 0x01, Connecting = 0x02, Preparing = 0x02, Stopped = 0x04, Operational = 0x05, Pre_operational = 0x7F, Unknown_state = 0x0F 41. moxa_setState Change the state of the node.
IA261/262 WinCE User’s Manual Operational = 0x05, Pre_operational = 0x7F, Unknown_state = 0x0F y CANopen Library Return Values 0xFF if error, else return 0. 42. moxa_getNodeId Return the node Id. y Syntax void moxa_getNodeId (CO_Data* d, UNS8 nodeId) y Parameters d: [input] Node handle pointer. y Return Values Return the node Id. 43. moxa_setNodeId Define the node ID. Initialize the object dictionary. y Syntax void moxa_setNodeId (CO_Data* d) y Parameters d: [input] Node handle pointer.
IA261/262 WinCE User’s Manual CANopen Library cob_id: [input]COB-ID. y Return Values 1: success, 0: fail. 45. moxa_proceedSYNC This function is called when the node is receiving a SYNC message (cob-id = 0x80). y Syntax UNS8 moxa_proceedSYNC (CO_Data* d, Message * m) y Parameters d: [input] Node handle pointer. m: [input] CAN message structure. y Return Values 0 if OK, 0xFF if error. 46. moxa_SetAlarm Use this to declare a new alarm.
IA261/262 WinCE User’s Manual y CANopen Library Syntax TIMER_HANDLE moxa_DelAlarm (TIMER_HANDLE handle) y Parameters Handle: [input] timer handle. y Return Values -1. 48. moxa_StartTimerLoop Use this to start timer loop. y Syntax void moxa_StartTimerLoop (TimerCallback_t init_callback) y Parameters init_callback:[input] the callback function. y Return Values None. 49. moxa_StopTimerLoop Use this to stop timer loop. y Syntax void moxa_StopTimerLoop (void) y Parameters None.
IA261/262 WinCE User’s Manual y CANopen Library Parameters port: [input] specified can port (1 or 2) m: [input]CAN message structure. y Return Values 1: Success, 0: fail. 51. moxa_canReceive Receive can message. y Syntax UNS8 moxa_canReceive(CAN_PORT fd0, Message *m) y Parameters Fdo:[input] driver data. typedef struct { CO_Data * d; HANDLE receive_thread; void* inst; volatile BOOL continue_receive_thread; }driver_data; m:[output] CAN message structure. y Return Values 0: success ,else error. 52.
IA261/262 WinCE User’s Manual CANopen Library struct struct_s_BOARD { * busname; //port number * baudrate;//baud rate }; d: [input] Node handle pointer. y Return Values Return handle value for this CAN port. 53. moxa_canClose The function can close the CAN controller. y Syntax int moxa_canClose (CO_Data * d) y Parameters d: [input] Node handle pointer. y Return Values 0 Example Code The following example codes can let user to understand how to configure master and slave node.
IA261/262 WinCE User’s Manual CANopen Library #include “master.h” //this file is generated by Dictionary Editor GUI } UNS8 GetChangeStateResults(UNS8 node_id, UNS8 expected_state, unsigned long timeout_ms) { unsigned long start_time = 0; // reset nodes state win32test_Data.NMTable[node_id] = Unknown_state; // request slave’s node state, send (identified=700+nodId,rtr=1) to slave.
IA261/262 WinCE User’s Manual CANopen Library UNS8 res = SDO_UPLOAD_IN_PROGRESS; // Read SDO UNS8 err = moxa_readNetworkDict (&win32test_Data, nodeId, index, subIndex, dataType); if (err) return 0xFF; for(;;) { res = moxa_getReadResultNetworkDict (&win32test_Data, nodeId, data, size, &abortCode); if (res != SDO_UPLOAD_IN_PROGRESS) break; Sleep(1); continue; } moxa_closeSDOtransfer(&win32test_Data, nodeId, SDO_CLIENT); if (res == SDO_FINISHED) return 0; return 0xFF; } int _tmain(int argc, _TCHAR* argv[])
IA261/262 WinCE User’s Manual CANopen Library /* process command line arguments */ if (argc < 3) { wprintf( TEXT(“USAGE: master \n”) ); return 1; } node_id = _wtoi(argv[1]); if (node_id < 2 || node_id > 127) { wprintf(TEXT(“ERROR: node_id shoule be >=2 and <= 127\n”)); return 1; } if (moxa_canOpen(&MasterBoard,&master_Data)) { /* Defining the master node Id */ moxa_setNodeId(&master_Data, 0x01); /* set the master in operational mode */ moxa_setState(&master_Data, Operational); /* As
IA261/262 WinCE User’s Manual CANopen Library /* wait until slave’s mode will switch to operational state*/ /* if return 0, mean this node entry operational state */ if (GetChangeStateResults(node_id, Operational, 20000) != 0xFF) { /*modify Client SDO 1 Parameter, mapping to dictionary index:1280 ,client:0x600,server:0x580 */ UNS32 COB_ID_Client_to_Server_Transmit_SDO = 0x600 + node_id; UNS32 COB_ID_Server_to_Client_Receive_SDO = 0x580 + node_id; UNS32 Node_ID_of_the_SDO_Server = node_id; UNS8 ExpectedSiz
IA261/262 WinCE User’s Manual CANopen Library res = ReadSDO(node_id, 0x1000, 0, uint32, &dev_type, &size); printf(“device type: %d\n”,dev_type & 0xFFFF); size = sizeof (device_name); res = ReadSDO(node_id, 0x1008, 0, visible_string, device_name, &size); printf(“device name: %s\n”,device_name); size = sizeof (hw_ver); res = ReadSDO(node_id, 0x1009, 0, visible_string, hw_ver, &size); printf(“HW version: %s\n”,hw_ver); size = sizeof (sw_ver); res = ReadSDO(node_id, 0x100A, 0, visible_string, sw_ver, &size
IA261/262 WinCE User’s Manual CANopen Library } else { wprintf(TEXT(“ERROR: Object dictionary access failed\n”)); } } else { wprintf(TEXT(“ERROR: node_id %d is not responding\n”),node_id); } moxa_masterSendNMTstateChange (&master_Data, 0, NMT_Stop_Node); moxa_setState(&master_Data, Stopped); moxa_canClose(&master_Data); } return 0; } Configure Slave node: #include #include #pragma comment(lib, “CANopen.lib”) extern “C” { #include #include “Slave.
IA261/262 WinCE User’s Manual CANopen Library int _tmain(int argc, _TCHAR* argv[]) { //set canbus port and baud rate s_BOARD MasterBoard = {“2”, “1000K”}; //create canopen if (moxa_canOpen(&MasterBoard,&Slave_Data)) { //set slave state to pre-operational moxa_setState(&Slave_Data, Pre_operational); //modify Client SDO 1 Parameter, mapping to dictionary, the default node id is 0x05.