-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathbits.c
More file actions
32 lines (24 loc) · 731 Bytes
/
Copy pathbits.c
File metadata and controls
32 lines (24 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "slave.h"
static uint8_t _tab_bits[10] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
static int get_map_buf(void *buf, int bufsz)
{
uint8_t *ptr = (uint8_t *)buf;
pthread_mutex_lock(&slave_mtx);
for (int i = 0; i < sizeof(_tab_bits); i++) {
ptr[i] = _tab_bits[i];
}
pthread_mutex_unlock(&slave_mtx);
return 0;
}
static int set_map_buf(int index, int len, void *buf, int bufsz)
{
uint8_t *ptr = (uint8_t *)buf;
pthread_mutex_lock(&slave_mtx);
for (int i = 0; i < len; i++) {
_tab_bits[index + i] = ptr[index + i];
}
pthread_mutex_unlock(&slave_mtx);
return 0;
}
const agile_modbus_slave_util_map_t bit_maps[1] = {
{0x041A, 0x0423, get_map_buf, set_map_buf}};