input_bits.c 464 B

12345678910111213141516171819
  1. #include "slave.h"
  2. static uint8_t _tab_input_bits[10] = {0, 1, 1, 0, 0, 1, 1, 0, 0, 1};
  3. static int get_map_buf(void *buf, int bufsz)
  4. {
  5. uint8_t *ptr = (uint8_t *)buf;
  6. pthread_mutex_lock(&slave_mtx);
  7. for (int i = 0; i < sizeof(_tab_input_bits); i++) {
  8. ptr[i] = _tab_input_bits[i];
  9. }
  10. pthread_mutex_unlock(&slave_mtx);
  11. return 0;
  12. }
  13. const agile_modbus_slave_util_map_t input_bit_maps[1] = {
  14. {0x041A, 0x0423, get_map_buf, NULL}};