I communicate with 06's 250-1's and 260's using Host engineering's SDK.
I am using HEICCMRequest to read and write the plc's vmemory from the
PC.
Here is a code fragment:
#pragma warning(disable:4103)
#include "hei.h"
static HEIDevice device;
static HEITransport tp;
static int warn = 1;
void PlcioOpen ()
{
unsigned s;
unsigned short count;
long ip;
memset(&tp, 0, sizeof(tp));
memset(&device, 0, sizeof(device));
s = HEIOpen(HEIAPIVERSION);
if (s && warn) lprintf ("Open %d\n", s);
tp.Transport = HEIT_WINSOCK;
tp.Protocol = HEIP_IP;
s = HEIOpenTransport(&tp, HEIAPIVERSION, 0);
if (s && warn) lprintf ("Open Transport %d\n", s);
count = 1;
s = HEIQueryDevices(&tp, &device, &count, HEIAPIVERSION);
if (s && warn) lprintf ("Query Device %d, %d found\n", s, count);
/* The open routine in this example is rather weak. It is hard-coded to */
/* hex 0x0114a8c0 which is 192.168.20.1. There are better ways to do this. */
device.Address.AddressIP.AddressingType.lAddr = 0x0114a8c0;
s = HEIOpenDevice(&tp, &device, HEIAPIVERSION, 25, 3, FALSE);
if (s && warn) lprintf ("Open device %d\n", s);
device.Retrys = 0;
device.Timeout = 100;
}
int PlcioRead (long vloc)
{
unsigned s;
unsigned short vdata;
s = HEICCMRequest (&device, FALSE, 0x31, vloc + 1, 2, (BYTE *) &vdata);
if (s && warn) lprintf ("PlcRead failed, status %x\n", s);
return s ? -1 : vdata;
}
int PlcioWrite (long vloc, int vdata)
{
unsigned s;
unsigned short bvdata;
bvdata = vdata;
s = HEICCMRequest (&device, TRUE, 0x31, vloc + 1, 2, (BYTE *) &bvdata);
if (s && warn) lprintf ("PlcWrite failed, status %x\n", s);
return !s;
}
In practice, it is better (performance) to exchange small blocks of v memory
each direction, rather than to read individual locations.
This is done by changing the 2 to 2 * n (where n is the number of words to
transfer), and making the last argument to HEICCMRequest an array.
But this should at least get you started.