Hi all ;
if someone here can help me to convert this code to python
code:
public static libnodave.daveOSserialType fds;
public static libnodave.daveInterface di;
public static libnodave.daveConnection dc;
public static int res;
public static byte plcValue;
public static int memoryRes;
public static byte[] memoryBuffer = new byte[16];
public static void connectTo()
{
//fds.rfd = libnodave.openSocket(0, "192.168.X.X");
fds.rfd = libnodave.openSocket(102, "192.168.X.X");
fds.wfd = fds.rfd;
di = new libnodave.daveInterface(fds, "IF1", 0, libnodave.daveProtoISOTCP, libnodave.daveSpeed187k);
res = di.initAdapter();
dc = new libnodave.daveConnection(di, 0, 0, 3);
res = dc.connectPLC();
if (res==-1)
{
System.Windows.Forms.MessageBox.Show("Erreur de connexion");
}
else
{
//memoryRes = dc.readBytes(libnodave.daveFlags, 0, 0, 1, memoryBuffer);
memoryRes = dc.readBytes(libnodave.daveFlags, 172, 0, 1, memoryBuffer);
plcValue = memoryBuffer[0];
}
dc.disconnectPLC();
di.disconnectAdapter();
libnodave.closePort(fds.rfd);
if someone here can help me to convert this code to python
code:
public static libnodave.daveOSserialType fds;
public static libnodave.daveInterface di;
public static libnodave.daveConnection dc;
public static int res;
public static byte plcValue;
public static int memoryRes;
public static byte[] memoryBuffer = new byte[16];
public static void connectTo()
{
//fds.rfd = libnodave.openSocket(0, "192.168.X.X");
fds.rfd = libnodave.openSocket(102, "192.168.X.X");
fds.wfd = fds.rfd;
di = new libnodave.daveInterface(fds, "IF1", 0, libnodave.daveProtoISOTCP, libnodave.daveSpeed187k);
res = di.initAdapter();
dc = new libnodave.daveConnection(di, 0, 0, 3);
res = dc.connectPLC();
if (res==-1)
{
System.Windows.Forms.MessageBox.Show("Erreur de connexion");
}
else
{
//memoryRes = dc.readBytes(libnodave.daveFlags, 0, 0, 1, memoryBuffer);
memoryRes = dc.readBytes(libnodave.daveFlags, 172, 0, 1, memoryBuffer);
plcValue = memoryBuffer[0];
}
dc.disconnectPLC();
di.disconnectAdapter();
libnodave.closePort(fds.rfd);