Using Visual Stdio2010 C#, 6ES7 972-OB20-0A0 PC Adapter (USB)
code public static void MainMPI(string NamePort, int AdressMPI) { int a = 0, b = 0, c = 0, res; float d = 0;
fds.rfd = libnodave.setPort(NamePort, "38400", 'O'); fds.wfd = fds.rfd;
if (fds.rfd > 0) { di = new libnodave.daveInterface(fds, "IF1", localMPI, libnodave.daveProtoMPI, libnodave.daveSpeed187k); di.setTimeout(1000000);
res = di.initAdapter();
if (res == 0) { dc = new libnodave.daveConnection(di, AdressMPI, 0, 0); if (dc.connectPLC() == 0) { res = dc.readBytes(libnodave.daveFlags, 0, 0, 16, null); if (res == 0) { a = dc.getS32(); b = dc.getS32(); c = dc.getS32(); d = dc.getFloat(); MessageBox.Show("FD0:" + a.ToString() + " FD4:" + b.ToString() + " FD8:" + c.ToString() + " FD12:" + d.ToString()); } else MessageBox.Show("Error" + res.ToString() + " " + libnodave.daveStrerror(res)); } dc.disconnectPLC(); } di.disconnectAdapter(); libnodave.closePort(fds.rfd); } else { MessageBox.Show("Couldn't open serial port " + NamePort); } }
di.initAdapter() returns -44? NamePort = "COM1" Tried to use NamePort = "USB", then libnodave.setPort return -1?
Help please
Anonymous
You seem to have CSS turned off. Please don't fill out this field.
adapter in the device manager is defined as a Simatic PC Adapter USB, as it the new model with USB
Using Visual Stdio2010 C#, 6ES7 972-OB20-0A0 PC Adapter (USB)
code
public static void MainMPI(string NamePort, int AdressMPI)
{
int a = 0, b = 0, c = 0, res;
float d = 0;
fds.rfd = libnodave.setPort(NamePort, "38400", 'O');
fds.wfd = fds.rfd;
if (fds.rfd > 0)
{
di = new libnodave.daveInterface(fds, "IF1", localMPI, libnodave.daveProtoMPI, libnodave.daveSpeed187k);
di.setTimeout(1000000);
res = di.initAdapter();
if (res == 0)
{
dc = new libnodave.daveConnection(di, AdressMPI, 0, 0);
if (dc.connectPLC() == 0)
{
res = dc.readBytes(libnodave.daveFlags, 0, 0, 16, null);
if (res == 0)
{
a = dc.getS32();
b = dc.getS32();
c = dc.getS32();
d = dc.getFloat();
MessageBox.Show("FD0:" + a.ToString() + " FD4:" + b.ToString() + " FD8:" + c.ToString() + " FD12:" + d.ToString());
}
else
MessageBox.Show("Error" + res.ToString() + " " + libnodave.daveStrerror(res));
}
dc.disconnectPLC();
}
di.disconnectAdapter();
libnodave.closePort(fds.rfd);
}
else
{
MessageBox.Show("Couldn't open serial port " + NamePort);
}
}
di.initAdapter() returns -44?
NamePort = "COM1"
Tried to use NamePort = "USB", then libnodave.setPort return -1?
Help please
adapter in the device manager is defined as a Simatic PC Adapter USB, as it the new model with USB
Help please