Prechádzať zdrojové kódy

迭代海康相机模块:1,使其同时支持G口相机;2,根据设备厂商名严格匹配是否为海康相机

niujiuru 6 dní pred
rodič
commit
1f357ab61a

+ 4 - 4
hk_takephoto/bridge.go

@@ -26,22 +26,22 @@ type SImgMark struct {
 	ImgExposureTime float32 // 曝光时间值
 }
 
-// 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: -1
+// 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: <0
 func getSysUsbfsMemCurrentSize() int {
 	ret := int(C.GetSysUsbfsMemCurrentSize())
 	return ret
 }
 
-// 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: -1
+// 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: <0
 func setSysUsbfsMemSize(val int) int {
 	setNewV := C.int(val)
 	ret := int(C.SetSysUsbfsMemSize(setNewV))
 	return ret
 }
 
-// 获取当前连接在USB口上的相机数, 失败返回: <0值, 成功返回: >=0
+// 获取当前连接在USB口上的相机数, 成功返回: >=0, 失败返回: <0值
 func GetUsbCameraCount() int {
-	ret := int(C.GetUsbCameraCount())
+	ret := int(C.GetHKCameraCount())
 	return ret
 }
 

+ 19 - 8
hk_takephoto/hkcam_reset.c

@@ -5,10 +5,12 @@
 
 const char *MODULE_NAME = "HKCamReset";
 
+static const char *manufacturer = "Hikrobot"; // 制造厂商
+
 int main(int argc,char *argv[])
 {
   HANDLE hCam = NULL; MV_CC_DEVICE_INFO_LIST devList = { 0 };
-  MV_CC_DEVICE_INFO *pDevInfo; int ret;
+  MV_CC_DEVICE_INFO *pDevInfo; int ret, index = 0; char name[MAX_LINE_CHARS] = { 0 };
 
   // 1, 查找相机
   ret = MV_CC_Initialize();
@@ -18,20 +20,22 @@ int main(int argc,char *argv[])
     goto end_p;
   }
 
-  ret = MV_CC_EnumDevices(MV_USB_DEVICE, &devList); // 目前只枚举USB连接的相机
+  ret = MV_CC_EnumDevices(MV_GIGE_DEVICE | MV_USB_DEVICE, &devList); // 目前只枚举G口和U口相机
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口枚举相机失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 枚举相机,执行错误, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
-  if(devList.nDeviceNum != 1)
+  if(devList.nDeviceNum < 1)
   {
     ret = -1;
-    sw_log_error("[%s] USB口相机数量错误, deviceNum=%u!!", MODULE_NAME, devList.nDeviceNum);
+    sw_log_error("[%s] 没有相机,数量=%u!!", MODULE_NAME, devList.nDeviceNum);
     goto end_p;
   }
 
-  pDevInfo = devList.pDeviceInfo[0];
+findp:
+  if(index < devList.nDeviceNum) pDevInfo = devList.pDeviceInfo[index++];
+  else goto end_p;
   if(!pDevInfo)
   {
     ret = -2;
@@ -39,12 +43,17 @@ int main(int argc,char *argv[])
     goto end_p;
   }
 
+  if(0) ;
+  else if(pDevInfo && pDevInfo->nTLayerType == MV_USB_DEVICE /*U口相机*/) strcpy(name, (const char *)pDevInfo->SpecialInfo.stUsb3VInfo.chManufacturerName);
+  else if(pDevInfo && pDevInfo->nTLayerType == MV_GIGE_DEVICE/*G口相机*/) strcpy(name, (const char *)pDevInfo->SpecialInfo.stGigEInfo.chManufacturerName);
+  if(xstrcasecmp(name, manufacturer) != 0) goto findp;
+
   // 2, 打开相机
   ret = MV_CC_CreateHandleWithoutLog(&hCam, pDevInfo);
   if(MV_OK == ret) ret = MV_CC_OpenDevice(hCam, MV_ACCESS_Exclusive, 0);
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口相机打开失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 打开相机时发生错误, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
 
