Yokogawa FA-M3 PLC simple test program and library Kazuro Furukawa ========== Command usage of plc4 or plctest4 : ========== Usage: plc4 [] [data1 [data2 [...]]] options: -d debug information -dd more verbose -l {C} loop count -i {S} loop interval -m increment each data at each loop -h {host} plc hostname -g {host2} optional 2nd plc hostname -a {Xxxxx} plc register address -r {N} number of data to read -w {N} number of data to write -c {data} data to write (using with -w) -p {prot} protocol, wwr/wrd:0 (default), mcm:7 -t use tcp transport instead of udp -q {opt} query option '-h host' and ('-a' or '-q') are mandatory. data1... are data to write (0xddd for hex) examples: plc4 -h yewplc -a D100 -w 10 -c 3 -l 10 plc4 -h yewplc -a D200 -r 3 0xff 11 0xee plc4 -h yewplc -a D300 -r 3 -m -l 100 -i 0 10 20 30 plc4 -h yewplc -g yewplc2 -a D300 -r 3 -l 1 -i 0 options for query 1 cpu status, and program status 2 system id., cpu type, and area size 3:{unit} module names, and input/output info. examples: plc4 -h yewplc -q 1 -i10 plc4 -h yewplc -q 2 plc4 -h yewplc -q 3:0 -i0 -l1 plc4 -h yewplc -q 3:1\n"); ========== Library usage ========== /* * plc4 * yew plc (fa-m3) library * k.furukawa, oct.6.1997, oct.25.1997, jul.20.1999. * * k.f sep.19.2002. correct protocol, retry on timout as well (v3.0) * k.f jul.3.2003. add query protocol (v3.1) * k.f aug.10.2003. merge WRD/WWR protocol as well as MCM (v3.2) * k.f aug.17.2006. add tcp option (v3.3) */ /* this program is a test program. */ static char what_plc4[] = "@(#)plc4 v3.3.0 yew plc, k.furukawa, oct.1997-aug.2006"; /********** * plcclose -- close a channel to a plc */ int plcclose () /********** * plcwrite4 -- write values into a plc (MCM) */ int plcwrite4 ( char *host, /* host - host name or ip address of yew plc */ char *caddr, /* caddr - address to write ("Xxxxx") */ int addr, /* addr - address to write (Dxxxx), when caddr is NULL */ char *trans, /* trans - transport to use */ int size, /* size - number of words to write (maximum of 247?) */ unsigned short *data /* data - data to write */ ) /********** * plcread4 -- read values from a plc (MCM) */ int plcread4 ( char *host, /* host - host name or ip address of yew plc */ char *caddr, /* caddr - address to read ("Yxxxx") */ int addr, /* addr - address to read (Dxxxx), when caddr is NULL */ char *trans, /* trans - transport to use */ int size, /* size - number of words to read (maximum of 247?) */ unsigned short *data /* data - data to read */ ) /********** * plcwrite2 -- write values into a plc (WWR) */ int plcwrite2 ( char *host, /* host - host name or ip address of yew plc */ char *caddr, /* caddr - address to write ("Xxxxx") */ int addr, /* addr - address to write (Dxxxx), when caddr is NULL */ char *trans, /* trans - transport to use */ int size, /* size - number of words to write (maximum of 256) */ unsigned short *data /* data - data to write */ ) /********** * plcread2 -- read values from a plc (WRD) */ int plcread2 ( char *host, /* host - host name or ip address of yew plc */ char *caddr, /* caddr - address to read ("Yxxxx") */ int addr, /* addr - address to read (Dxxxx), when caddr is NULL */ char *trans, /* trans - transport to use */ int size, /* size - number of words to read (maximum of 247?) */ unsigned short *data /* data - data to read */ ) /********** * plcquery -- query to a plc (INF) */ int plcquery ( char *host, /* host - host name or ip address of yew plc */ char *trans, /* trans - transport to use */ int option, /* option - query option, 1 - 5 */ int unit, /* unit - 0 - 7 */ unsigned short *data, /* data - data to read */ int *size /* size - received data size */ )