EasyManua.ls Logo

YASKAWA MP920 - Appendix C C Language Sample Programs; Sample Programs for Master Station; TCP (When Using Extended MEMOBUS Protocol (SFC = 09

YASKAWA MP920
336 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Appendix C C Language Sample Programs
C.1.1 TCP (When Using Extended MEMOBUS Protocol (SFC = 09))
C-2
C.1 Sample Programs for Master Station
The programs listed in this appendix were prepared only for reference purpose and they may not
operate correctly in actual applications. To execute the programs, a socket library and C com-
piler must be installed on the personal computer.
The brief explanations on the program contents are written in italics after double-slash (//) in the
programs.
The line on the left end of the program indicates the positions of paragraph indentions.
C.1.1 TCP (When Using Extended MEMOBUS Protocol (SFC = 09))
#include <stdio.h>
#include <winsock.h>
#include <winioctl.h>
int sd; /* Socket Discripter */
struct sockaddr_in my;
struct sockaddr_in dst;
#define MY_IP 0xC0A80103
// Local IP address: 192.168.1.3
#define MY_PORT 5000 // Local port number
#define DST_IP 0xC0A80101 // Remote IP address: 192.168.1.1
#define DST_PORT 5000 // Remote port number
char sbuf[2048];
char rbuf[2048];
void main_tcp(void);
void mk_cmd_data(void);
int chk_rsp_data(int);
void main_tcp(void)
{
WSADATAwsadata;
int rc, slen, rlen;
// Declaration to use Winsock.dll (Always required at first.)
rc = WSAStartup( 0x0101, &wsadata );
if ( rc != 0 )
{
exit(0);
}
Ethernet
CN1
PORT
MP920 (Slave)
Personal computer (Master)
IP address192. 168. 1. 1
Port number5000
IP address192. 168. 1. 3.
Port number5000
Configuration and Setting Example

Table of Contents

Related product manuals