summaryrefslogtreecommitdiff
path: root/include/General.h
blob: 861ec62d25149292abd72e8196fb9e2a4874e863 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef GENERAL_HPP
#define GENERAL_HPP

#ifdef _MSC_VER
#pragma warning(disable : 4514 4512 4710 4355)
#endif

typedef signed char sint8;
typedef unsigned char uint8;
typedef signed short sint16;
typedef unsigned short uint16;
typedef signed int sint32;
typedef unsigned int uint32;
typedef signed long long sint64;
typedef unsigned long long uint64;
typedef signed int sint;   // 32 bit - even on 64 bit machines
typedef unsigned int uint; // 32 bit - even on 64 bit machines

#define memzero(ptr) memset(ptr, 0, sizeof(*(ptr)))
#define ArrayZero(ptr, elements) memset(ptr, 0, sizeof(*(ptr)) * (elements))

#include <mts/MTS_Logger.h>
#include <mts/MTS_System.h>
#include <mts/MTS_Text.h>

#include <dirent.h>
#include <fcntl.h> /* open */
#include <fstream>
#include <iostream>
#include <linux/spi/spidev.h>
#include <regex>
#include <stdio.h> /* printf fprintf */
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h> /* lseek, close */
#include <getopt.h> /* command line parser */

#include "rapidjson/document.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/istreamwrapper.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"

#define MAX_ACC_CARDS 4

#define VERBOSE false
#define MTS_IO_CONTROLS_STATUS_LED false
#define MTS_IO_CONTROLS_LS_LED false

#define FIRMWARE_VERSION "Version"
#define FIRMWARE_DATE "Date"
#define FIRMWARE_RELEASE "Release"

#define SYSFS_PLATFORM "/sys/devices/platform/mts-io/"
#define HW_VERSION_PATH "/sys/devices/platform/mts-io/hw-version"
#define LEDS_GPIO_DIR "/sys/devices/platform/leds-gpio/leds/"
#define FIRMWARE_FILE "/etc/issue"
#define CRESET "/creset"

#define LORA_1_5_MTCAP_SPI      "/dev/spidev0.0"
#define LORA_1_5_MTCDT_SPI_AP_1 "/dev/spidev0.2"
#define LORA_1_5_MTCDT_SPI_AP_2 "/dev/spidev1.2"

#define LORA_2_1_FPGA_VERSION                                                  \
    "mts-fpga-loader -g | grep version | awk '{printf $4}'"
#define LORA_2_1_EXT_FPGA_VERSION                                              \
    "mts-fpga-loader -b 1 -g | grep version | awk '{printf $4}'"

#define DEVICE_INFO_FILE "/var/run/config/device_info.json"
#define RESET_SHORT_CMD "reset_short_handler"
#define RESET_LONG_CMD "reset_long_handler"
#define KILL_SIGNAL "kill -l "

enum HardwareType {
    HARDWARE_MTCDT,
    HARDWARE_MTCDT3,
    HARDWARE_MTCAP,
    HARDWARE_INVALID
};

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

#endif