完善数据调用接口,修改调试中发现的Bug,增加log日志文件保存

serial
huyizhong 11 months ago
parent a936a62440
commit 3cc25a5a51

@ -27,9 +27,9 @@ add_library( # Sets the name of the library.
SpiLib.cpp SpiLib.cpp
native-lib.cpp native-lib.cpp
GPIOControl.cpp GPIOControl.cpp
WeatherComm.cpp #WeatherComm.cpp
#serialComm.cpp serialComm.cpp
#SensorsProtocol.cpp SensorsProtocol.cpp
) )
# Searches for a specified prebuilt library and stores the path as a # Searches for a specified prebuilt library and stores the path as a

File diff suppressed because it is too large Load Diff

@ -36,7 +36,7 @@ typedef unsigned char BYTE;
#define IOT_PARAM_READ 0xAF #define IOT_PARAM_READ 0xAF
#define MAX_SERIAL_DEV_NUM 25 /* 最大接串口传感器数量*/ #define MAX_SERIAL_DEV_NUM 25 /* 最大接串口传感器数量*/
#define MAX_SERIAL_PORT_NUM 3 #define MAX_SERIAL_PORT_NUM 5
#define MAX_DEV_VALUE_NUM 12 /* 一台装置最大的采样值数量*/ #define MAX_DEV_VALUE_NUM 12 /* 一台装置最大的采样值数量*/
#define WEATHER_PROTOCOL 1 /* 温湿度协议序号*/ #define WEATHER_PROTOCOL 1 /* 温湿度协议序号*/
@ -130,7 +130,7 @@ typedef unsigned char BYTE;
#define SPEED_DOME_CAMERA 0 /* 球机摄像机*/ #define SPEED_DOME_CAMERA 0 /* 球机摄像机*/
#define SERIAL_CAMERA 2 /* 串口摄像机a*/ #define SERIAL_CAMERA 2 /* 串口摄像机a*/
#define COLLECT_DATA 0 /* 调试使用*/ #define COLLECT_DATA 1 /* 调试使用*/
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args) /* 红色*/ #define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args) /* 红色*/
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "Sensors_Protocol", fmt, ##args) /* 草绿色*/ #define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "Sensors_Protocol", fmt, ##args) /* 草绿色*/
@ -372,7 +372,7 @@ void Gm_OpenSerialPort(int devidx);
// 关闭串口通讯 // 关闭串口通讯
void Gm_CloseSerialPort(); void Gm_CloseSerialPort();
int SaveLogTofile(char *szbuf);
// 功能说明:串口发送数据 返回实际发送的字节数 // 功能说明:串口发送数据 返回实际发送的字节数
int GM_SerialComSend(const unsigned char * cSendBuf, unsigned long nSendLen, int commid); int GM_SerialComSend(const unsigned char * cSendBuf, unsigned long nSendLen, int commid);
void Gm_InitSerialComm(); void Gm_InitSerialComm();

@ -575,7 +575,7 @@ int serial_port_comm()
#if 1 #if 1
memset(portparm.pathname, 0, sizeof(portparm.pathname)); memset(portparm.pathname, 0, sizeof(portparm.pathname));
//sprintf(portparm.pathname, "/dev/ttyS1"); //sprintf(portparm.pathname, "/dev/ttyS1");
sprintf(portparm.pathname, "/dev/ttysWK3"); sprintf(portparm.pathname, "/dev/ttysWK0");
portparm.parity = 'N'; portparm.parity = 'N';
portparm.databit = 8; portparm.databit = 8;
portparm.baudrate = B9600; portparm.baudrate = B9600;

@ -18,9 +18,9 @@
#include <termios.h> #include <termios.h>
#include <time.h> #include <time.h>
#include "GPIOControl.h" #include "GPIOControl.h"
//#include "serialComm.h" #include "serialComm.h"
//#include "SensorsProtocol.h" #include "SensorsProtocol.h"
#include "WeatherComm.h" //#include "WeatherComm.h"
#if 0 #if 0
#define BYTE u_char; #define BYTE u_char;
@ -662,9 +662,9 @@ Java_com_xinyingpower_testcomm_MainActivity_testSpi(
//setRS485Enable(true); //setRS485Enable(true);
//set12VEnable(true); //set12VEnable(true);
serial_port_comm(); //serial_port_comm();
//GM_StartSerialComm(); //GM_StartSerialComm();
//Gm_InitSerialComm(); Gm_InitSerialComm();
//GM_StartSerialCameraPhoto(1, 0); //GM_StartSerialCameraPhoto(1, 0);
//lxy modify modify //lxy modify modify
//LOGE("_test_ setRS485Enable false"); //LOGE("_test_ setRS485Enable false");

@ -12,7 +12,7 @@
#define IOT_PARAM_WRITE 0xAE #define IOT_PARAM_WRITE 0xAE
#define IOT_PARAM_READ 0xAF #define IOT_PARAM_READ 0xAF
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args) //#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args)
int set_port_attr (int fd, unsigned int baudrate, int databit, const int stopbit, char parity, int vtime, int vmin ); int set_port_attr (int fd, unsigned int baudrate, int databit, const int stopbit, char parity, int vtime, int vmin );