@@ -52,10 +61,12 @@ int main(int argc,char *argv[])
   ret = MV_CC_SetCommandValue(hCam, "DeviceReset");
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口相机重置失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 重置相机时发生错误, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
 
+  if(index < devList.nDeviceNum) goto findp;
+
   // 4, 关闭相机
 end_p:
   if(hCam)

+ 80 - 29
hk_takephoto/takephoto.c

@@ -3,6 +3,12 @@
 // 模块名称
 static const char MODULE_NAME[] = "TakePhoto";
 
+// 相机类型
+static unsigned int device_type =  MV_GIGE_DEVICE | MV_USB_DEVICE;
+
+// 制造厂商
+static const char *manufacturer = "Hikrobot";
+
 // 保存照片
 static int SavePhoto(HANDLE hCam, MV_FRAME_OUT *pFrame, EImgType imgType, const char *imgFile);
 
@@ -86,7 +92,7 @@ getp:
 int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *pImgMark)
 {
   int fd; char runDir[MAX_PATH_CHARS] = { 0 }, lockFile[MAX_PATH_CHARS+32] = { 0 };
-  int ret; SImgMark imgMark = { 0 }; HANDLE hCam = NULL; PthotoProcCtx ctx = { 0 };
+  int ret; SImgMark imgMark = { 0 }; HANDLE hCam = NULL; PthotoProcCtx ctx = { 0 }; int index = 0;
   MV_CC_DEVICE_INFO_LIST devList = { 0 }; MV_CC_DEVICE_INFO *pDevInfo = NULL; MVCC_ENUMVALUE exposureMode =  { 0 };
 
   // 1, 占用锁定, 避免同时间拍照
@@ -94,7 +100,7 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
   if(runDir[strlen(runDir)-1] == '/') sprintf(lockFile, "%s%s", runDir, "status/");
   else sprintf(lockFile, "%s/%s", runDir, "status/");
   if(!sw_dir_exists(lockFile)) sw_dir_create(lockFile);
-  strcat(lockFile, "takephoto.lock");
+  strcat(lockFile, "hk_takephoto.lock");
 
   fd = open(lockFile, O_CREAT | O_RDWR | __O_CLOEXEC, 0666);
   if(-1 == fd) { return -1; }
@@ -109,36 +115,66 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
     goto end_p;
   }
 
-  ret = MV_CC_EnumDevices(MV_USB_DEVICE, &devList);
+  ret = MV_CC_EnumDevices(device_type, &devList);
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口枚举相机失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 枚举相机,执行错误, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
-  if(devList.nDeviceNum != 1)
+  if(devList.nDeviceNum < 1)
   {
     ret = -3;
-    sw_log_error("[%s] USB口相机数量错误, deviceNum=%u!!", MODULE_NAME, devList.nDeviceNum);
+    sw_log_error("[%s] 没有相机,数量=%u!!", MODULE_NAME, devList.nDeviceNum);
     goto end_p;
   }
 
-  pDevInfo = devList.pDeviceInfo[0];
+findp:
+  pDevInfo = devList.pDeviceInfo[index++];
   if(!pDevInfo)
   {
     ret = -4;
     sw_log_error("[%s] unexpected internal error, unable to obtain detailed information about the industrial camera!!", MODULE_NAME);
     goto end_p;
   }
