test
This commit is contained in:
@ -49,7 +49,7 @@ uint16_t crc16(const uint8_t *data, size_t len, uint16_t polynomial)
|
||||
{
|
||||
uint16_t i, j, tmp, CRC16;
|
||||
|
||||
CRC16 = 0xFFFF; // CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼֵ
|
||||
CRC16 = 0xFFFF; // CRC<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼֵ
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
CRC16 ^= data[i];
|
||||
@ -59,7 +59,7 @@ uint16_t crc16(const uint8_t *data, size_t len, uint16_t polynomial)
|
||||
CRC16 >>= 1;
|
||||
if (tmp == 1)
|
||||
{
|
||||
CRC16 ^= polynomial; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
CRC16 ^= polynomial; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ size_t SendSettingCommand(u_char Command, size_t CommandLenth, u_char *Value, si
|
||||
|
||||
int lenthforwrite = IRIS_Protocol_Pack(Command, (uint16_t)ValueLenth, Value, (uint8_t *)BufferFortempWrite);
|
||||
SerialWrite(BufferFortempWrite, lenthforwrite);
|
||||
// for 5 <20><>
|
||||
// for 5 <20><>
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
size_t retunnumber = GetInfoBackFromSensorinTime(Command,1000);
|
||||
@ -84,7 +84,7 @@ size_t SendSettingCommand(u_char Command, size_t CommandLenth, u_char *Value, si
|
||||
|
||||
}
|
||||
|
||||
// <20><>I<EFBFBD>γ<EFBFBD><CEB3><EFBFBD> <20><><EFBFBD>ݻظ<DDBB><D8B8>쳣 <20><><EFBFBD><EFBFBD>ȷʵ <20><>Ӣ<EFBFBD>Ĵ<EFBFBD>ӡ
|
||||
// <20><>I<EFBFBD>γ<EFBFBD><CEB3><EFBFBD> <20><><EFBFBD>ݻظ<DDBB><D8B8>쳣 <20><><EFBFBD><EFBFBD>ȷʵ <20><>Ӣ<EFBFBD>Ĵ<EFBFBD>ӡ
|
||||
printf("warning try %d times: date not enough,try again!!\n",i);
|
||||
|
||||
|
||||
@ -100,19 +100,21 @@ size_t SendGetData(int shutter)
|
||||
{
|
||||
uint8_t dataforsend=NONE_DATA;
|
||||
int lenthforwrite=IRIS_Protocol_Pack(GET_DATA_FROM_SENSOR, (uint16_t)01, &dataforsend, (uint8_t *)BufferFortempWrite );
|
||||
|
||||
SerialWrite(BufferFortempWrite, lenthforwrite);
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
size_t retunnumber = GetInfoBackFromSensorinTime(GET_DATA_FROM_SENSOR,2*shutter+2000);
|
||||
size_t retunnumber = GetInfoBackFromSensorinTime(GET_DATA_FROM_SENSOR,3*shutter);
|
||||
//size_t retunnumber = GetInfoBackFromSensorinTime(GET_DATA_FROM_SENSOR,2*shutter+2000);
|
||||
if (retunnumber<OVERTIME) {
|
||||
return retunnumber;
|
||||
}
|
||||
if (i%5==0) {
|
||||
if (i%2==0) {
|
||||
printf("send command again\n");
|
||||
SerialWrite(BufferFortempWrite, lenthforwrite);
|
||||
|
||||
}
|
||||
// <20><>I<EFBFBD>γ<EFBFBD><CEB3><EFBFBD> <20><><EFBFBD>ݻظ<DDBB><D8B8>쳣 <20><><EFBFBD><EFBFBD>ȷʵ <20><>Ӣ<EFBFBD>Ĵ<EFBFBD>ӡ
|
||||
// <20><>I<EFBFBD>γ<EFBFBD><CEB3><EFBFBD> <20><><EFBFBD>ݻظ<DDBB><D8B8>쳣 <20><><EFBFBD><EFBFBD>ȷʵ <20><>Ӣ<EFBFBD>Ĵ<EFBFBD>ӡ
|
||||
printf("warning try %d times: date not enough,try again!!\n",i);
|
||||
}
|
||||
|
||||
@ -144,7 +146,7 @@ size_t GetSetBackFromSensor()
|
||||
|
||||
|
||||
|
||||
size_t GetInfoBackFromSensor(uint8_t Command) // big <20><>ָ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>ֽڱ<D6BD>ʾ<EFBFBD><CABE><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> <20><>ʱֻ<CAB1><D6BB><EFBFBD>ֲɼ<D6B2><C9BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
size_t GetInfoBackFromSensor(uint8_t Command) // big <20><>ָ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>ֽڱ<D6BD>ʾ<EFBFBD><CABE><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> <20><>ʱֻ<CAB1><D6BB><EFBFBD>ֲɼ<D6B2><C9BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
{
|
||||
delay(1);
|
||||
TotalIndexNow = 0;
|
||||
@ -161,7 +163,7 @@ size_t GetInfoBackFromSensor(uint8_t Command) // big
|
||||
size_t retrunlenth=SerailRead(BufferForRead + TotalIndexNow, 5-TotalIndexNow);
|
||||
TotalIndexNow += retrunlenth;
|
||||
// if (retrunlenth!=0) {
|
||||
// //<2F><><EFBFBD><EFBFBD>bufferforread
|
||||
// //<2F><><EFBFBD>bufferforread
|
||||
// for (int i = 0; i < TotalIndexNow; i++) {
|
||||
// printf("%02x ", BufferForRead[i]);
|
||||
// }
|
||||
@ -186,7 +188,7 @@ size_t GetInfoBackFromSensor(uint8_t Command) // big
|
||||
//delay(10);
|
||||
//delay(10);
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>bufferforread
|
||||
// <20><><EFBFBD>bufferforread
|
||||
printf("Data from sensor: ");
|
||||
int maxoutput= TotalIndexNow>50 ? 50 : TotalIndexNow;
|
||||
for (int i = 0; i <maxoutput; i++) {
|
||||
@ -201,10 +203,10 @@ size_t GetInfoBackFromSensor(uint8_t Command) // big
|
||||
|
||||
#include <chrono>
|
||||
|
||||
size_t GetInfoBackFromSensorinTime(uint8_t Command,uint32_t waittime) // big <20><>ָ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>ֽڱ<D6BD>ʾ<EFBFBD><CABE><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> <20><>ʱֻ<CAB1><D6BB><EFBFBD>ֲɼ<D6B2><C9BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
size_t GetInfoBackFromSensorinTime(uint8_t Command,uint32_t waittime) // big <20><>ָ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>ֽڱ<D6BD>ʾ<EFBFBD><CABE><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> <20><>ʱֻ<CAB1><D6BB><EFBFBD>ֲɼ<D6B2><C9BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
{
|
||||
delay(1);
|
||||
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
// delay(1);
|
||||
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
size_t begintime= get_system_uptime_ms();
|
||||
|
||||
TotalIndexNow = 0;
|
||||
@ -221,7 +223,7 @@ size_t GetInfoBackFromSensorinTime(uint8_t Command,uint32_t waittime) // big
|
||||
size_t retrunlenth=SerailRead(BufferForRead + TotalIndexNow, 5-TotalIndexNow);
|
||||
TotalIndexNow += retrunlenth;
|
||||
// if (retrunlenth!=0) {
|
||||
// //<2F><><EFBFBD><EFBFBD>bufferforread
|
||||
// //<2F><><EFBFBD>bufferforread
|
||||
// for (int i = 0; i < TotalIndexNow; i++) {
|
||||
// printf("%02x ", BufferForRead[i]);
|
||||
// }
|
||||
@ -252,7 +254,7 @@ size_t GetInfoBackFromSensorinTime(uint8_t Command,uint32_t waittime) // big
|
||||
//delay(10);
|
||||
//delay(10);
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>bufferforread
|
||||
// <20><><EFBFBD>bufferforread
|
||||
printf("Data from sensor: ");
|
||||
int maxoutput= TotalIndexNow>50 ? 50 : TotalIndexNow;
|
||||
for (int i = 0; i <maxoutput; i++) {
|
||||
@ -283,7 +285,9 @@ size_t SerailRead(u_char *data, size_t lenth)
|
||||
{
|
||||
if (MySerialRead != nullptr)
|
||||
{
|
||||
return MySerialRead(data, lenth);
|
||||
size_t aa= MySerialRead(data, lenth);
|
||||
|
||||
return aa;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user