Hello can i comunicate with the servodrive in the object, do you have any example because this is what i have done:
import socket
from pymelsec import Type3E
from pymelsec.constants import DT # Importa i Data Type
from pymelsec.tag import Tag # Importa la classe Tag
plc = Type3E(host="192.168.3.1", port=5010)
Patch UDP
plc._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
plc._socket.settimeout(2.0)
plc._server_address = (plc.host, plc.port)
plc.open = lambda: None
plc.close = lambda: plc._socket.close()
plc._send = lambda payload: plc._socket.sendto(payload, plc._server_address)
plc._recv = lambda: plc._socket.recvfrom(4096)[0]
try:
# tag list
tags_to_read = [
Tag(device="D100", type=DT.SWORD), # Word con segno (Short)
Tag(device="D101", type=DT.UWORD), # Word senza segno
Tag(device="M100", type=DT.BIT) # Singolo bit
]
read
results = plc.read(devices=tags_to_read)
print('results: ', results)
print results
for tag in results:
print(f"Device: {tag.device} | Value: {tag.value}")
except socket.timeout:
print("Errore: plc never reply")
finally:
plc.close()
I never get any error but results is empty list
is there any way to read hex register like modbus??
Thanks
Hello can i comunicate with the servodrive in the object, do you have any example because this is what i have done:
import socket
from pymelsec import Type3E
from pymelsec.constants import DT # Importa i Data Type
from pymelsec.tag import Tag # Importa la classe Tag
plc = Type3E(host="192.168.3.1", port=5010)
Patch UDP
plc._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
plc._socket.settimeout(2.0)
plc._server_address = (plc.host, plc.port)
plc.open = lambda: None
plc.close = lambda: plc._socket.close()
plc._send = lambda payload: plc._socket.sendto(payload, plc._server_address)
plc._recv = lambda: plc._socket.recvfrom(4096)[0]
try:
# tag list
tags_to_read = [
Tag(device="D100", type=DT.SWORD), # Word con segno (Short)
Tag(device="D101", type=DT.UWORD), # Word senza segno
Tag(device="M100", type=DT.BIT) # Singolo bit
]
read
results = plc.read(devices=tags_to_read)
print('results: ', results)
print results
for tag in results:
print(f"Device: {tag.device} | Value: {tag.value}")
except socket.timeout:
print("Errore: plc never reply")
finally:
plc.close()
I never get any error but results is empty list
is there any way to read hex register like modbus??
Thanks