V3S拍照上传又拍云bug排查过程
1.確保收到mqtt命令后去生效抓圖標志。
void CreateOpenDoorJpgName(void *recordData)
{
?? ?int i;
?? ?int ret;
?? ?unsigned char *p;
?? ?unsigned char high;
?? ?unsigned char low;
?? ?if(OpenDoorJpgFlag == 1)
?? ?{
?? ??? ?printf(".......OpenDoor_TakePicture is busy now.......\n");
?? ??? ?return;//還沒處理完畢,直接退出
?? ?}
?? ?if(CanUseUpYunCheck())
?? ?{
?? ??? ?SetUpYunDelayTime(0);//重新計時?? ?
?? ?}
?? ?else
?? ?{
?? ??? ?return;//間隔時間符合要求
?? ?}
?? ?
?? ?p = (unsigned char *)recordData;
?? ?for(i=0; i<10; i++)
?? ?{
?? ??? ?low ?? ?= (p[i] ?>> 0) & 0x0f;
?? ??? ?high ?? ?= (p[i] ?>> 4) & 0x0f;
?? ??? ?if(high <= 9)
?? ??? ?{
?? ??? ??? ?OpenDoorJpgName[i*2+0] = high+0x30;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?OpenDoorJpgName[i*2+0] = 'A'+high-10;
?? ??? ?}
?? ??? ?if(low <= 9)
?? ??? ?{
?? ??? ??? ?OpenDoorJpgName[i*2+1] = low+0x30;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?OpenDoorJpgName[i*2+1] = 'A'+low-10;
?? ??? ?}
?? ?}
?? ?OpenDoorJpgName[i*2+0] = '.';
?? ?OpenDoorJpgName[i*2+1] = 'j';
?? ?OpenDoorJpgName[i*2+2] = 'p';
?? ?OpenDoorJpgName[i*2+3] = 'g';
?? ?OpenDoorJpgName[i*2+4] = '\0';
?? ?OpenDoorJpgFlag = 1;//抓圖有時候太快了,要放到抓圖操作的前面?? ?
?? ?ret = OpenDoor_TakePicture();
?? ?if(ret == -1)
?? ?{
?? ?
?? ?}
?? ?else
?? ?{
?? ?}
?? ?printf(".......OpenDoor_TakePicture's ret:%d.......\n", ret);
?? ?printf("......OpenDoor_TakePicture:%s..............\n\n",OpenDoorJpgName);
}
?
?
2.生效抓圖標志一定要放在啟動攝像機拍照之前,否則有可能抓圖的回調函數在抓圖標志生效之前就發生了,回調函數中會去判斷抓圖標志,決定是否上傳,導致邏輯錯誤。
static void jpegCallback(void *data, int size, void* caller, int id)
{
?? ?RecordPreview* rp;
?? ?printf("........picture call back %d data %p size %d.......\n", id, data, size);
?? ?if(caller == NULL)?
?? ?{
?? ??? ?printf(".....caller not initialized.......\n");
?? ??? ?return;
?? ?}
?? ?rp = (RecordPreview*)caller;
??? ?UploadOpenDoorJpgDeal(data, size);?? ?
?? ?rp->takePicFinish(id);
?}
?
?
3.確保又拍云發送完畢后才失效抓圖標志,以便進行下次抓圖生效。
void UploadOpenDoorJpgDeal(void *data, int size)
{
?? ?char filename[128];
?? ?char full_path_file_name[128];?? ?
?? ?if(GetOpenDoorJpgFlag())
?? ?{
?? ??? ?printf(".............yes.................\n");
?? ?}
?? ?else
?? ?{
?? ??? ?printf(".............no.................\n");
?? ??? ?return;
?? ?}
?? ?if(Xishi_GetConnectSuccessMqttServerStates()!=1)
?? ?{
?? ??? ?goto NormalEnd;
?? ?}
?? ?if(Xishi_GetInfoFromMcuIsOK()!=1)
?? ?{
?? ??? ?printf("qrz upyun error: is not sn \n");
?? ??? ?goto NormalEnd;
?? ?}?? ?
?? ?printf("...........UploadOpenDoorJpgDeal end..........\n");
?? ?
?? ?sprintf(filename,"%s", GetOpenDoorJpgName());//文件名
?? ?sprintf(full_path_file_name,"/tmp/%s", GetOpenDoorJpgName());//文件全路徑名
?? ?WirteFile_Qrz(full_path_file_name, (char *)data, size, 0);
?? ?uploadFile(full_path_file_name, filename);
NormalEnd:
?? ?SetOpenDoorJpgFlag(0);//發送完畢后才清0標志位
?? ?printf("...........UploadOpenDoorJpgDeal: clear flag..........\n\n");
}
?
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的V3S拍照上传又拍云bug排查过程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: V3S文件系统基本构架
- 下一篇: 进程环境详解(四)---getenv、p