CustomModbusRequest #2854
-
|
I have a device that recognizes a Modbus address but the rest of the PDU data is unique. It doesn't respond to messages for other device Modbus addresses, so it could exist on my rs485 network. Is there a way I can send a raw data message out to this device that I preset in my code and send it with an expected response length in bytes and get back a raw data packet? I would expect a timeout if enough bytes were not received but I would like to see the raw data that was received as well. I have done some research on this CustomModbusRequest but it looks like it just adds another function code. The device I have does have a new function code of 0xB3 plus a check code of 1 and is ends with a check sum rather than a CRC. The response is a fixed 37 bytes that also ends in a check sum. Is there a way I can talk to this device with PyModbus? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
|
Imho you need a custom Framer too |
Beta Was this translation helpful? Give feedback.
-
|
First I would like to thank both of you for timely responses. After 40+ years in factory automation and controls doing among many other things dealing with Modbus and other industrial communication protocols I find myself retired and looking to add solar panels, inverter/charger, and a big battery to my camper. The devices I'm using claim to support Modbus but not really. 10 to 20 years ago I would have banged this out in a week or so using VB6, ActiveX components and a little C programming. Now I'm programming Python for the first time and targeting a linux based Raspberry Pi for my HMI. My experience is there have always been some devices that claim to support Modbus but not really. Sometimes you can get the manufacture to fix their bugs and sometimes you have to work around them. It looks like my three choices are custom Framer/Function, calling the transport myself, or writing the whole thing myself. The last option is the least appealing. Calling the transport myself sounds like what I was thinking about. The custom Framer sounds intriguing if I can write my own check sum code. What I could really use right now is some guidance as to what might be the best option, what modules/code to look at, and are there any documentation/examples as to how to do this. Thanks again for all your help. |
Beta Was this translation helpful? Give feedback.
-
|
In my experience most modern solar inverters support modbus in a pretty standard way, however often with user function code extension. 0xB3 is a user function code, so just add a custom pdu for both request and response. ps. I too have 40+ experience in automation, primarily SCADA systems and communication protocols. |
Beta Was this translation helpful? Give feedback.
-
|
My Inverter/Chargers "Modbus" protocol is documented to be RTU but it has a check sum not a CRC. The response also has a check sum. The response also doesn't have byte or register count information. It is a fixed length response of 37 bytes. I have already verified this. I have another device where the register count is byte swapped. when you request 1 register it takes as 256 registers and returns an exception. I have some work to do and I was hoping to do it with PyModbus. |
Beta Was this translation helpful? Give feedback.
-
|
What is a checksum if not a CRC ??? I am pretty sure it is a CRC, since the rest seems to be modbus standard. Did you actually confirm that the messages are not CRC, and in that case what are they (checksum is a very vague statement). A lot of modbus messages do not have byte or register count information, seems like you need to read the modbus standard. Your other device needs a big/little endian correction, that is a quite normal modbus problem (even though not part of the standard). Pymodbus allows you do these corrections. Seems to me, you can easily do this with pymodbus, however you do need to familiarize yourself with the modbus standard, our online documentation as well as our examples. I really cannot help you more with your general statements, you do not provide any logs, the type of your inverter or at the very least hex dump of the messages. I have given you enough pointers that you should be able to implement what you need with pymodbus....if you prefer to use another library it is of course your choice. |
Beta Was this translation helpful? Give feedback.
What is a checksum if not a CRC ??? I am pretty sure it is a CRC, since the rest seems to be modbus standard. Did you actually confirm that the messages are not CRC, and in that case what are they (checksum is a very vague statement).
A lot of modbus messages do not have byte or register count information, seems like you need to read the modbus standard.
Your other device needs a big/little endian correction, that is a quite normal modbus problem (even though not part of the standard). Pymodbus allows you do these corrections.
Seems to me, you can easily do this with pymodbus, however you do need to familiarize yourself with the modbus standard, our online documentation as well as our exa…