* apps/include/industry/abnt_codi.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __APPS_INCLUDE_INDUSTRY_ABNTCODI_H
#define __APPS_INCLUDE_INDUSTRY_ABNTCODI_H
* Included Files
****************************************************************************/
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
* Pre-processor Definitions
****************************************************************************/
#define boolstr(s) ((s) ? "true" : "false")
#define END_ACT_DEM_MASK 0x0f
#define BILL_INDICADOR (1 << 4)
* replenishment of demand */
#define REACT_INTERVAL (1 << 5)
* at end of reactive interval
* consumption */
#define REACT_CAP_PULSE (1 << 6)
* capacitive pulses are computed to
* calculate UFER and DMCR */
#define REACT_IND_PULSE (1 << 7)
* inductive pulses are computed to
* calculate UFER and DMCR */
#define SEGMENT_MASK 0x0f
#define SEGMENT_PEEK 1
#define SEGMENT_OUT_PEEK 2
#define SEGMENT_RESERVED 8
#define CHARGES_MASK (3 << 4)
#define CHARGES_BLUE (0 << 4)
#define CHARGES_GREEN (1 << 4)
#define CHARGES_IRRIGATORS (2 << 4)
#define CHARGES_OTHER (3 << 4)
#define CHARGES_REACT_EN (1 << 7)
#define NOT_USED_BIT (1 << 7)
* Public Types
****************************************************************************/
struct abnt_codi_proto_s
{
uint16_t end_act_dem;
bool bill_indicator;
bool react_interval;
bool react_cap_pulse;
* calculate consumption */
bool react_ind_pulse;
* calculate consumption */
uint8_t segment_type;
uint8_t charge_type;
bool react_charge_en;
uint16_t pulses_act_dem;
* of current demand */
uint16_t pulses_react_dem;
* of current demand */
uint8_t checksum;
* complement (bits inversion) the result */
};
#ifdef __cplusplus
extern "C"
{
#endif
* Public Function Prototypes
****************************************************************************/
uint8_t abnt_codi_checksum(FAR const uint8_t *data);
bool abnt_codi_parse(FAR const uint8_t *data, FAR struct abnt_codi_proto_s *proto);
#ifdef __cplusplus
}
#endif
#endif