Hello, I have a solar inverter that have a custom protocol (VABUS of Bonfiglioli) and I need to send a custom request for read de power of the inverter with bytes in TCP. I don't want testing with a real inverter so i'm using ModRSIM that is a Modbus TCP Server simulator and i want to read a holding register with a script for test how send bytes to a TCP Server.
In python i have a script that works fine:
*import socket*
*import time*
*def trama_modbus():*
* asdu = bytearray()*
*#2 bytes para el transaction id*
* asdu.append(0x00)*
* asdu.append(0x01)*
*#protocolo id, como es modbus esto es 00*
* asdu.append(0x00)*
* asdu.append(0x00)*
*#va tener una longitud de 6 registros*
* asdu.append(0x00)*
* asdu.append(0x06)*
*#el slave id es el 1*
* asdu.append(0x01)*
*#como vamos a leer holding es la fc 3*
* asdu.append(0x03)*
*#el primer registro a leer es el 3*
* asdu.append(0x00)*
* asdu.append(0x03)*
*#el numero de registros que se pide en bloque es 1*
* asdu.append(0x00)*
* asdu.append(0x01)*
* return asdu*
*# Press the green button in the gutter to run the script.*
*if __name__ == '__main__':*
* HOST = '127.0.0.1' # IP del servidor*
* PORT = 507 # Puerto de escucha del servidor*
* data = trama_modbus()*
* print(data)*
* s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)*
* s.connect((HOST, PORT))*
* s.send(data)*
* time.sleep(1)*
* resultado = s.recv(1024)*
* print(resultado.hex())*
* s.close()*
But I want do this in Ignition and I don't know how do it:
I think that the problem is the creation of the message but i don't know how create the message. I'm using Ignition perspective but im testing this in Script Console of designer.