Files
SpectralPlot/myis11/src/IRIS_IS3/IS3Comon.h

136 lines
3.5 KiB
C
Raw Normal View History

/**
* @brief is11相关底层函数
*
*/
#ifndef __IS3COMON_H__
#define __IS3COMON_H__
#ifndef IS3COMMON_H
#define IS3COMMON_H
#include <stdint.h>
#include <stddef.h>
#include <string>
#ifdef __cplusplus
extern "C" {
#endif
#define COMMAND_GET 0x03
#define COMMAND_SET 0x06
#define COMMAND_MULTSET 0x10
#define POLYNOMIAL 0xa001 //modbus crc
#include "comon.h"
const u_char GET_ADDRESS[]={0x01,0x03,0x00,0x01,0x00,0x01};
const u_char GET_BANDRATE[]={0x01,0x03,0x00,0x02,0x00,0x01};
const u_char GET_INTEGRAL_TIME[]={0x01,0x03,0x00,0x06,0x00,0x01};
const u_char GET_AVERAGE_NUMBER[]={0x01,0x03,0x00,0x07,0x00,0x01};
const u_char GET_WAVELENTH_AT_BAND[]={0x01, 0x03, 0x00,0x10, 0x00,0x02};
const u_char GET_VALUE_AT_BAND[]={0x01, 0x03, 0x00,0x30, 0x00,0x02};
const u_char GET_SETTING_OF_LAMP[]={0x01, 0x03, 0x00,0x04, 0x00,0x01};
const u_char GET_WAVELENTH_COEFF[]={0x01, 0x03, 0x00,0x20, 0x00,0x08};
const u_char GET_ALL_DN[]={0x01, 0x03, 0x01,0x00, 0x10,0x00};
const u_char GET_SERIAL_NUMBER[]={0x01, 0x03, 0x00,0x40, 0x00,0x00};
const u_char GET_PRODUCT_NAME[]={0x01, 0x03, 0x00,0x50, 0x00,0x00};
const u_char SET_ADDRESS[]={0x01,0x06, 0x00,0x01};
const u_char SET_BandRATE[]={0x01,0x06, 0x00,0x02};
const u_char SET_INTEGRAL_TIME[]={0x01,0x06, 0x00,0x06};
const u_char SET_AVERAGE_NUMBER[]={0x01,0x06, 0x00,0x07};
const u_char SET_WORK_MODE[]={0x01,0x06, 0x00,0x01};
const u_char SET_WAVELENTH_COEFF[]={0x01,0x10,0x00,0x20,0x00,0x08,0x16};
/**
* @brief
*
* @return true
* @return false
*/
bool isSensorInit();
/**
* @brief
*
* @param writefunc
* @param readfunc
*/
void InitFunction(SERIALWRITE writefunc,SERIALWRITE readfunc);
/**
* @brief BufferForRead
*
*/
u_char * GetDataBufferPTR();
/**
* @brief Get指令
*
* @param Command
* @param lenth sizeof来求算
* @return size_t BufferForRead;
*/
size_t SendGetSensorInfo(u_char * Command,size_t lenth);//此过程不适合获取数据
/**
* @brief
*
* @param shutter
* @return size_t
*/
size_t SendGetData(int shutter);
/**
* @brief
*
* @param Command
* @param CommandLenth
* @param Value
* @param ValueLenth
* @return size_t
*/
size_t SendSettingCommand(u_char * Command,size_t CommandLenth,u_char *Value,size_t ValueLenth=2);
//big
/**
* @brief
*
* @param isbig
* @return size_t
*/
size_t GetInfoBackFromSensor(bool isbig=false);
/**
* @brief
*
* @return size_t ;
*/
size_t GetSetBackFromSensor();
/**
* @brief
*
* @param data
* @param lenth
* @return size_t
*/
size_t SerialWrite(u_char* data,size_t lenth);
size_t SerailRead(u_char* data,size_t lenth=0);
/**
* @brief crc16
*
* @param data
* @param len
* @param polynomial crc16多项式 A001H
* @return uint16_t crc16的值
*/
uint16_t crc16(const uint8_t *data, size_t len, uint16_t polynomial=POLYNOMIAL) ;
bool panduanHeader();
void CoverLittleAndBig(char *data,int lenth);
#ifdef __cplusplus
}
#endif
#endif
#endif // __IS11COMON_H__