Skip to content

Commit 0c1b739

Browse files
committed
feat: implement freenect_get_device_serial()
Signed-off-by: Benn Snyder <[email protected]>
1 parent d7a1806 commit 0c1b739

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ include (FindOS)
4646
include (SetupDirectories)
4747

4848
set (PROJECT_VER_MAJOR 0)
49-
set (PROJECT_VER_MINOR 6)
50-
set (PROJECT_VER_PATCH 4)
49+
set (PROJECT_VER_MINOR 7)
50+
set (PROJECT_VER_PATCH 0)
5151
set (PROJECT_VER
5252
"${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}")
5353
set (PROJECT_APIVER

include/libfreenect.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,15 @@ FREENECTAPI int freenect_open_device(freenect_context *ctx, freenect_device **de
355355
*/
356356
FREENECTAPI int freenect_open_device_by_camera_serial(freenect_context *ctx, freenect_device **dev, const char* camera_serial);
357357

358+
/**
359+
* Gets a serial number for the device.
360+
* The caller must free() the serial after use.
361+
*
362+
* @param dev
363+
* @return an appropriate serial number, or NULL if none was found.
364+
*/
365+
FREENECTAPI char* freenect_get_device_serial(freenect_device* dev);
366+
358367
/**
359368
* Closes a device that is currently open
360369
*

src/core.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ FREENECTAPI int freenect_open_device_by_camera_serial(freenect_context *ctx, fre
202202
return -1;
203203
}
204204

205+
FREENECTAPI char* freenect_get_device_serial(freenect_device* dev)
206+
{
207+
if (dev == NULL) return NULL;
208+
209+
int res;
210+
211+
struct freenect_device_attributes attr;
212+
res = fnusb_get_device_attributes(dev, &attr);
213+
if (res != 0) return NULL;
214+
215+
return strdup(attr.camera_serial);
216+
}
217+
205218
FREENECTAPI int freenect_close_device(freenect_device *dev)
206219
{
207220
freenect_context *ctx = dev->parent;

0 commit comments

Comments
 (0)