Receiving data via modbus tcp
Boobert21 opened this issue · 1 comments
Boobert21 commented
I have a PLC that broadcasts data. I tried to get this data using "easy modbus tcp", but I get ex "Starting address invalid or starting address + quantity invalid"
static void Modsim()
{
ModbusClient modbusClient = new ModbusClient("10.7.0.2", 502);
modbusClient.Connect();
modbusClient.ReceiveDataChanged += ModbusClient_ReceiveDataChanged;
Console.WriteLine("Receiving data:");
int startingAddress = 49000;
int quantity = 9;
while (isChatRunning)
{
try
{
for (int i = startingAddress; i < startingAddress + quantity; i++)
{
modbusClient.ReadHoldingRegisters(startingAddress, quantity);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
static void ModbusClient_ReceiveDataChanged(object sender)
{
ModbusClient modbusClient = (ModbusClient)sender;
string receivedData = BitConverter.ToString(modbusClient.receiveData.ToArray());
if (receivedData.Length > 0)
{
Console.WriteLine(receivedData);
}
Thread.Sleep(1000);
}
So far I'm training on modsim32. These are the values I have set:
Address: 9000
Length: 10
Device id: 1
Modbus Point Type: 03: Holding Register
IP: 127.0.0.1, Port: 502
Please tell me what I did wrong. Or what I didn't. I would be glad for any information)
Padanian commented
I see 49000 in place of 9000? That might have an impact?
Da: Boobert21 ***@***.***>
Inviato: venerdì 25 agosto 2023 10:11
A: rossmann-engineering/EasyModbusTCP.NET ***@***.***>
Cc: Subscribed ***@***.***>
Oggetto: [rossmann-engineering/EasyModbusTCP.NET] Receiving data via modbus tcp (Issue #102)
I have a PLC that broadcasts data. I tried to get this data using "easy modbus tcp", but I get ex "Starting address invalid or starting address + quantity invalid"
static void Modsim()
{
ModbusClient modbusClient = new ModbusClient("10.7.0.2", 502);
modbusClient.Connect();
modbusClient.ReceiveDataChanged += ModbusClient_ReceiveDataChanged;
Console.WriteLine("Receiving data:");
int startingAddress = 49000;
int quantity = 9;
while (isChatRunning)
{
try
{
for (int i = startingAddress; i < startingAddress + quantity; i++)
{
modbusClient.ReadHoldingRegisters(startingAddress, quantity);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
static void ModbusClient_ReceiveDataChanged(object sender)
{
ModbusClient modbusClient = (ModbusClient)sender;
string receivedData = BitConverter.ToString(modbusClient.receiveData.ToArray());
if (receivedData.Length > 0)
{
Console.WriteLine(receivedData);
}
Thread.Sleep(1000);
}
So far I'm training on modsim32. These are the values I have set:
Address: 9000
Length: 10
Device id: 1
Modbus Point Type: 03: Holding Register
IP: 127.0.0.1, Port: 502
Please tell me what I did wrong. Or what I didn't. I would be glad for any information)
—
Reply to this email directly, view it on GitHub <#102> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AB3I2BD6GJ377XYWCXPAPB3XXBM2ZANCNFSM6AAAAAA36EUCAM> .
You are receiving this because you are subscribed to this thread. <https://github.com/notifications/beacon/AB3I2BCS6BKJ6SZMG6L7HO3XXBM2ZA5CNFSM6AAAAAA36EUCAOWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHG6QMPXM.gif> Message ID: ***@***.*** ***@***.***> >
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage", "potentialAction": { ***@***.***": "ViewAction", "target": "#102", "url": "#102", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]