-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathteleinfo.h
55 lines (47 loc) · 1.76 KB
/
teleinfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-
* teleinfuse is a FUSE module to access to the "Téléinformation"
* "Téléinfo" data are transmitted by french electric meters (EDF/ERDF)
*
* Copyright (C) 2010 Romuald Conty
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TELEINFO_H_
#define _TELEINFO_H_
#include <sys/types.h>
typedef struct {
char label[9];
char value[13];
} teleinfo_data;
// Message Teleinfo
// LF 1 char (0x0a)
// [ ETIQUETTE ] 4 à 8 char
// SP 1 char (0x20)
// [ DONNEES ] 1 à 12 char
// SP 1 char (0x20)
// [ CHECKSUM ] 1 char
// CR 1 char (0x0d)
// (1 + 8 + 1 + 12 + 1 + 1 + 1) = 25
#define TI_MESSAGE_LENGTH_MAX 26
#define TI_MESSAGE_COUNT_MAX 32
#define TI_FRAME_LENGTH_MAX (TI_MESSAGE_LENGTH_MAX * TI_MESSAGE_COUNT_MAX)
// returns file descriptor if succeed otherwise 0
int teleinfo_open (const char * port);
// returns 0 if succeed otherwise negative
#define teleinfo_read_frame(X, Y, Z) teleinfo_read_frame_ext(X, Y, Z, NULL)
int teleinfo_read_frame_ext (const int fd, char *const buffer, const size_t buflen, int *error_counter);
// returns 0 if succeed otherwise negative
int teleinfo_decode (const char * frame, teleinfo_data dataset[], size_t * datasetlen);
void teleinfo_close (int fd);
#endif