УкраїнськаEnglishmRussian
Вхід/Новий
У темі немає нових постів

Modbus over TCP


Автор Повідомлення
Повідомлення створено: 13. 03. 2013 [12:13]
citrizin
Abolfazl
Автор теми
Зареєстрован(а) с: 04.10.2012
Повідомлення: 19
Hi

I have connected oscada to my micro-controller and I am trying to communicate with oscada through modbus protocol.

oscada works as a client and sends its request to my micro controller.

for this command:
R:01:rw:R1:R1

I receive the following bytes in the micro controller side (Destination node is set to address 10):
0x20 0x26 0x00 0x00 0x00 0x06 0x0A 0x03 0x00 0x01 0x00 0x01

First two bytes are transaction identifiers, next two are always zero, next two are number of remaining bytes. 0x0A is destination address, 0x03 corresponds to packet type(read registers), next two bytes are the address of first register and the last two bytes are the number of registers that must be read.

I recieve this packet and it seems completely OK, but when I respond to oscada using below package, oscada says server responded erroneously and resend its request and this goes on...

response packet:
0x20 0x26 0x00 0x00 0x00 0x06 0x0A 0x03 0x00 0x01 0x00 0x11 (I am saying the value for register 1 is 17)


Does anybody know why this is wrong? Where can I find the exact template of responses to oscada modbus packets?

Thanks
Повідомлення створено: 13. 03. 2013 [12:15]
citrizin
Abolfazl
Автор теми
Зареєстрован(а) с: 04.10.2012
Повідомлення: 19


"citrizin" wrote:

Does anybody know why this is wrong? Where can I find the exact template of responses to oscada modbus packets?



In fact I want to know the template for the pdu that oscada can understand it.
Повідомлення створено: 13. 03. 2013 [16:33]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
"citrizin" wrote:

response packet:
0x20 0x26 0x00 0x00 0x00 0x06 0x0A 0x03 0x00 0x01 0x00 0x11 (I am saying the value for register 1 is 17)

Your respond is wrong!
See closely to ModBus standard where you will see that correct respond's PDU is:
03 02 00 11

For ModBus messages debug also use ModBus protocol report: http://wiki.oscada.org/HomePageEn/Doc/ModBus#h871-12

Learn, learn and learn better than work, work and work.
Повідомлення створено: 13. 03. 2013 [19:03]
citrizin
Abolfazl
Автор теми
Зареєстрован(а) с: 04.10.2012
Повідомлення: 19
"roman" wrote:


correct respond's PDU is:
03 02 00 11

For ModBus messages debug also use ModBus protocol report: http://wiki.oscada.org/HomePageEn/Doc/ModBus#h871-12


Thanks Roman, that works,
Now I can see that the value for Register is correctly set to 17 and there is no indication of error.

But I think there are some bugs in the system, oscada almost ignores the ABAP header. It does not check whether transition identifiers, unit address, data length are right. even in PDU part it does not check that it has to read 0x02 bytes for the value of the register, you can put any number instead of 0x02 and there is no error. just in the case that you put extra bytes in the packet or put less than 2 bytes in the register value part, you may see an error "15:Response PDU size error."

What sould I do about this problem?

I think modbus protocol is barely implemented in oscada side, if I'm wrong please let me know.


Повідомлення створено: 13. 03. 2013 [21:06]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зареєстрован(а) с: 12.12.2007
Повідомлення: 3750
"citrizin" wrote:

Now I can see that the value for Register is correctly set to 17 and there is no indication of error.

See closely, your 17 moved to right!

"citrizin" wrote:

But I think there are some bugs in the system, oscada almost ignores the ABAP header. It does not check whether transition identifiers, unit address, data length are right. even in PDU part it does not check that it has to read 0x02 bytes for the value of the register, you can put any number instead of 0x02 and there is no error.

Sure and its are no problems for correct work.

"citrizin" wrote:

just in the case that you put extra bytes in the packet or put less than 2 bytes in the register value part, you may see an error "15:Response PDU size error."

And it is also correct!

"citrizin" wrote:

What sould I do about this problem?

Into OpenSCADA have not any problem here. Take and start ModBus/TCP test client into DemoDB or any other correct ModBus/TCP device for check!

Learn, learn and learn better than work, work and work.



2169