Help!!! convert code javascript to python

babido10

Member
Join Date
Nov 2017
Location
rabat
Posts
28
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);
 
That's not Javascript, it looks more like Java. But the System.Windows.Forms call means it's probably C#.

What are you actually trying to do?
 
That's not Javascript, it looks more like Java. But the System.Windows.Forms call means it's probably C#.

What are you actually trying to do?

trying to get Python to work with Libnodave. Libnodave is a library that allows you to read/write data from/to a lot of Siemens PLCs
 
I know nothing about Siemen's Plc's. But do they have a MQTT Driver? Open Automation does I know.

My point is Python has some very good examples of subscribing to MQTT Brokers and doing just about anything you want with the data.
 
I know nothing about Siemen's Plc's. But do they have a MQTT Driver? Open Automation does I know.

My point is Python has some very good examples of subscribing to MQTT Brokers and doing just about anything you want with the data.

You made me google it... https://github.com/RoanBrand/MQTT-Siemens-S7-300

I guess anything is possible if you create the correct program :). Never even thought about doing this with Siemens.. I use it all around the house for sensor nodes and my sprinkler system (NodeMCU & Arduino).

Now I know what my next project is going to be :). Thanks ;)
 
The bit that didn't come across from his other post is that he is using a USB connected MPI cable. I think I would split the problem in to two parts, first work in libnodave to make sure that the USB connected MPI cable connection can work with libnodave. Then try to get libnodave to work with Python. There are some simple test MPI programs in the libnodave Dot.NET folders that I converted to get working with PPI to an S7-200. If you search here on plctalk.net for libnodave you will find at least one working program that uses libnodave.

Just found this note in the libnodave usb2mpi-Linux-2.6 folder:
siemens-mpi.ko is a module that allows to use the USB to MPI adapter 6ES7-972-0CB20-0AX0
from Siemens under Linux. It was written for kernel 2.6 and tested under 2.6.13.
 

Similar Topics

hi, i try to capture barcode data using UDT with SINT ascii array. i have all the data i need but it in array format, how can i convert to 1...
Replies
5
Views
3,016
I am trying to convert this simple ladder diagram (for Omron Symatic 200) into Pascal, C or Basic. I want to use a PICmicro instead of PLC, but I...
Replies
3
Views
5,822
G
Now I have project for Test in my university, I want to convert Lader Code to Hex Code Ex.. LD ====> 0XXX How to convert sulution if...
Replies
5
Views
7,347
i hope you could help me to convert the network Stl to lad it's apart from program of machine and i try to find solution for the reason of error...
Replies
10
Views
1,851
Hello everyone, I am migrating a program from STL to SCL via S7-1200 portal, I would like you to help me by converting these lines of code...
Replies
4
Views
1,607
Back
Top Bottom