Closed Rahul14189 closed 11 months ago
Hi,
Please show full code you are referring to. From the error looks like you are not calling connect
properly/at all.
Also, keep in mind that TCP connection here is just for serial-over-ethernet transport, not any FX-specific TCP connection protocol.
Hi ,
Thanks for the reply, I have attached the code below,
import asyncio from contextlib import closing from fxplc.client.FXPLCClient import FXPLCClient from fxplc.transports.TransportTCP import TransportTCP
async def main(): transport = TransportTCP("192.10.14.2", 5000)
for _ in range(3):
try:
await transport.connect()
print("Connected to the PLC.")
break
except Exception as e:
print(f"Error: {e}")
await asyncio.sleep(1)
with closing(FXPLCClient(transport)) as fx:
s0_state = await fx.read_bit("D100")
# t0_state = await fx.read_bit("T0")
# t0_value = await fx.read_int("T0")
print(f"value_1: {s0_state}")
if name == "main": asyncio.run(main())
Now i did some changes and now my error is,
And at GX works 2, i have made some changes,
as mentioned, TransportTCP class is not for proprietary melsec TCP protocol (I don't even have device to test it). It is just for RS232<->ETH connector. I doubt they made ethernet connection compatibly with their 7-bit ASCII protocol.
BTW, in you code, if it didn't manage to connect to the transport tree times, it just continues with unconnected transport.
in my code, if it does not get connected or if the PLC doesn't allow the connection, then i get error at the transport's connect method itself, because it tries three times, so its something like this,
But if the PLC is not engaged with any other utility tool and is in running condition, then i don't get error at transport's connect, and the log is somehow similar to,
the log shows that, in the first try itself connect method was successfully called. So, it means the transport connect method is responding as it should, please correct me if my understanding is in wrong direction. Do you think we can use this, to read data from the PLC ?
So, it means the transport connect method is responding as it should
Transport connects successfully, but this is just TCP connect().
Do you think we can use this, to read data from the PLC ?
Only via RS232/RS485 if your PLC has this.
Thanks Krystian
Hi,
Thanks for the library, for FX series PLC's.
I am trying to connect with the PLC, but i am unable to connect. My PLC is FX3U and FX5U. I am using python script similar to provided by you in the document, but it throws me error as,
I can see the error is thrown at transport.connect itself. Here, in the snippet, i have tried read method of transport too, in order to verify the connection, even if we remove that and keep the code same as given in the document , the error is same. However, the plc is available at the pointed ip-address and port, i have verified this.
It will be helpful if you can guide, what mistake i am making!!