blob: c5be2ff26479344409749f5122deebea69b9d076 (
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
|
#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_System.h>
#include <mts/MTS_Text.h>
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <stdio.h> /* printf fprintf */
#include <fcntl.h> /* open */
#include <linux/spi/spidev.h>
#include <sys/ioctl.h>
#include <unistd.h> /* lseek, close */
#include <dirent.h>
#include <regex>
#include <sys/stat.h>
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/istreamwrapper.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 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 LORA_1_5_AP1_FPGA_VERSION "mts-fpga-loader -p 1 -c | grep version | awk '{printf $4}'"
#define LORA_1_5_AP2_FPGA_VERSION "mts-fpga-loader -p 2 -c | grep version | awk '{printf $4}'"
#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 MTAC_SX1301 0x0
#define MTAC_FPGA 0x1
#define MTAC_FPGA_ADDRESS 0x1
#define READ_ACCESS 0x00
#define SPI_SPEED 8000000
#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 "
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif
|