2017-09-27 13:25:39 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hwo/chksum.h>
|
|
|
|
#include <sys/threads.h>
|
|
|
|
|
|
|
|
/***********************************
|
|
|
|
rb2/regbus.h
|
|
|
|
|
|
|
|
RegisteredBus2
|
|
|
|
|
|
|
|
Paketorientierte Kommunikation via Serielle Verbindungen mit Adressierung
|
|
|
|
|
|
|
|
Paketformat ähnelt ServiceLink:
|
|
|
|
|
|
|
|
Byte Inhalt
|
|
|
|
0 Magic 0x77
|
|
|
|
1 empfänger
|
|
|
|
2 sender
|
|
|
|
3 flags
|
|
|
|
|
|
|
|
!flags.ident:
|
|
|
|
4..5 register
|
|
|
|
6..9 value
|
|
|
|
flags.ident:
|
|
|
|
4..5 endpunktmaske
|
|
|
|
6 achse
|
|
|
|
7..9 reserve
|
|
|
|
|
|
|
|
Alle:
|
|
|
|
10..11 CHKSUM (SUM+XOR)
|
|
|
|
|
|
|
|
|
|
|
|
***********************************/
|
|
|
|
|
|
|
|
struct _rb2_addr;
|
|
|
|
struct _rb2_telegram;
|
|
|
|
union _rb2_flags;
|
|
|
|
struct _rb2_request;
|
|
|
|
struct _rb2_listed_telegram;
|
|
|
|
|
|
|
|
typedef struct _rb2_addr RB2_ADDR;
|
2017-11-08 16:08:32 +01:00
|
|
|
typedef struct _rb2_addr rb2_addr_t;
|
|
|
|
|
2017-09-27 13:25:39 +02:00
|
|
|
typedef struct _rb2_telegram RB2_TELEGRAM;
|
2017-11-08 16:08:32 +01:00
|
|
|
typedef struct _rb2_telegram rb2_telegram_t;
|
|
|
|
|
2017-09-27 13:25:39 +02:00
|
|
|
typedef union _rb2_flags RB2_FLAGS;
|
|
|
|
typedef struct _rb2_request RB2_REQUEST;
|
|
|
|
|
|
|
|
typedef struct _rb2_telegram_buffer
|
|
|
|
rb2_telegram_buffer_t;
|
|
|
|
|
|
|
|
|
|
|
|
#define RB2_ADDR(ptr) ((RB2_ADDR*)(ptr))
|
|
|
|
#define RB2_TELEGRAM(ptr) ((RB2_TELEGRAM*)(ptr))
|
|
|
|
#define RB2_FLAGS(ptr) ((RB2_FLAGS*)(ptr))
|
|
|
|
#define RB2_REQUEST(ptr) ((RB2_REQUEST*)(ptr))
|
|
|
|
#define rb2_telegram_buffer_t(ptr) ((rb2_telegram_buffer_t*)(ptr))
|
|
|
|
|
|
|
|
struct _rb2_addr
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint8_t ax:4;
|
|
|
|
uint8_t node:4;
|
|
|
|
};
|
|
|
|
uint8_t addr;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
union _rb2_flags
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint8_t ident:1; // 1 = Ident Paket, 0 = Request/Response
|
|
|
|
uint8_t response:1; // 1 = Antwort auf Request, 0 = Request
|
|
|
|
uint8_t read:1; // 1 = Wert Lesen, 0 = Wert Schreiben
|
|
|
|
uint8_t fail:1; // 1 = Anfrage fehlgeschlagen
|
|
|
|
|
|
|
|
uint8_t type:4; // 0 = Wert als Int32, 1 = Wert als float,...
|
|
|
|
};
|
|
|
|
uint8_t byte;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _rb2_telegram
|
|
|
|
{
|
|
|
|
uint8_t magic;
|
|
|
|
RB2_ADDR receiver;
|
|
|
|
RB2_ADDR sender;
|
|
|
|
RB2_FLAGS flags;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct // flags.ident = 0
|
|
|
|
{
|
|
|
|
uint16_t regno;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
int32_t i32;
|
|
|
|
float f32;
|
|
|
|
uint32_t ui32;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
struct // flags.ident = 1
|
|
|
|
{
|
|
|
|
uint16_t endpoints;
|
|
|
|
uint8_t ax;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
CHKSUM chksum;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct _rb2_telegram_buffer {
|
|
|
|
list_t list;
|
|
|
|
|
|
|
|
rb2_link_t *link;
|
|
|
|
|
|
|
|
union {
|
|
|
|
rb2_telegram_t telegram;
|
|
|
|
unsigned char bytes[ sizeof( rb2_telegram_t ) ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _rb2_request
|
|
|
|
{
|
|
|
|
list_t list;
|
|
|
|
|
|
|
|
uint8_t autofree:1;
|
|
|
|
|
|
|
|
THREAD *waiter;
|
|
|
|
RB2_TELEGRAM telegram;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _rb2_request rb2_request_t;
|