-  strcpy(imgMark.camModelName, (const char *)pDevInfo->SpecialInfo.stUsb3VInfo.chModelName);
-  strcpy(imgMark.camSerialNum, (const char *)pDevInfo->SpecialInfo.stUsb3VInfo.chSerialNumber);
+
+  char name[MAX_LINE_CHARS] = { 0 }; if(0) ;
+  else if(pDevInfo->nTLayerType == MV_USB_DEVICE /*U口相机*/)
+  {
+    strcpy(name, (const char *)pDevInfo->SpecialInfo.stUsb3VInfo.chManufacturerName);
+    strcpy(imgMark.camModelName, (const char *)pDevInfo->SpecialInfo.stUsb3VInfo.chModelName);
+    strcpy(imgMark.camSerialNum, (const char *)pDevInfo->SpecialInfo.stUsb3VInfo.chSerialNumber);
+  }
+  else if(pDevInfo->nTLayerType == MV_GIGE_DEVICE/*G口相机*/)
+  {
+    strcpy(name, (const char *)pDevInfo->SpecialInfo.stGigEInfo.chManufacturerName);
+    strcpy(imgMark.camModelName, (const char *)pDevInfo->SpecialInfo.stGigEInfo.chModelName);
+    strcpy(imgMark.camSerialNum, (const char *)pDevInfo->SpecialInfo.stGigEInfo.chSerialNumber);
+  }
+
+  if(xstrcasecmp(name, manufacturer) != 0)
+  {
+    if(index < devList.nDeviceNum) goto findp;
+    ret = -5;
+    sw_log_error("[%s] 没有找到 \"%s\" 的相机!!", MODULE_NAME, manufacturer);
+    goto end_p;
+  }
 
   // 3, 打开相机, 设置其触发模式
   ret = MV_CC_CreateHandleWithoutLog(&hCam, pDevInfo);
   if(MV_OK == ret) ret = MV_CC_OpenDevice(hCam, MV_ACCESS_Exclusive, 0);
-  if(MV_OK == ret) ret = MV_USB_SetTransferWays(hCam, 1); // 设置传输通道个数(RTU硬件资源有限, 需要降低通道数)
+  if(MV_OK == ret && pDevInfo->nTLayerType == MV_USB_DEVICE /*U口相机*/)
+  {
+    ret = MV_USB_SetTransferWays(hCam, 1); // 设置传输通道个数(RTU硬件资源有限, 需要降低通道数)
+  }
+  if(MV_OK == ret && pDevInfo->nTLayerType == MV_GIGE_DEVICE/*G口相机*/)
+  { // 探测网络最佳包大小(只对GigE相机有效)
+    int size = MV_CC_GetOptimalPacketSize(hCam);
+    if(size > 0) ret = MV_CC_SetIntValueEx(hCam, "GevSCPSPacketSize", size);
+    else ret = -6;
+  }
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口相机打开失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 打开相机时发生错误, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
 
@@ -146,7 +182,7 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
   if(MV_OK == ret) ret = MV_CC_SetEnumValue(hCam, "TriggerSource", MV_TRIGGER_SOURCE_SOFTWARE); // 设置软件触发
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口相机设置失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 设置相机时发生错误, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
 
@@ -154,7 +190,7 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
   ret =  MV_CC_GetExposureAutoMode(hCam, &exposureMode);
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] 获取-曝光模式失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 获取曝光模式时出错, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
   if(exposureMode.nCurValue != MV_EXPOSURE_AUTO_MODE_OFF) { ctx.isExposureAuto = true; clock_gettime(CLOCK_MONOTONIC, &ctx.expTime0); }
@@ -163,7 +199,7 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
   ret = MV_CC_StartGrabbing(hCam);
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口相机取流失败, errCode=0x%x!!", MODULE_NAME, ret);
+    sw_log_error("[%s] 相机取流时发生错误, errCode=0x%x!!", MODULE_NAME, ret);
     goto end_p;
   }
 
@@ -173,7 +209,7 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
   ctx.hESig = sw_signal_create();
   if(!ctx.hESig)
   {
-    ret = -5;
+    ret = -7;
     sw_log_error("[%s] SIG信号量创建失败!!", MODULE_NAME);
     goto end_p;
   }
