35#ifndef PROTOCORE_MELSEC_H
36#define PROTOCORE_MELSEC_H
40#if PROTOCORE_ENABLE_MELSEC
48#define MELSEC_3E_REQ_SUBHEADER0 0x50
49#define MELSEC_3E_REQ_SUBHEADER1 0x00
50#define MELSEC_3E_RES_SUBHEADER0 0xD0
51#define MELSEC_3E_RES_SUBHEADER1 0x00
53#define MELSEC_NETWORK_DEFAULT 0x00
54#define MELSEC_PROTOCORE_DEFAULT 0xFF
55#define MELSEC_DEST_IO_DEFAULT 0x03FF
56#define MELSEC_DEST_MULTIDROP_DEFAULT 0x00
58#define MELSEC_CMD_BATCH_READ 0x0401
59#define MELSEC_CMD_BATCH_WRITE 0x1401
60#define MELSEC_SUBCMD_WORD 0x0000
61#define MELSEC_SUBCMD_BIT 0x0001
64#define MELSEC_DEV_D 0xA8
65#define MELSEC_DEV_R 0xAF
66#define MELSEC_DEV_M 0x90
67#define MELSEC_DEV_S 0x98
68#define MELSEC_DEV_X 0x9C
69#define MELSEC_DEV_Y 0x9D
70#define MELSEC_DEV_TN 0xC2
71#define MELSEC_DEV_TS 0xC1
72#define MELSEC_DEV_CN 0xC5
73#define MELSEC_DEV_CS 0xC4
75#define MELSEC_ENDCODE_OK 0x0000
78#define MELSEC_3E_READ_REQ_LEN 21
79#define MELSEC_3E_READ_REQ_DATA_LEN 12
80#define MELSEC_3E_RES_MIN_LEN 11
81#define MELSEC_3E_RES_LEN_OFFSET 7
82#define MELSEC_3E_RES_DATALEN_BASE 9
83#define MELSEC_3E_RES_DATA_OFFSET 11
84#define MELSEC_ENDCODE_LEN 2
100 uint32_t head_device;
102 uint16_t monitoring_timer;
103} MelsecBuildReadArgs;
111 uint32_t head_device;
113 uint16_t monitoring_timer;
116} MelsecBuildWriteArgs;
124} MelsecParseResponseArgs;
157 MelsecBuildReadArgs build_read_args;
158 MelsecBuildWriteArgs build_write_args;
159 MelsecParseResponseArgs parse_response_args;
165extern MelsecVars MelsecV;
170 void (*
const build_read)(uint8_t *work);
171 void (*
const build_write)(uint8_t *work);
172 void (*
const parse_response)(uint8_t *work);
177void protocore_melsec_build_read(uint8_t *work);
178void protocore_melsec_build_write(uint8_t *work);
179void protocore_melsec_parse_response(uint8_t *work);
185static const MelsecNs Melsec __attribute__((unused)) = {
186 .build_read = protocore_melsec_build_read,
187 .build_write = protocore_melsec_build_write,
188 .parse_response = protocore_melsec_parse_response,
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS