modbus-rtu-private.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_PRIVATE_H_
  18. #define _MODBUS_RTU_PRIVATE_H_
  19. #define _MODBUS_RTU_HEADER_LENGTH 1
  20. #define _MODBUS_RTU_PRESET_REQ_LENGTH 6
  21. #define _MODBUS_RTU_PRESET_RSP_LENGTH 2
  22. #define _MODBUS_RTU_CHECKSUM_LENGTH 2
  23. typedef struct _modbus_rtu {
  24. /* Device: "/dev/ttyS0", "/dev/ttyUSB0" or "/dev/tty.USA19*" on Mac OS X for
  25. KeySpan USB<->Serial adapters this string had to be made bigger on OS X
  26. as the directory+file name was bigger than 19 bytes. Making it 67 bytes
  27. for now, but OS X does support 256 byte file names. May become a problem
  28. in the future. */
  29. #ifdef __APPLE_CC__
  30. char device[64];
  31. #else
  32. char device[16];
  33. #endif
  34. /* Bauds: 9600, 19200, 57600, 115200, etc */
  35. int baud;
  36. /* Data bit */
  37. uint8_t data_bit;
  38. /* Stop bit */
  39. uint8_t stop_bit;
  40. /* Parity: 'N', 'O', 'E' */
  41. char parity;
  42. /* Save old termios settings */
  43. struct termios old_tios;
  44. } modbus_rtu_t;
  45. #endif /* _MODBUS_RTU_PRIVATE_H_ */