modbus-rtu.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright © 2001-2010 Stéphane Raimbault <stephane.raimbault@gmail.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _MODBUS_RTU_H_
  18. #define _MODBUS_RTU_H_
  19. #include "modbus.h"
  20. /* Modbus_Application_Protocol_V1_1b.pdf Chapter 4 Section 1 Page 5
  21. * RS232 / RS485 ADU = 253 bytes + slave (1 byte) + CRC (2 bytes) = 256 bytes
  22. */
  23. #define MODBUS_RTU_MAX_ADU_LENGTH 256
  24. modbus_t* modbus_new_rtu(const char *device, int baud, char parity,
  25. int data_bit, int stop_bit);
  26. #define MODBUS_RTU_RS232 0
  27. #define MODBUS_RTU_RS485 1
  28. int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode);
  29. int modbus_rtu_get_serial_mode(modbus_t *ctx);
  30. #endif /* _MODBUS_RTU_H_ */