Skip to content

Commit a8a17ae

Browse files
committed
implement freenect_get_device_serial()
Signed-off-by: Benn Snyder <[email protected]>
1 parent 3cb8890 commit a8a17ae

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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+
char* camera_serial = fnusb_get_serial(&dev->usb_cam);
210+
if (camera_serial) return camera_serial;
211+
212+
char* audio_serial = fnusb_get_serial(&dev->usb_audio);
213+
if (audio_serial) return audio_serial;
214+
215+
return NULL;
216+
}
217+
205218
FREENECTAPI int freenect_close_device(freenect_device *dev)
206219
{
207220
freenect_context *ctx = dev->parent;

0 commit comments

Comments
 (0)