필터 지우기
필터 지우기

Modbus crc16 calculation

조회 수: 8 (최근 30일)
Rohit Baranwal
Rohit Baranwal 2016년 6월 2일
댓글: John D'Errico 2016년 6월 2일
Hi, I have written a function to compute CRC16 checksum for Modbus messages. The function accepts a Modbus message in uint16 format and gives the checksum in uint16 format (without swapping low and high bytes). I have submitted it here: http://www.mathworks.com/matlabcentral/fileexchange/57479-modbus-crc--message-modbus-- I have used the procedure outlined in Appendix B, page 39/44 of 'MODBUS over serial line specification and implementation guide V1.02'. The results agree with the following calculator: http://www.lammertbies.nl/comm/info/crc-calculation.html
However, since I am processing uint16, this means that message must have even number of bytes. However, Modbus can have odd number of bytes in a message, correct? If true, then should the data input be of uint8 type rather than uint16? Please help.
  댓글 수: 1
John D'Errico
John D'Errico 2016년 6월 2일
This is YOUR code as you have written it, right? So the input can be whatever you choose to require it to be.
Nothing stops you from testing the input to determine the class of a variable, and even perhaps acting intelligently on what is passed in.
So what is your question?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Modbus Communication에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by