rllib  1
rleibnetip.h
Go to the documentation of this file.
1 /***************************************************************************
2  rleibnetip.h - description
3  -------------------
4  begin : Wed Apr 04 2007
5  copyright : (C) 2007 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #ifndef _RL_EIB_NET_IP_H_
17 #define _RL_EIB_NET_IP_H_
18 
19 #include "rldefine.h"
20 #include "rludpsocket.h"
21 #include "rlthread.h"
22 #include <stdio.h>
23 
24 #define EIB_ON 0x81
25 #define EIB_OFF 0x80
26 
28 
32 class rlEIBnetIP : public rlUdpSocket
33 {
34 public:
35 
36  enum EIBnetIP
37  {
38  PORT = 3671,
39  SUCCESS = 0,
40  EIBERROR = 0x0ffffffff,
41  TIMEOUT = -1,
43  };
44 
45  typedef struct
46  {
47  unsigned char headersize;
48  unsigned char version;
49  unsigned short servicetype;
50  unsigned short totalsize;
51  unsigned char data[128-6];
52  }PDU;
53 
54  typedef struct
55  {
56  unsigned char mc; // 0x29
57  unsigned char addi1; // 0x0
58  unsigned char ctrl1; // 0xbc
59  unsigned char ctrl2; // 0xe0
60  unsigned short saddr; // 0x1
61  unsigned short daddr; // 0x100
62  unsigned char apci_length; // 0x1
63  unsigned char apci; // 0x0
64  unsigned char val[14]; // 0x80
65  }EIB_TEL;
66 
67  // this may be used by the application programmer
68  rlEIBnetIP(int num_signals = 1000, int debug = 0, rlDataAcquisitionProvider *provider = NULL);
69  virtual ~rlEIBnetIP();
70 
71  int setServer(rlIpAdr *server);
72  int setClient(rlIpAdr *client);
73  int startReading();
74  int stopReading();
75  int value(const char *name);
76  unsigned int valueUnsigned(const char *name);
77  float valueFloat2(const char *name);
78  float valueFloat4(const char *name);
79  int setValue(const char *name, int val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1);
80  int setValueUnsigned(const char *name, unsigned int val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1);
81  int setValueFloat(const char *name, float val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1);
82  int setText(const char *name, const char *text);
83  int getText(const char *name, char *text, int maxlen);
84  int setSourceAdr(const char *adr);
85  int dump(FILE *fout);
86  int setValuesFromCSV(const char *filename);
87  int debug;
88  int watch_eib;
89 
90  // the rest is for internal use only
91  int connect();
92  int disconnect();
93  int isConnected();
94 #ifndef SWIG_SESSION
95  int getDescription(PDU *pdu);
96 #endif
97  int recv(void *buf, int maxlen);
98  int storeBuffer(unsigned char *buf, int len);
100 
101  void *mem;
102  int memsize;
103  int running;
110 
111 private:
112  int printTelegram(EIB_TEL *tel);
113  int storeInProvider(EIB_TEL *tel);
118  short saddr;
119 };
120 
121 #endif
unsigned short saddr
Definition: rleibnetip.h:60
void * mem
Definition: rleibnetip.h:101
int channelid
Definition: rleibnetip.h:104
int setValue(const char *name, int val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1)
Definition: rleibnetip.cpp:612
int maxvalues
Definition: rleibnetip.h:116
int printTelegram(EIB_TEL *tel)
Definition: rleibnetip.cpp:287
int sendDisconnectRequest()
Definition: rleibnetip.cpp:553
int setSourceAdr(const char *adr)
Definition: rleibnetip.cpp:595
int storeInProvider(EIB_TEL *tel)
Definition: rleibnetip.cpp:322
unsigned short servicetype
Definition: rleibnetip.h:49
int watch_eib
Definition: rleibnetip.h:88
int value(const char *name)
Definition: rleibnetip.cpp:619
unsigned int valueUnsigned(const char *name)
Definition: rleibnetip.cpp:685
int isConnected()
Definition: rleibnetip.cpp:572
int startReading()
Definition: rleibnetip.cpp:577
int recv(void *buf, int maxlen)
unsigned char mc
Definition: rleibnetip.h:56
float valueFloat2(const char *name)
Definition: rleibnetip.cpp:662
unsigned char apci
Definition: rleibnetip.h:63
int getDescription(PDU *pdu)
unsigned char headersize
Definition: rleibnetip.h:47
int getText(const char *name, char *text, int maxlen)
Definition: rleibnetip.cpp:745
int send_sequencecounter
Definition: rleibnetip.h:107
int disconnect()
Definition: rleibnetip.cpp:534
int setServer(rlIpAdr *server)
rlIpAdr client
Definition: rleibnetip.h:114
short saddr
Definition: rleibnetip.h:118
unsigned char apci_length
Definition: rleibnetip.h:62
float valueFloat4(const char *name)
Definition: rleibnetip.cpp:676
rlThread thread
Definition: rleibnetip.h:105
int is_connected
Definition: rleibnetip.h:117
unsigned char addi1
Definition: rleibnetip.h:57
unsigned short daddr
Definition: rleibnetip.h:61
rlEIBnetIP(int num_signals=1000, int debug=0, rlDataAcquisitionProvider *provider=NULL)
Definition: rleibnetip.cpp:164
int setValueFloat(const char *name, float val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1)
Definition: rleibnetip.cpp:628
int stopReading()
Definition: rleibnetip.cpp:586
unsigned char ctrl1
Definition: rleibnetip.h:58
virtual ~rlEIBnetIP()
Definition: rleibnetip.cpp:190
int storeBuffer(unsigned char *buf, int len)
Definition: rleibnetip.cpp:201
int setClient(rlIpAdr *client)
int setValuesFromCSV(const char *filename)
Definition: rleibnetip.cpp:413
int setText(const char *name, const char *text)
Definition: rleibnetip.cpp:790
int setValueUnsigned(const char *name, unsigned int val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1)
Definition: rleibnetip.cpp:894
int tunnel_ack
Definition: rleibnetip.h:108
rlIpAdr from
Definition: rleibnetip.h:115
unsigned char version
Definition: rleibnetip.h:48
int connect()
Definition: rleibnetip.cpp:474
int dump(FILE *fout)
Definition: rleibnetip.cpp:364
unsigned char ctrl2
Definition: rleibnetip.h:59
rlDataAcquisitionProvider * provider
Definition: rleibnetip.h:109
rlIpAdr * server
Definition: rleibnetip.h:106
unsigned short totalsize
Definition: rleibnetip.h:50