33#ifndef PROTOCORE_SIMATIC_H
34#define PROTOCORE_SIMATIC_H
38#if PROTOCORE_ENABLE_SIMATIC
47#define SIMATIC_STX 0x02
48#define SIMATIC_DLE 0x10
49#define SIMATIC_ETX 0x03
50#define SIMATIC_NAK 0x15
53#define SIMATIC_MAX_BLOCK_RETRY 6
54#define SIMATIC_MAX_CONN_RETRY 6
58 SIMATIC3964_STATE_IDLE,
59 SIMATIC3964_STATE_TX_AWAIT_CONN,
60 SIMATIC3964_STATE_TX_AWAIT_END,
61 SIMATIC3964_STATE_RX_COLLECT
65typedef void (*Simatic3964TxFn)(
void *user, uint8_t byte);
68typedef void (*Simatic3964RxFn)(
void *user,
const uint8_t *data,
size_t len);
76 Simatic3964State state;
77 embed_bool high_priority;
88 uint8_t block_retries;
97 RK512_CMD_SEND = 0x00,
98 RK512_CMD_FETCH = 0x01,
99 RK512_CMD_REACTION = 0x02
104 RK512_AREA_DB = 0x01,
105 RK512_AREA_DX = 0x02,
106 RK512_AREA_MB = 0x03,
107 RK512_AREA_EB = 0x04,
108 RK512_AREA_AB = 0x05,
109 RK512_AREA_PB = 0x06,
110 RK512_AREA_ZB = 0x07,
129} SimaticBcc3964rArgs;
139} SimaticBuildBlock3964rArgs;
150} SimaticParseBlock3964rArgs;
156 embed_bool high_priority;
161} SimaticInit3964rArgs;
170} SimaticSend3964rArgs;
178} SimaticRxByte3964rArgs;
185} SimaticTick3964rArgs;
190 const Simatic3964Ctx *ctx;
191} SimaticIdle3964rArgs;
201 const uint16_t *words;
203} SimaticBuildSendRk512Args;
214} SimaticBuildFetchRk512Args;
222} SimaticBuildReactionRk512Args;
230} SimaticParseHeaderRk512Args;
238 const uint8_t **data;
240} SimaticParseReactionRk512Args;
289 SimaticBcc3964rArgs bcc_3964r_args;
290 SimaticBuildBlock3964rArgs build_block_3964r_args;
291 SimaticParseBlock3964rArgs parse_block_3964r_args;
292 SimaticInit3964rArgs init_3964r_args;
293 SimaticSend3964rArgs send_3964r_args;
294 SimaticRxByte3964rArgs rx_byte_3964r_args;
295 SimaticTick3964rArgs tick_3964r_args;
296 SimaticIdle3964rArgs idle_3964r_args;
297 SimaticBuildSendRk512Args build_send_rk512_args;
298 SimaticBuildFetchRk512Args build_fetch_rk512_args;
299 SimaticBuildReactionRk512Args build_reaction_rk512_args;
300 SimaticParseHeaderRk512Args parse_header_rk512_args;
301 SimaticParseReactionRk512Args parse_reaction_rk512_args;
308extern SimaticVars SimaticV;
313 void (*
const bcc_3964r)(
const uint8_t *work);
314 void (*
const build_block_3964r)(
const uint8_t *work);
315 void (*
const parse_block_3964r)(uint8_t *work);
316 void (*
const init_3964r)(
const uint8_t *work);
317 void (*
const send_3964r)(uint8_t *work);
318 void (*
const rx_byte_3964r)(uint8_t *work);
319 void (*
const tick_3964r)(
const uint8_t *work);
320 void (*
const idle_3964r)(
const uint8_t *work);
321 void (*
const build_send_rk512)(
const uint8_t *work);
322 void (*
const build_fetch_rk512)(
const uint8_t *work);
323 void (*
const build_reaction_rk512)(
const uint8_t *work);
324 void (*
const parse_header_rk512)(
const uint8_t *work);
325 void (*
const parse_reaction_rk512)(
const uint8_t *work);
330void protocore_simatic_bcc_3964r(
const uint8_t *work);
331void protocore_simatic_build_block_3964r(
const uint8_t *work);
332void protocore_simatic_parse_block_3964r(uint8_t *work);
333void protocore_simatic_init_3964r(
const uint8_t *work);
334void protocore_simatic_send_3964r(uint8_t *work);
335void protocore_simatic_rx_byte_3964r(uint8_t *work);
336void protocore_simatic_tick_3964r(
const uint8_t *work);
337void protocore_simatic_idle_3964r(
const uint8_t *work);
338void protocore_simatic_build_send_rk512(
const uint8_t *work);
339void protocore_simatic_build_fetch_rk512(
const uint8_t *work);
340void protocore_simatic_build_reaction_rk512(
const uint8_t *work);
341void protocore_simatic_parse_header_rk512(
const uint8_t *work);
342void protocore_simatic_parse_reaction_rk512(
const uint8_t *work);
348static const SimaticNs Simatic __attribute__((unused)) = {
349 .bcc_3964r = protocore_simatic_bcc_3964r,
350 .build_block_3964r = protocore_simatic_build_block_3964r,
351 .parse_block_3964r = protocore_simatic_parse_block_3964r,
352 .init_3964r = protocore_simatic_init_3964r,
353 .send_3964r = protocore_simatic_send_3964r,
354 .rx_byte_3964r = protocore_simatic_rx_byte_3964r,
355 .tick_3964r = protocore_simatic_tick_3964r,
356 .idle_3964r = protocore_simatic_idle_3964r,
357 .build_send_rk512 = protocore_simatic_build_send_rk512,
358 .build_fetch_rk512 = protocore_simatic_build_fetch_rk512,
359 .build_reaction_rk512 = protocore_simatic_build_reaction_rk512,
360 .parse_header_rk512 = protocore_simatic_parse_header_rk512,
361 .parse_reaction_rk512 = protocore_simatic_parse_reaction_rk512,
373uint8_t *protocore_simatic_span(
void);
EMBED_ENUM_BYTE(ProtoConn, PROTO_NONE=0, PROTO_HTTP=1, PROTO_TELNET=2, PROTO_SSH=3, PROTO_MODBUS=4, PROTO_OPCUA=5, PROTO_SSH_RFWD=6, PROTO_RELAY=7, PROTO_BRIDGE=8, PROTO_NTRIP_CASTER=9, PROTO_MESH=10, PROTO_UDP=11,)
Application protocol spoken on a listener port or connection slot.
#define PROTOCORE_SIMATIC_BLOCK_MAX
3964R block-body buffer size (built/received bytes: DLE-stuffed payload + DLE ETX + BCC).