-
Notifications
You must be signed in to change notification settings - Fork 4
/
modbus_slave.h
44 lines (37 loc) · 886 Bytes
/
modbus_slave.h
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
33
34
35
36
37
38
39
40
41
42
43
44
/*
* modbus_slave.h
*
* Created on: 04 îêò. 2014 ã.
* Author: salnikov
*/
#ifndef MODBUS_SLAVE_H_
#define MODBUS_SLAVE_H_
#include "DSP2802x_Device.h"
enum {
MODBUS_FUNCTION_ERROR = 1,
MODBUS_ADDRESS_ERROR,
MODBUS_DATA_VALUE_ERROR
};
/**
* Îáðàáîò÷èê Modbus çàïðîñà
* @return len - äëèíà îòâåòà
* 0 - ïîñûëêà íå íàøà èëè CRC íå ñîâïàë
*/
Uint16 modbus_func(Uint16 *Buffer, Uint16 len, Uint16 ModbusAddress);
/**
* Îáðàáîòêà çàïðîñà íà ÷òåíèå
* @return len - äëèíà îòâåòà
*/
Uint16 modbus_0x03_func(Uint16 *Buffer, Uint16 len);
/**
* Îáðàáîòêà çàïðîñà íà çàïèñü
* @return len - äëèíà îòâåòà
*/
Uint16 modbus_0x06_func(Uint16 *Buffer, Uint16 len);
/**
* Îáðàáîòêà îøèáêè â çàïðîñå
* ôîðìèðóåò îòâåò ñ îò÷åòîì îá îøèáêå
* @return 3 - äëèíà ïîñûëêè îòâåòà îá îøèáêå
*/
Uint16 modbus_error(Uint16 *Buffer, Uint16 err);
#endif /* MODBUS_SLAVE_H_ */