Skip to content

Commit

Permalink
feat: implement freenect_get_device_serial()
Browse files Browse the repository at this point in the history
Signed-off-by: Benn Snyder <[email protected]>
  • Loading branch information
piedar committed Sep 20, 2022
1 parent d7a1806 commit 0c1b739
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ include (FindOS)
include (SetupDirectories)

set (PROJECT_VER_MAJOR 0)
set (PROJECT_VER_MINOR 6)
set (PROJECT_VER_PATCH 4)
set (PROJECT_VER_MINOR 7)
set (PROJECT_VER_PATCH 0)
set (PROJECT_VER
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
set (PROJECT_APIVER
Expand Down
9 changes: 9 additions & 0 deletions include/libfreenect.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ FREENECTAPI int freenect_open_device(freenect_context *ctx, freenect_device **de
*/
FREENECTAPI int freenect_open_device_by_camera_serial(freenect_context *ctx, freenect_device **dev, const char* camera_serial);

/**
* Gets a serial number for the device.
* The caller must free() the serial after use.
*
* @param dev
* @return an appropriate serial number, or NULL if none was found.
*/
FREENECTAPI char* freenect_get_device_serial(freenect_device* dev);

/**
* Closes a device that is currently open
*
Expand Down
13 changes: 13 additions & 0 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ FREENECTAPI int freenect_open_device_by_camera_serial(freenect_context *ctx, fre
return -1;
}

FREENECTAPI char* freenect_get_device_serial(freenect_device* dev)
{
if (dev == NULL) return NULL;

int res;

struct freenect_device_attributes attr;
res = fnusb_get_device_attributes(dev, &attr);
if (res != 0) return NULL;

return strdup(attr.camera_serial);
}

FREENECTAPI int freenect_close_device(freenect_device *dev)
{
freenect_context *ctx = dev->parent;
Expand Down

0 comments on commit 0c1b739

Please sign in to comment.