81
CHAPTER 7 COMMUNICATION OF THE ETHERNET ADAPTER MODULE
7
7.
1 SLM
P
Com
m
unicat
ion
and Cyc
lic
T
ransm
ission
(2) Creating a program
A program example is shown in this section. Programs should be executed from an external device.
●
In the program example shown in this section, the minimum processing is described. When including any other
processing such as error handling, add the corresponding program to it.
●
If the Ethernet adapter module is powered off and then on, data written from the external device to the Ethernet adapter
module using SLMP will be cleared. Therefore, create a program of communicating data while handshaking with the
master station.
(a) Programming environment
Development environment: Microsoft
Visual C++
2005
Library that requires a link: ws2_32.lib
(b) Configuration of the Ethernet adapter module
(c) Program example
Item
Setting
IP address
192.168.3.30
Subnet mask
255.255.255.0
Port No.
2000
H
//EthernetAD_test.cpp: Defines the entry point of the console application.
//
#include "stdafx.h"
/***********************************************************************************************/
/**
**/
/**
Sample program (program name: EthernetAD_test.cpp)
**/
/**
**/
/**
This is a sample program for testing a connection between
**/
/**
the Ethernet adapter module and the external device.
**/
/**
This program reads RY0000 to RY001F of the Ethernet adapter module **/
/**
and writes data to RWr0000 and RWr0001.
**/
/**
**/
/**
Copyright(C) 2010 Mitsubishi Electric Corporation
**/
/**
All Rights Reserved
**/
/**
**/
/***********************************************************************************************/
#include <winsock2.h>
#define FLAG_OFF 0
// End flag OFF
#define FLAG_ON 1
// End flag ON
#define SOCK_OK 0
// Normal end
#define SOCK_NG -1
// Abnormal end
#define BUF_SIZE 4096
// Receive buffer size
#define ERROR_INITIAL 0
// Initial error
#define ERROR_SOCKET 1
// Socket creation error
#define ERROR_BIND 2
// Bind error
#define ERROR_CONNECT 3
// Connect error
#define ERROR_SEND 4
// Send error
#define ERROR_RECIEVE 5
// Receive error
#define ERROR_SHUTDOWN 6
// Shutdown error
#define ERROR_CLOSE 7
// Line close error
Summary of Contents for NZ2GF-ETB
Page 1: ...CC Link IE Field Network Ethernet Adapter Module User s Manual NZ2GF ETB ...
Page 2: ......
Page 49: ...47 CHAPTER 4 PROCEDURE BEFORE THE OPERATION 4 4 1 Start Up Procedure Memo ...
Page 198: ...196 a Detail Setting ...
Page 246: ...244 Memo ...
Page 253: ......