Skip to content

Commit e6f3b80

Browse files
committed
Test to get UVC serial number just after open
1 parent a98a856 commit e6f3b80

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

include/sensorcapture.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <map>
2929
#include <mutex>
3030

31-
3231
#ifdef SENSORS_MOD_AVAILABLE
3332

3433
#include "sensorcapture_def.hpp"

include/videocapture.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class SL_OC_EXPORT VideoCapture
386386
void grabThreadFunc(); //!< The frame grabbing thread function
387387

388388
// ----> Low level functions
389-
int ll_VendorControl(uint8_t *buf, int len, int readMode, bool safe = false);
389+
int ll_VendorControl(uint8_t *buf, int len, int readMode, bool safe = false, bool force=false);
390390
int ll_get_gpio_value(int gpio_number, uint8_t* value);
391391
int ll_set_gpio_value(int gpio_number, uint8_t value);
392392
int ll_set_gpio_direction(int gpio_number, int direction);
@@ -395,7 +395,7 @@ class SL_OC_EXPORT VideoCapture
395395
int ll_read_sensor_register(int side, int sscb_id, uint64_t address, uint8_t *value);
396396
int ll_write_sensor_register(int side, int sscb_id, uint64_t address, uint8_t value);
397397

398-
int ll_SPI_FlashProgramRead(uint8_t *pBuf, int Adr, int len);
398+
int ll_SPI_FlashProgramRead(uint8_t *pBuf, int Adr, int len, bool force=false);
399399

400400
int ll_isp_aecagc_enable(int side, bool enable);
401401
int ll_isp_is_aecagc(int side);

src/videocapture.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,13 @@ bool VideoCapture::openCamera( uint8_t devId )
399399
}
400400
// <---- Open
401401

402+
int sn = getSerialNumber();
403+
if(mParams.verbose)
404+
{
405+
std::string msg = std::string("Opened camera with SN: ") + std::to_string(sn);
406+
INFO_OUT(mParams.verbose,msg);
407+
}
408+
402409
// ----> Init
403410
struct v4l2_capability cap;
404411
memset(&cap, 0, sizeof (v4l2_capability));
@@ -540,8 +547,8 @@ bool VideoCapture::openCamera( uint8_t devId )
540547

541548
int VideoCapture::getSerialNumber()
542549
{
543-
if(!mInitialized)
544-
return -1;
550+
/*if(!mInitialized)
551+
return -1;*/
545552

546553
int ulValue = -1;
547554

@@ -553,7 +560,7 @@ int VideoCapture::getSerialNumber()
553560
int try_count = 0;
554561
while(res!=0)
555562
{
556-
res = ll_SPI_FlashProgramRead(&UNIQUE_BUF[0], UNIQUE_ID_START, 64);
563+
res = ll_SPI_FlashProgramRead(&UNIQUE_BUF[0], UNIQUE_ID_START, 64, true);
557564

558565
//check bytes read
559566
if (UNIQUE_BUF[0] != 'O') {
@@ -901,12 +908,12 @@ const Frame& VideoCapture::getLastFrame( uint64_t timeout_msec )
901908
return mLastFrame;
902909
}
903910

904-
int VideoCapture::ll_VendorControl(uint8_t *buf, int len, int readMode, bool safe)
911+
int VideoCapture::ll_VendorControl(uint8_t *buf, int len, int readMode, bool safe, bool force)
905912
{
906913
if (len > 384)
907914
return -2;
908915

909-
if (!mInitialized)
916+
if (!force && !mInitialized)
910917
return -3;
911918

912919
unsigned char tmp[2] = {0};
@@ -1240,7 +1247,7 @@ int VideoCapture::ll_write_sensor_register(int side, int sscb_id, uint64_t addre
12401247
return hr;
12411248
}
12421249

1243-
int VideoCapture::ll_SPI_FlashProgramRead(uint8_t *pBuf, int Adr, int len) {
1250+
int VideoCapture::ll_SPI_FlashProgramRead(uint8_t *pBuf, int Adr, int len, bool force) {
12441251

12451252
int hr = -1;
12461253
uint8_t xu_buf[384];
@@ -1262,7 +1269,7 @@ int VideoCapture::ll_SPI_FlashProgramRead(uint8_t *pBuf, int Adr, int len) {
12621269
xu_buf[11] = ((len) >> 8) & 0xff;
12631270
xu_buf[12] = ((len) >> 0) & 0xff;
12641271

1265-
hr = ll_VendorControl(xu_buf, len, 1, true);
1272+
hr = ll_VendorControl(xu_buf, len, 1, true, force);
12661273
memcpy(pBuf, &xu_buf[17], len);
12671274
return hr;
12681275
}

0 commit comments

Comments
 (0)