@@ -182,7 +218,7 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
   HANDLE hThrd = sw_thrd_create("PhotoProc", THREAD_DEFAULT_PRIORITY, THREAD_DEFAULT_STACK_SIZE, PhotoProc, (unsigned long)&ctx, 0);
   if(!hThrd)
   {
-    ret = -6;
+    ret = -8;
     sw_signal_destroy(ctx.hESig);
     sw_log_error("[%s] 拍照线程-创建失败!!", MODULE_NAME);
     goto end_p;
@@ -193,7 +229,7 @@ int TakePhoto(EImgType imgType, const char *saveImgPath, int timeout, SImgMark *
   if(0 == ret) ret = ctx.rCode;
   else
   {
-    ret = -7;
+    ret = -9;
     sw_log_error("[%s] 拍照过程-等待超时!!", MODULE_NAME);
   }
 
@@ -232,7 +268,7 @@ static int SavePhoto(HANDLE hCam, MV_FRAME_OUT *pFrame, EImgType imgType, const
   MV_SAVE_IMAGE_PARAM_EX3 saveParams = { 0 }; MVCC_INTVALUE_EX iv;
   char *filename1 = (char *)imgFile, *filename2 = NULL; int ret; char ext[5];
 
-  if(!hCam || !pFrame || !filename1 || strlen(filename1) <= 0) return -8;
+  if(!hCam || !pFrame || !filename1 || strlen(filename1) <= 0) return -15;
 
   switch(imgType)
   {
@@ -244,7 +280,7 @@ static int SavePhoto(HANDLE hCam, MV_FRAME_OUT *pFrame, EImgType imgType, const
     imgType = MV_Image_Jpeg;
     strcpy(ext, ".jpg");
     break;
-   default: return -9;
+   default: return -16;
   }
 
   ret = MV_CC_GetIntValueEx(hCam, "PayloadSize", &iv);
@@ -263,7 +299,7 @@ static int SavePhoto(HANDLE hCam, MV_FRAME_OUT *pFrame, EImgType imgType, const
   if(imgType == IMG_TYPE_JPG) saveParams.nBufferSize  = (unsigned int)(iv.nCurValue * 1);
   else saveParams.nBufferSize  = (unsigned int)(iv.nCurValue * 4);
   saveParams.pImageBuffer = (unsigned char *)sw_heap_malloc(saveParams.nBufferSize);
-  if(!saveParams.pImageBuffer) return -10;
+  if(!saveParams.pImageBuffer) return -17;
 
   ret = MV_CC_SaveImageEx3(hCam, &saveParams);
   if(MV_OK != ret) goto end_p;
@@ -272,7 +308,7 @@ static int SavePhoto(HANDLE hCam, MV_FRAME_OUT *pFrame, EImgType imgType, const
   {
     filename2 = (char *)sw_heap_malloc(strlen(filename1) +sizeof(ext));
     if(filename2) sprintf(filename2, "%s%s", filename1, ext);
-    else { ret = -11; goto end_p; }
+    else { ret = -18; goto end_p; }
     ret = sw_file_update(filename2, "wb", (const char *)saveParams.pImageBuffer, saveParams.nImageLen);
     sw_heap_free(filename2);
   }
@@ -282,14 +318,14 @@ static int SavePhoto(HANDLE hCam, MV_FRAME_OUT *pFrame, EImgType imgType, const
   }
 
   if(ret == saveParams.nImageLen) ret = MV_OK;
-  else ret = -12;
+  else ret = -19;
 
 end_p:
   sw_heap_free(saveParams.pImageBuffer);
   return ret;
 }
 
-// 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: -1
+// 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: <0
 int GetSysUsbfsMemCurrentSize()
 {
   const char *usbfsFile = "/sys/module/usbcore/parameters/usbfs_memory_mb";
@@ -303,7 +339,7 @@ int GetSysUsbfsMemCurrentSize()
   return val;
 }
 
-// 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: -1
+// 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: <0
 int SetSysUsbfsMemSize(int val)
 {
   const char *usbfsFile = "/sys/module/usbcore/parameters/usbfs_memory_mb";
@@ -312,8 +348,8 @@ int SetSysUsbfsMemSize(int val)
   else return -1;
 }
 
-// 获取当前连接在USB口上的相机数, 失败返回: <0值, 成功返回: >=0
-int GetUsbCameraCount()
+// 获取当前已连接的海康相机的数量, 成功返回: >=0, 失败返回: <0值
+int GetHKCameraCount()
 {
   MV_CC_DEVICE_INFO_LIST devList = { 0 };
   int ret;
@@ -325,15 +361,30 @@ int GetUsbCameraCount()
     goto end_p;
   }
 
-  ret = MV_CC_EnumDevices(MV_USB_DEVICE, &devList);
+  ret = MV_CC_EnumDevices(device_type, &devList);
   if(MV_OK != ret)
   {
-    sw_log_error("[%s] USB口枚举相机失败, errCode=0x%x!!", MODULE_NAME, ret);
-    goto end_p;
+    sw_log_error("[%s] 枚举相机,执行错误, errCode=0x%x!!", MODULE_NAME, ret);
+    ret = -1; goto end_p;
   }
 
   ret = devList.nDeviceNum;
 
+  if(ret > 0)
+  {
+    int index = 0, cnt = 0; MV_CC_DEVICE_INFO *pDevInfo = NULL; char name[MAX_LINE_CHARS] = { 0 };
+findp:
+    pDevInfo = devList.pDeviceInfo[index++];
+    
+    if(0) ;
+    else if(pDevInfo && pDevInfo->nTLayerType == MV_USB_DEVICE /*U口相机*/) strcpy(name, (const char *)pDevInfo->SpecialInfo.stUsb3VInfo.chManufacturerName);
+    else if(pDevInfo && pDevInfo->nTLayerType == MV_GIGE_DEVICE/*G口相机*/) strcpy(name, (const char *)pDevInfo->SpecialInfo.stGigEInfo.chManufacturerName);
+
+    if(xstrcasecmp(name, manufacturer) == 0) cnt++;
+    if(index < devList.nDeviceNum) goto findp;
+    else ret = cnt;
+  }
+
 end_p:
   MV_CC_Finalize();
 

+ 35 - 0
hk_takephoto/takephoto.go

@@ -1,18 +1,43 @@
 package hk_takephoto
 
 import (
+	"syscall"
 	"time"
 
+	"github.com/vishvananda/netlink"
 	"hnyfkj.com.cn/rtu/linux/baseapp"
 )
 
 // 相机模块的名称
 const MODULE_NAME = "TakePhoto"
 
+func SetupIface(iface, cidr string) error {
+	link, err := netlink.LinkByName(iface)
+	if err != nil {
+		return err
+	}
+
+	if err = netlink.LinkSetUp(link); err != nil {
+		return err
+	}
+
+	addr, err := netlink.ParseAddr(cidr)
+	if err != nil {
+		return err
+	}
+
+	if err = netlink.AddrAdd(link, addr); err != nil && err != syscall.EEXIST {
+		return err
+	}
+
+	return nil
+}
+
 // 相机模块初始化, 设置必要的运行环境参数, 只有成功才能进行后续的拍照操作
 func ModuleInit() bool {
 	myUsbfsMemSize := 200 // 单位: 兆字节
 	bSetOK := false
+
 	for range 5 {
 		if baseapp.IsExit1() {
 			return false
@@ -26,9 +51,19 @@ func ModuleInit() bool {
 			time.Sleep(1 * time.Second)
 		}
 	}
+
 	if !bSetOK {
 		baseapp.Logger.Errorf("[%s] 无法将系统\"usbfs\"的内存大小设置为: %dMB, 相机模块初始化失败!!", MODULE_NAME, myUsbfsMemSize)
 		return false
 	}
+
+	if err := SetupIface("eth1", "192.168.100.123/24"); err != nil {
+		baseapp.Logger.Errorf(
+			"[%s] 设置网口 %s 的 IP 地址失败: %v",
+			MODULE_NAME, "eth1", err,
+		)
+		return false
+	}
+
 	return true
 }

+ 6 - 5
hk_takephoto/takephoto.h

@@ -1,6 +1,7 @@
 // Author: NiuJiuRu
 // Email: niujiuru@qq.com
-// Date: 2025-07-21
+// Date: 2025-07-21 【新增支持U口相机】
+// Date: 2026-01-06 【新增支持G口相机】
 #ifndef __TAKEPHOTO_H__
 #define __TAKEPHOTO_H__
 
@@ -27,14 +28,14 @@ extern "C"
 {
 #endif
 
-// 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: -1
+// 获取系统当前USBFS内存大小(MB), 成功返回: >=0, 失败返回: <0
 int GetSysUsbfsMemCurrentSize();
 
-// 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: -1
+// 设置系统新的USBFS内存大小(MB), 成功返回: 0值, 失败返回: <0
 int SetSysUsbfsMemSize(int val);
 
-// 获取当前连接在USB口上的相机数, 失败返回: <0值, 成功返回: >=0
-int GetUsbCameraCount();
+// 获取当前已连接的海康相机的数量, 成功返回: >=0, 失败返回: <0值
+int GetHKCameraCount();
 
 // 单次执行相机拍照, 并保存到文件, 成功返回: 0值, 失败返回:非0值
 // "imgType"     - 获取图像类型

+ 6 - 18
hk_takephoto/takephoto_test.c

@@ -2,46 +2,34 @@
 
 #include "takephoto.h"
 
-// 检查核心内存分配情况
-static char coreBuf[300*1024*1024] = { 0 }; 
-static void coreMemCheck(const char *filename, int line, const char *ptr, int size, void *lpParameter)
-{
-  sw_log_info("filename:%s line:%d addr:%#p size:%dbytes", filename, line, ptr, size);
-}
-
 // 主函数入口, 测试拍照
 int main(int argc,char *argv[])
 {
-  int ret = 0; unsigned long stime, wtime, etime;
+  int ret = 0; unsigned long stime, wtime, etime; SImgMark imgMark = { 0 };
   char filename[MAX_PATH_CHARS] = { 0 }; int timeout = 5*60;
 
-  if(!sw_heap_init(coreBuf, sizeof(coreBuf), 4)) goto end_p;
-
   if(GetSysUsbfsMemCurrentSize() < 200) ret = SetSysUsbfsMemSize(200);
   if(0 != ret)
   {
     sw_log_error("Failed to set system usbfs's memory size, ret=%d!!", ret);
-    goto end_p;
+    return ret;
   }
 
+  sw_log_info("Get HK camera count: %d", GetHKCameraCount());
+
   sw_log_info("Photo taking...");
   for(int i = 0; i < 9; i++)
   {
     sprintf(filename, "test%d.jpg", i+1);
 
     xgettickcount(&stime);
-    ret = TakePhoto(IMG_TYPE_JPG, filename, timeout, NULL);
+    ret = TakePhoto(IMG_TYPE_JPG, filename, timeout, &imgMark);
     xgettickcount(&etime);
 
     wtime = etime - stime;
-    if(0 == ret) sw_log_info("+++ Take a photo: \"%s\", time: %lums +++", filename, wtime);
+    if(0 == ret) sw_log_info("+++ Take a photo: \"%s\", time: %lums, exposure time: %fus, camera sn: %s, camera model: %s +++", filename, wtime, imgMark.imgExposureTime, imgMark.camSerialNum, imgMark.camModelName);
     else sw_log_error("+++ Failed to take a photo, ret=%d, time: %lums!! +++", ret, wtime);
   }
 
-end_p:
-  sw_log_info("Memory leak check:");
-  sw_heap_check(coreMemCheck, NULL); // 内存泄露检查
-  sw_heap_exit();
-
 	return 0;
 }

+ 0 - 8
scripts/set_env

@@ -6,11 +6,3 @@ export APPNAME="rtu_linux_modules.out"
 
 #导出运行时库
 export LD_LIBRARY_PATH=${APPLIBS_PATH}
-
-#设置系统主频(需放到/etc/rc.local中执行)
-#echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
-#echo 528000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
-
-#设置一秒落盘(需放到/etc/rc.local中执行)
-#echo 100 > /proc/sys/vm/dirty_writeback_centisecs
-#echo 100 > /proc/sys/vm/dirty_expire_centisecs