@ -31,6 +31,16 @@ typedef struct
char str[MAX_STRING_LEN]; char str[MAX_STRING_LEN];
}IOT_PARAM; }IOT_PARAM;
typedef struct{
float airtemp; /* 空气温度*/
float RH; /* 相对湿度*/
float atmos; /* 大气压*/
float windspeed; /* 风速*/
float winddirection; /* 风向*/
float rainfall; /* 雨量*/
float sunshine; /* 日照*/
}Weather;
void GpioControl::setInt(int cmd, int value) void GpioControl::setInt(int cmd, int value)
{ {
int fd = open("/dev/mtkgpioctrl", O_RDONLY); int fd = open("/dev/mtkgpioctrl", O_RDONLY);

@ -36,6 +36,17 @@
#define CMD_SET_CAM_3V3_EN_STATE 132 #define CMD_SET_CAM_3V3_EN_STATE 132
#define CMD_SET_12V_EN_STATE 133 #define CMD_SET_12V_EN_STATE 133
#define CMD_SET_SYSTEM_RESET 202 #define CMD_SET_SYSTEM_RESET 202
#define CMD_SET_WTH_POWER 490
#define CMD_SET_PULL_POWER 491
#define CMD_SET_ANGLE_POWER 492
#define CMD_SET_OTHER_POWER 493
#define CMD_SET_PIC1_POWER 494
#define CMD_SET_485_en0 301
#define CMD_SET_485_en1 302
#define CMD_SET_485_en2 303
#define CMD_SET_485_en3 304
#define CMD_SET_485_en4 305
class GpioControl class GpioControl
{ {

File diff suppressed because it is too large Load Diff

@ -36,7 +36,7 @@ typedef unsigned char BYTE;
#define IOT_PARAM_READ 0xAF #define IOT_PARAM_READ 0xAF
#define MAX_SERIAL_DEV_NUM 25 /* 最大接串口传感器数量*/ #define MAX_SERIAL_DEV_NUM 25 /* 最大接串口传感器数量*/
#define MAX_SERIAL_PORT_NUM 3 #define MAX_SERIAL_PORT_NUM 5
#define MAX_DEV_VALUE_NUM 12 /* 一台装置最大的采样值数量*/ #define MAX_DEV_VALUE_NUM 12 /* 一台装置最大的采样值数量*/
#define WEATHER_PROTOCOL 1 /* 温湿度协议序号*/ #define WEATHER_PROTOCOL 1 /* 温湿度协议序号*/
@ -130,7 +130,7 @@ typedef unsigned char BYTE;
#define SPEED_DOME_CAMERA 0 /* 球机摄像机*/ #define SPEED_DOME_CAMERA 0 /* 球机摄像机*/
#define SERIAL_CAMERA 2 /* 串口摄像机a*/ #define SERIAL_CAMERA 2 /* 串口摄像机a*/
#define COLLECT_DATA 0 /* 调试使用*/ #define COLLECT_DATA 1 /* 调试使用*/
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args) /* 红色*/ #define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args) /* 红色*/
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "Sensors_Protocol", fmt, ##args) /* 草绿色*/ #define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "Sensors_Protocol", fmt, ##args) /* 草绿色*/
@ -372,7 +372,7 @@ void Gm_OpenSerialPort(int devidx);
// 关闭串口通讯 // 关闭串口通讯
void Gm_CloseSerialPort(); void Gm_CloseSerialPort();
int SaveLogTofile(char *szbuf);
// 功能说明:串口发送数据 返回实际发送的字节数 // 功能说明:串口发送数据 返回实际发送的字节数
int GM_SerialComSend(const unsigned char * cSendBuf, unsigned long nSendLen, int commid); int GM_SerialComSend(const unsigned char * cSendBuf, unsigned long nSendLen, int commid);
void Gm_InitSerialComm(); void Gm_InitSerialComm();

@ -12,7 +12,7 @@
#define IOT_PARAM_WRITE 0xAE #define IOT_PARAM_WRITE 0xAE
#define IOT_PARAM_READ 0xAF #define IOT_PARAM_READ 0xAF
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args) //#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, "serial_port_comm", fmt, ##args)
int set_port_attr (int fd, unsigned int baudrate, int databit, const int stopbit, char parity, int vtime, int vmin ); int set_port_attr (int fd, unsigned int baudrate, int databit, const int stopbit, char parity, int vtime, int vmin );

Loading…
Cancel
Save