101 lines
1.5 KiB
C
101 lines
1.5 KiB
C
#pragma once
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <rb2/regbus.h>
|
|
#include <hwo/bits.h>
|
|
#include <hwo/chksum.h>
|
|
|
|
#include <util/list.h>
|
|
|
|
/****
|
|
|
|
Telegram auf Leitung:
|
|
|
|
Byte Inhalt
|
|
|
|
0 Magic
|
|
1 request
|
|
2 achse
|
|
3 knoten
|
|
4 register low
|
|
5 register high
|
|
(4x) (value)
|
|
(2x) (chksum)
|
|
|
|
****/
|
|
|
|
|
|
#define SL_REQ_READ 0x01
|
|
#define SL_REQ_WRITE 0x02
|
|
#define SL_REQ_EVENT 0x04
|
|
#define SL_REQ_FAIL 0x08
|
|
#define SL_REQ_INT 0x10
|
|
#define SL_REQ_FLOAT 0x20
|
|
#define SL_REQ_ACK 0x40
|
|
|
|
#define SL_MAGIC 0x66
|
|
|
|
struct sl_header
|
|
{
|
|
uint8_t request;
|
|
uint8_t achse;
|
|
uint8_t knoten;
|
|
uint16_t register_no;
|
|
};
|
|
|
|
struct servicelink_telegram
|
|
{
|
|
struct sl_header header;
|
|
union bits32 value;
|
|
avrChksum chksum;
|
|
};
|
|
|
|
typedef struct {
|
|
union {
|
|
uint8_t request;
|
|
struct {
|
|
uint8_t has_value:1; // <value> enthält daten
|
|
uint8_t is_float:1; // <value> ist vom typ float
|
|
uint8_t failed:1; // signalisiert einen fehlschlag (z.B. timeout)
|
|
uint8_t timeout:1; // signalisiert ein timeout
|
|
uint8_t extra_payload:4;// <extra_bytes> zusätzliche bytes folgen auf dieses telegram
|
|
};
|
|
};
|
|
|
|
union {
|
|
uint8_t addr;
|
|
struct {
|
|
uint8_t node:4;
|
|
uint8_t ax:4;
|
|
};
|
|
};
|
|
|
|
uint16_t register_no;
|
|
|
|
union {
|
|
int32_t i32;
|
|
float f32;
|
|
} value;
|
|
|
|
} sl_v2_telegram_t;
|
|
|
|
|
|
typedef struct {
|
|
list_t list;
|
|
systick_t timeout;
|
|
|
|
sl_v2_telegram_t
|
|
sl_telegram;
|
|
rb2_request_t
|
|
rb2_request;
|
|
|
|
} sl_v2_telegram_list_t;
|
|
|
|
|
|
|
|
void servicelink(FILE *stream);
|
|
void servicelink2(void *_arg);
|
|
|
|
int sl2_dbg_free_telegrams(void);
|