<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de-AT">
	<id>https://becomwiki.live.md-websolutions.com/index.php?action=history&amp;feed=atom&amp;title=BltTofApi_Quick_Start_Guide</id>
	<title>BltTofApi Quick Start Guide - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://becomwiki.live.md-websolutions.com/index.php?action=history&amp;feed=atom&amp;title=BltTofApi_Quick_Start_Guide"/>
	<link rel="alternate" type="text/html" href="https://becomwiki.live.md-websolutions.com/index.php?title=BltTofApi_Quick_Start_Guide&amp;action=history"/>
	<updated>2026-05-13T14:09:56Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in BECOM Systems Support</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://becomwiki.live.md-websolutions.com/index.php?title=BltTofApi_Quick_Start_Guide&amp;diff=42&amp;oldid=prev</id>
		<title>Peter: 1 Version importiert</title>
		<link rel="alternate" type="text/html" href="https://becomwiki.live.md-websolutions.com/index.php?title=BltTofApi_Quick_Start_Guide&amp;diff=42&amp;oldid=prev"/>
		<updated>2023-10-31T08:03:05Z</updated>

		<summary type="html">&lt;p&gt;1 Version importiert&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de-AT&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 31. Oktober 2023, 10:03 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;de-AT&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(kein Unterschied)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Peter</name></author>
	</entry>
	<entry>
		<id>https://becomwiki.live.md-websolutions.com/index.php?title=BltTofApi_Quick_Start_Guide&amp;diff=41&amp;oldid=prev</id>
		<title>en&gt;Peter: 1 Version importiert</title>
		<link rel="alternate" type="text/html" href="https://becomwiki.live.md-websolutions.com/index.php?title=BltTofApi_Quick_Start_Guide&amp;diff=41&amp;oldid=prev"/>
		<updated>2023-08-22T19:35:46Z</updated>

		<summary type="html">&lt;p&gt;1 Version importiert&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Overview ==&lt;br /&gt;
In order to create a common interface for our products we define the interfaces between a ToF device and an application. The main part of this model is the common BltTofApi which is written in C for platform independency. The BltTofSuite and any application able to access the BltTofApi interface is compatible with any device with existing lib implementing the BltTofApi.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:CommonBltTofApiConcept.png|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;Interfacing concept&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every ToF system built by or for Bluetechnix shall be accessible by this common interface. A lib implementing this interface shall be written in C only and compile on any platform. The interface is kept as simple as possible and covers all functionalities of all ToF sensors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:hint.png]]&lt;br /&gt;
|&lt;br /&gt;
Before implementing and building the following examples, please check the Section [[BltTofApi Build instructions]].&amp;lt;br&amp;gt;&lt;br /&gt;
When encountering errors with the API consult the list of error codes in Section [[BltTofApi Error codes]].&amp;lt;br&amp;gt;&lt;br /&gt;
The API supports a callback (infoEvent) which can be used for further investigation of the (non-)functionality, described in Section [[BltTofApi Events description]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SDK Example ==&lt;br /&gt;
This example code is supposed to explain the most important functions exposed to the user. For more detailed information you can also check the header files in the SDK package&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot; collapse=&amp;quot;true&amp;quot; first-line=&amp;quot;2&amp;quot; highlight=&amp;quot;[4,6]&amp;quot; title=&amp;quot;title&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;bta.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#if defined(PLAT_LINUX) || defined(linux)&lt;br /&gt;
    #include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#elif defined(PLAT_WINDOWS) || defined(WIN32) || defined(WIN64)&lt;br /&gt;
    #include &amp;lt;windows.h&amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
    #error &amp;quot;No platform defined&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void BTA_CALLCONV discoveryCallback(BTA_DeviceInfo *deviceInfo) {&lt;br /&gt;
    printf(&amp;quot;discoveryCallback: device 0x%x, serial %d \n&amp;quot;, deviceInfo-&amp;gt;deviceType, deviceInfo-&amp;gt;serialNumber);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void errorHandling(BTA_Status status) {&lt;br /&gt;
    if (status != BTA_StatusOk) {&lt;br /&gt;
        char statusString[100];&lt;br /&gt;
        BTAstatusToString(status, statusString, strlen(statusString));&lt;br /&gt;
        printf(&amp;quot;error: %s (%d)\n&amp;quot;, statusString, status);&lt;br /&gt;
        printf(&amp;quot;Hit &amp;lt;Return&amp;gt; to end the example\n&amp;quot;);&lt;br /&gt;
        fgetc(stdin);&lt;br /&gt;
        exit(0);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
static void wait(int ms) {&lt;br /&gt;
    #if defined(PLAT_LINUX) || defined(linux)&lt;br /&gt;
        usleep(ms * 1000);&lt;br /&gt;
    #elif defined(PLAT_WINDOWS) || defined(WIN32) || defined(WIN64)&lt;br /&gt;
        Sleep(ms);&lt;br /&gt;
    #endif&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Example for an implementation of the infoEvent callback handler&lt;br /&gt;
static void BTA_CALLCONV infoEvent(BTA_EventId eventId, int8_t *msg) {&lt;br /&gt;
    char eventIdString[100];&lt;br /&gt;
    BTAeventIdToString(eventId, eventIdString, sizeof(eventIdString));&lt;br /&gt;
    printf(&amp;quot;   infoEvent: (%s) %s\n&amp;quot;, eventIdString, msg);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Example for an implementation of the frameArrived callback handler&lt;br /&gt;
static void BTA_CALLCONV frameArrived(BTA_Frame *frame) {&lt;br /&gt;
    BTA_Status status;&lt;br /&gt;
    BTA_Frame *frameClone;&lt;br /&gt;
    status = BTAcloneFrame(frame, &amp;amp;frameClone);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    // The frameClone pointer can now be stored for later processing, or&lt;br /&gt;
    // a new thread can handle that, // but this function should return now.&lt;br /&gt;
    // Wherever the processing is done, before loosing the last reference to it,&lt;br /&gt;
    // the clone must be free&amp;#039;d&lt;br /&gt;
    BTAfreeFrame(&amp;amp;frameClone);&lt;br /&gt;
    // (Do not free or alter the frame that was passed as a parameter)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#ifdef FOR_EXPERTS_ONLY&lt;br /&gt;
// Example for an implementation of the progressReport callback handler&lt;br /&gt;
static void BTA_CALLCONV progressReport(BTA_Status status, uint8_t percentage) {&lt;br /&gt;
    if (percentage == 0 &amp;amp;&amp;amp; status == BTA_StatusOk) {&lt;br /&gt;
        printf(&amp;quot;Flash update started&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    else if (percentage == 100 &amp;amp;&amp;amp; status == BTA_StatusOk) {&lt;br /&gt;
        printf(&amp;quot;Flash update finished with success&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    else if (status == BTA_StatusOk){&lt;br /&gt;
        printf(&amp;quot;Flash update progress: %d&amp;quot;, percentage);&lt;br /&gt;
    }&lt;br /&gt;
    else {&lt;br /&gt;
        char statusString[100];&lt;br /&gt;
        BTAstatusToString(status, statusString, strlen(statusString));&lt;br /&gt;
        printf(&amp;quot;Flash update failed: %s&amp;quot;, statusString);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    BTA_Status status;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // BtaP100Lib only (until now)&lt;br /&gt;
    // Discovery&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // The feature of listing available devices is currently only supported by BtaP100Lib.&lt;br /&gt;
    BTA_DiscoveryConfig discoveryConfig;&lt;br /&gt;
    BTAinitDiscoveryConfig(&amp;amp;discoveryConfig);&lt;br /&gt;
    status = BTAstartDiscovery(&amp;amp;discoveryConfig, &amp;amp;discoveryCallback);&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    // Initialization&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // First, the library must be configured via the configuration c-structure.&lt;br /&gt;
    // The configuration structure must be initialized with standard values using the function&lt;br /&gt;
    // BTAinitConfig. The specific implementation of the library defines which parameters are &lt;br /&gt;
    // required and which can be left out. The required parameters must then be set to a valid&lt;br /&gt;
    // value before calling BTAopen.&lt;br /&gt;
&lt;br /&gt;
    BTA_Config config;&lt;br /&gt;
    printf(&amp;quot;BTAinitConfig()\n&amp;quot;);&lt;br /&gt;
    status = BTAinitConfig(&amp;amp;config);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    &lt;br /&gt;
    // Connection Parameters&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Depending on the library and the device, different connection parameters must be set.&lt;br /&gt;
    // Redundant connections (like TCP and UDP control connections) are used sequencially and&lt;br /&gt;
    // exclusively&lt;br /&gt;
    // (UDP is tried first and only if it fails, TCP is connected)&lt;br /&gt;
    // Unnecessary information is ignored (BtaP100Lib ignores ethernet parameters)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // BtaEthLib only&lt;br /&gt;
    // UDP data connection (normally multicast address)&lt;br /&gt;
    uint8_t udpDataIpAddr[] = { 224, 0, 0, 1 };&lt;br /&gt;
    config.udpDataIpAddr = udpDataIpAddr;&lt;br /&gt;
    config.udpDataIpAddrLen = 4;&lt;br /&gt;
    config.udpDataPort = 10002;&lt;br /&gt;
    // TCP control connection (device&amp;#039;s IP address)&lt;br /&gt;
    uint8_t tcpDeviceIpAddr[] = { 192, 168, 0, 10 };&lt;br /&gt;
    config.tcpDeviceIpAddr = tcpDeviceIpAddr;&lt;br /&gt;
    config.tcpDeviceIpAddrLen = 4;&lt;br /&gt;
    config.tcpControlPort = 10001;&lt;br /&gt;
    // UDP control outbound connection (device&amp;#039;s IP address)&lt;br /&gt;
    uint8_t udpControlOutIpAddr[] = { 192, 168, 0, 10 };&lt;br /&gt;
    config.udpControlOutIpAddr = udpControlOutIpAddr;&lt;br /&gt;
    config.udpControlOutIpAddrLen = 4;&lt;br /&gt;
    config.udpControlOutPort = 10003;&lt;br /&gt;
    // UDP control inbound connection (normally the host&amp;#039;s IP address)&lt;br /&gt;
    uint8_t udpControlInIpAddr[] = { 192, 168, 0, 1 };&lt;br /&gt;
    config.udpControlInIpAddr = udpControlInIpAddr;&lt;br /&gt;
    config.udpControlInIpAddrLen = 4;&lt;br /&gt;
    config.udpControlInPort = 10004;&lt;br /&gt;
    &lt;br /&gt;
    // Optional settings for advanced functionalities&lt;br /&gt;
&lt;br /&gt;
    // If you want to receive status updates from the library,&lt;br /&gt;
    // register a callback function for informative events.&lt;br /&gt;
    config.infoEvent = &amp;amp;infoEvent;&lt;br /&gt;
    // ...and set the verbosity for infoEvents.&lt;br /&gt;
    config.verbosity = 9;&lt;br /&gt;
&lt;br /&gt;
    // If you want to receive the frames immediately when they arrive,&lt;br /&gt;
    // register a callback function for incoming frames.&lt;br /&gt;
    config.frameArrived = &amp;amp;frameArrived;&lt;br /&gt;
&lt;br /&gt;
    // Choose whether and how queueing of frames is done.&lt;br /&gt;
    // Queueing does not affect the frameArrived callback at all&lt;br /&gt;
    // If you don&amp;#039;t specify frame queuing, you can still use the frameArrived callback,&lt;br /&gt;
    // but you will get an error on BTAgetFrame()&lt;br /&gt;
    // We choose &amp;#039;DropOldest&amp;#039;, so we always get the most recent frame&lt;br /&gt;
    config.frameQueueMode = BTA_QueueModeDropOldest;&lt;br /&gt;
    // Set the length of the frame queue.&lt;br /&gt;
    config.frameQueueLength = 1;&lt;br /&gt;
    &lt;br /&gt;
    // The frame mode can be configured in order to get the desired data channels in a frame from&lt;br /&gt;
    // the sensor / library:&lt;br /&gt;
    config.frameMode = BTA_FrameModeDistAmp;&lt;br /&gt;
&lt;br /&gt;
    // BtaP100Lib only&lt;br /&gt;
    // If this parameter is left empty, the default lens configuration will be used.&lt;br /&gt;
    // Otherwise, use the name (and path) of a valid lens calibration file encoded in ASCII.&lt;br /&gt;
    config.calibFileName = 0; //(uint8_t *)&amp;quot;calibFile.bin&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    // Connecting&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Now that the configuration structure is filled in, the connection is ready to be opened&lt;br /&gt;
    // The first infoEvents should fire while the library is connecting to the sensor. That, however&lt;br /&gt;
    // depends on the library implementation and the configured verbosity.&lt;br /&gt;
&lt;br /&gt;
    BTA_Handle btaHandle;&lt;br /&gt;
    printf(&amp;quot;BTAopen()\n&amp;quot;);&lt;br /&gt;
    status = BTAopen(&amp;amp;config, &amp;amp;btaHandle);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
    // Connection Status&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // It is possible to get the service state and connection state (not all libraries are able to&lt;br /&gt;
    // detect their connection status):&lt;br /&gt;
    &lt;br /&gt;
    printf(&amp;quot;Service running: %d\n&amp;quot;, BTAisRunning(btaHandle));&lt;br /&gt;
    printf(&amp;quot;Connection up: %d\n&amp;quot;, BTAisConnected(btaHandle));&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    // Querying Device Information&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // The following example shows, how general information on the device can be retrieved.&lt;br /&gt;
    // The resulting struct may be only partly filled depending on the device’s capabilities.&lt;br /&gt;
&lt;br /&gt;
    BTA_DeviceInfo *deviceInfo;&lt;br /&gt;
    printf(&amp;quot;BTAgetDeviceInfo()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetDeviceInfo(btaHandle, &amp;amp;deviceInfo);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    printf(&amp;quot;Device type: 0x%x\n&amp;quot;, deviceInfo-&amp;gt;deviceType);&lt;br /&gt;
    printf(&amp;quot;BTAfreeDeviceInfo()\n&amp;quot;);&lt;br /&gt;
    BTAfreeDeviceInfo(deviceInfo);&lt;br /&gt;
    &lt;br /&gt;
    // Frame-Rate&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Read and change the frame rate via these functions&lt;br /&gt;
&lt;br /&gt;
    float frameRate;&lt;br /&gt;
    printf(&amp;quot;BTAgetFrameRate()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetFrameRate(btaHandle, &amp;amp;frameRate);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    printf(&amp;quot;Framerate is %f\n&amp;quot;, frameRate);&lt;br /&gt;
    printf(&amp;quot;BTAsetFrameRate(%f)\n&amp;quot;, frameRate);&lt;br /&gt;
    status = BTAsetFrameRate(btaHandle, frameRate);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    &lt;br /&gt;
    // Integration time&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Read and change the main integration time via this functions:&lt;br /&gt;
&lt;br /&gt;
    uint32_t integrationTime;&lt;br /&gt;
    printf(&amp;quot;BTAgetIntegrationTime()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetIntegrationTime(btaHandle, &amp;amp;integrationTime);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    printf(&amp;quot;Integration time is %d\n&amp;quot;, integrationTime);&lt;br /&gt;
    printf(&amp;quot;BTAsetIntegrationTime(%d)\n&amp;quot;, integrationTime);&lt;br /&gt;
    status = BTAsetIntegrationTime(btaHandle, integrationTime);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    &lt;br /&gt;
    // Modulation frequency&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Read and change the main modulation frequency via this functions&lt;br /&gt;
&lt;br /&gt;
    uint32_t modulationFrequency;&lt;br /&gt;
    printf(&amp;quot;BTAgetModulationFrequency()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetModulationFrequency(btaHandle, &amp;amp;modulationFrequency);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    printf(&amp;quot;Modulation frequency is %d\n&amp;quot;, modulationFrequency);&lt;br /&gt;
    printf(&amp;quot;BTAsetModulationFrequency(%d)\n&amp;quot;, modulationFrequency);&lt;br /&gt;
    status = BTAsetModulationFrequency(btaHandle, modulationFrequency);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    &lt;br /&gt;
    // Global offset&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Global stands for ‘all pixels’, meaning, that this offset is applied to all pixels.&lt;br /&gt;
    // It is, for all current devices, valid for the currently set modulation frequency.&lt;br /&gt;
    // It can only and should be set for all predefined modulation frequencies (see device’s SUM).&lt;br /&gt;
    // When changing the modulation frequency, the global offset reads differently.&lt;br /&gt;
&lt;br /&gt;
    float offset;&lt;br /&gt;
    printf(&amp;quot;BTAgetGlobalOffset()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetGlobalOffset(btaHandle, &amp;amp;offset);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    printf(&amp;quot;Global offset is %f\n&amp;quot;, offset);&lt;br /&gt;
    printf(&amp;quot;BTAsetGlobalOffset(%f)\n&amp;quot;, offset);&lt;br /&gt;
    status = BTAsetGlobalOffset(btaHandle, offset);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    &lt;br /&gt;
    // Frame mode&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // The frame mode defines what channels the sonsor delivers to the library and/or&lt;br /&gt;
    // what data the library puts into a frame&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;BTAsetFrameMode(BTA_FrameModeXYZAmp)\n&amp;quot;);&lt;br /&gt;
    status = BTAsetFrameMode(btaHandle, BTA_FrameModeXYZAmp);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    &lt;br /&gt;
    // Register read/write&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Register operations are done via readRegister and writeRegister.&lt;br /&gt;
    // Most devices support mult-read and multi-write. The last parameter can be used to take&lt;br /&gt;
    // advantage of that feature.&lt;br /&gt;
    // For a normal read/write null can be passed.&lt;br /&gt;
    // Example for one register at address 0x20:&lt;br /&gt;
    uint32_t regValue;&lt;br /&gt;
    printf(&amp;quot;BTAreadRegister()\n&amp;quot;);&lt;br /&gt;
    status = BTAreadRegister(btaHandle, 0x20, &amp;amp;regValue, 0);&lt;br /&gt;
    errorHandling(status);    &lt;br /&gt;
    printf(&amp;quot;BTAwriteRegister()\n&amp;quot;);&lt;br /&gt;
    status = BTAwriteRegister(btaHandle, 0x20, &amp;amp;regValue, 0);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    //The application must guarantee that register accesses are done exclusively. A read/write is&lt;br /&gt;
    // only called when the last read/write returned.&lt;br /&gt;
    &lt;br /&gt;
    // Wait a little, so the frame in the lib&amp;#039;s queue is fresh regarding the just written parameters&lt;br /&gt;
    wait(2000);&lt;br /&gt;
&lt;br /&gt;
    // Frame Retrieval&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // Once the connection is established, the frameArrived callback (if not null) is called&lt;br /&gt;
    // whenever a frame is received from the sensor.&lt;br /&gt;
    // But a frame can also actively be requested from the library&lt;br /&gt;
&lt;br /&gt;
    BTA_Frame *frame;&lt;br /&gt;
    printf(&amp;quot;BTAgetFrame()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetFrame(btaHandle, &amp;amp;frame, 300);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    &lt;br /&gt;
    // The frame structure contains all the necessary information which can be accessed directly&lt;br /&gt;
    // or using the helper functions.&lt;br /&gt;
    // For getting the buffer with amplitudes, for example:&lt;br /&gt;
    uint16_t *amplitudes;&lt;br /&gt;
    BTA_DataFormat dataFormat;&lt;br /&gt;
    BTA_Unit unit;&lt;br /&gt;
    uint16_t xRes, yRes;&lt;br /&gt;
    printf(&amp;quot;BTAgetAmplitudes()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetAmplitudes(frame, (void **)&amp;amp;amplitudes, &amp;amp;dataFormat, &amp;amp;unit, &amp;amp;xRes, &amp;amp;yRes);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    if (dataFormat == BTA_DataFormatUInt16) {&lt;br /&gt;
        // This dataformat tells us that it&amp;#039;s ok to interpret the data as (uint16_t *)&lt;br /&gt;
        if (unit == BTA_UnitUnitLess) {&lt;br /&gt;
            printf(&amp;quot;Got amplitude data\n&amp;quot;);&lt;br /&gt;
            // -&amp;gt; access amplitude data simply as amplitudes[i]&lt;br /&gt;
            uint32_t ampAvg = 0;&lt;br /&gt;
            for (int y = 0; y &amp;lt; yRes; y++) {&lt;br /&gt;
                for (int x = 0; x &amp;lt; xRes; x++) {&lt;br /&gt;
                    ampAvg += amplitudes[x + y*xRes];&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            if (xRes != 0 &amp;amp;&amp;amp; yRes != 0) {&lt;br /&gt;
                printf(&amp;quot;The average amplitude is %d\n&amp;quot;, ampAvg / xRes / yRes);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    else if (dataFormat == BTA_DataFormatFloat32) {&lt;br /&gt;
        // This dataformat tells us that it&amp;#039;s ok to interpret the data as (float *)&lt;br /&gt;
        if (unit == BTA_UnitUnitLess) {&lt;br /&gt;
            printf(&amp;quot;Got amplitude data\n&amp;quot;);&lt;br /&gt;
            // -&amp;gt; access amplitude data simply as ((float *)amplitudes)[i]&lt;br /&gt;
            float ampAvg = 0;&lt;br /&gt;
            for (int y = 0; y &amp;lt; yRes; y++) {&lt;br /&gt;
                for (int x = 0; x &amp;lt; xRes; x++) {&lt;br /&gt;
                    ampAvg += ((float *)amplitudes)[x + y*xRes];&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            if (xRes != 0 &amp;amp;&amp;amp; yRes != 0) {&lt;br /&gt;
                printf(&amp;quot;The average amplitude is %d\n&amp;quot;, (int)ampAvg / xRes / yRes);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // The first pixel value in the buffer corresponds to the&lt;br /&gt;
    // upper left pixel (sensor point of view).&lt;br /&gt;
&lt;br /&gt;
    // In order to extract the Cartesian coordinates, do the following:    &lt;br /&gt;
    void *xCoordinates, *yCoordinates, *zCoordinates;&lt;br /&gt;
    printf(&amp;quot;BTAgetXYZcoordinates()\n&amp;quot;);&lt;br /&gt;
    status = BTAgetXYZcoordinates(frame, &amp;amp;xCoordinates, &amp;amp;yCoordinates, &amp;amp;zCoordinates,&lt;br /&gt;
                                  &amp;amp;dataFormat, &amp;amp;unit, &amp;amp;xRes, &amp;amp;yRes);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    if (dataFormat == BTA_DataFormatSInt16) {&lt;br /&gt;
        // This dataformat tells us that it&amp;#039;s ok to cast (void *) to (int16_t *)&lt;br /&gt;
        if (unit == BTA_UnitMillimeter) {&lt;br /&gt;
            printf(&amp;quot;Got 3D data\n&amp;quot;);&lt;br /&gt;
            // -&amp;gt; cast the void* to int16_t* and access data points simply as:&lt;br /&gt;
            //   ((int16_t *)xCoordinates)[i]&lt;br /&gt;
            //   ((int16_t *)yCoordinates)[i]&lt;br /&gt;
            //   ((int16_t *)zCoordinates)[i]&lt;br /&gt;
            uint32_t radiusMin = 0xffffffff;&lt;br /&gt;
            int16_t xCoordinate = 0, yCoordinate = 0, zCoordinate = 0;&lt;br /&gt;
            for (int y = 0; y &amp;lt; yRes; y++) {&lt;br /&gt;
                for (int x = 0; x &amp;lt; xRes; x++) {&lt;br /&gt;
                    if (((int16_t *)zCoordinates)[x + y*xRes] &amp;gt; 0) {&lt;br /&gt;
                        uint32_t radius = ((int16_t *)xCoordinates)[x + y*xRes] * &lt;br /&gt;
                                          ((int16_t *)xCoordinates)[x + y*xRes];&lt;br /&gt;
                        radius += ((int16_t *)yCoordinates)[x + y*xRes] *&lt;br /&gt;
                                  ((int16_t *)yCoordinates)[x + y*xRes];&lt;br /&gt;
                        radius += ((int16_t *)zCoordinates)[x + y*xRes] *&lt;br /&gt;
                                  ((int16_t *)zCoordinates)[x + y*xRes];&lt;br /&gt;
                        if (radius &amp;lt; radiusMin) {&lt;br /&gt;
                            radiusMin = radius;&lt;br /&gt;
                            xCoordinate = ((int16_t *)xCoordinates)[x + y*xRes];&lt;br /&gt;
                            yCoordinate = ((int16_t *)yCoordinates)[x + y*xRes];&lt;br /&gt;
                            zCoordinate = ((int16_t *)zCoordinates)[x + y*xRes];&lt;br /&gt;
                        }&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            printf(&amp;quot;The nearest point is (%d, %d, %d) [mm]\n&amp;quot;, xCoordinate, yCoordinate, zCoordinate);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    else if (dataFormat == BTA_DataFormatFloat32) {&lt;br /&gt;
        // This dataformat tells us that it&amp;#039;s ok to cast (void *) to (float *)&lt;br /&gt;
        if (unit == BTA_UnitMeter) {&lt;br /&gt;
            printf(&amp;quot;Got 3D data\n&amp;quot;);&lt;br /&gt;
            // -&amp;gt; cast the void* to (float *) and access data points simply as:&lt;br /&gt;
            //   ((float *)xCoordinates)[i]&lt;br /&gt;
            //   ((float *)yCoordinates)[i]&lt;br /&gt;
            //   ((float *)zCoordinates)[i]&lt;br /&gt;
            float radiusMin = 0xffffffff;&lt;br /&gt;
            float xCoordinate = 0, yCoordinate = 0, zCoordinate = 0;&lt;br /&gt;
            for (int y = 0; y &amp;lt; yRes; y++) {&lt;br /&gt;
                for (int x = 0; x &amp;lt; xRes; x++) {&lt;br /&gt;
                    if (((float *)zCoordinates)[x + y*xRes] &amp;gt; 0) {&lt;br /&gt;
                        float radius = ((float *)xCoordinates)[x + y*xRes] * &lt;br /&gt;
                                       ((float *)xCoordinates)[x + y*xRes];&lt;br /&gt;
                        radius += ((float *)yCoordinates)[x + y*xRes] *&lt;br /&gt;
                                  ((float *)yCoordinates)[x + y*xRes];&lt;br /&gt;
                        radius += ((float *)zCoordinates)[x + y*xRes] *&lt;br /&gt;
                                  ((float *)zCoordinates)[x + y*xRes];&lt;br /&gt;
                        if (radius &amp;lt; radiusMin) {&lt;br /&gt;
                            radiusMin = radius;&lt;br /&gt;
                            xCoordinate = ((float *)xCoordinates)[x + y*xRes];&lt;br /&gt;
                            yCoordinate = ((float *)yCoordinates)[x + y*xRes];&lt;br /&gt;
                            zCoordinate = ((float *)zCoordinates)[x + y*xRes];&lt;br /&gt;
                        }&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            if (radiusMin &amp;lt; 0xffffffff) {&lt;br /&gt;
                printf(&amp;quot;The nearest point is (%d, %d, %d) [mm]\n&amp;quot;, (int)(1000*xCoordinate),&lt;br /&gt;
                                                                   (int)(1000*yCoordinate),&lt;br /&gt;
                                                                   (int)(1000*zCoordinate));&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // The Channels X, Y and Z are given in the predefine Cartesian coordinate system.&lt;br /&gt;
    // See Figure &amp;quot;ToF coordinate system&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // Example for extracting RGB565 data out of a BTA_Frame&lt;br /&gt;
    if (frame) {&lt;br /&gt;
        if (frame-&amp;gt;channels) {&lt;br /&gt;
            for (int i = 0; i &amp;lt; frame-&amp;gt;channelsLen; i++) {&lt;br /&gt;
                if (frame-&amp;gt;channels[i]-&amp;gt;id == BTA_ChannelIdColor) {&lt;br /&gt;
                    dataFormat = frame-&amp;gt;channels[i]-&amp;gt;dataFormat;&lt;br /&gt;
                    if (dataFormat == BTA_DataFormatRgb565) {&lt;br /&gt;
                        // Previously we selected a frameMode without an RGB channel, &lt;br /&gt;
                        // so this will never be true unless we change the frameMode&lt;br /&gt;
                        unit = frame-&amp;gt;channels[i]-&amp;gt;unit;&lt;br /&gt;
                        xRes = frame-&amp;gt;channels[i]-&amp;gt;xRes;&lt;br /&gt;
                        yRes = frame-&amp;gt;channels[i]-&amp;gt;yRes;&lt;br /&gt;
                        void *colorBuffer = frame-&amp;gt;channels[i]-&amp;gt;data;&lt;br /&gt;
                        if (colorBuffer) {&lt;br /&gt;
                            for (int xy = 0; xy &amp;lt; xRes*yRes; xy++) {&lt;br /&gt;
                                uint16_t pixelRgb565 = ((uint16_t *)colorBuffer)[xy];&lt;br /&gt;
                                uint8_t b = ((uint8_t)(((pixelRgb565 &amp;amp; 0x001f) &amp;lt;&amp;lt; 3) |&lt;br /&gt;
                                            ((pixelRgb565 &amp;amp; 0x001f) &amp;gt;&amp;gt; 2)));&lt;br /&gt;
                                uint8_t g = ((uint8_t)(((pixelRgb565 &amp;amp; 0x07e0) &amp;gt;&amp;gt; 3) |&lt;br /&gt;
                                            ((pixelRgb565 &amp;amp; 0x07e0) &amp;gt;&amp;gt; 9)));&lt;br /&gt;
                                uint8_t r = ((uint8_t)(((pixelRgb565 &amp;amp; 0xf800) &amp;gt;&amp;gt; 8) |&lt;br /&gt;
                                            ((pixelRgb565 &amp;amp; 0xf800) &amp;gt;&amp;gt; 13)));&lt;br /&gt;
                                printf(&amp;quot;r %d g %d b %d\n&amp;quot;, r, g, b);&lt;br /&gt;
                            }&lt;br /&gt;
                        }&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // Frame Cleanup&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // A successful call to getFrame or cloneFrame always demands for a call to BTAfreeFrame&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;BTAfreeFrame()\n&amp;quot;);&lt;br /&gt;
    status = BTAfreeFrame(&amp;amp;frame);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #ifdef FOR_EXPERTS_ONLY&lt;br /&gt;
    // Flash update&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // A transfer of data to the device, typically to be saved in the device’s flash memory can be&lt;br /&gt;
    // performed by calling the library’s function BTAflashUpdate. It is mainly used to perform a &lt;br /&gt;
    // firmware update. The struct BTA_FlashUpdateConfig is passed containing all the information&lt;br /&gt;
    // needed. The library defines which fields in the structure have to be filled depending on&lt;br /&gt;
    // the type of the update and/or data. Thus, the user must know how to configure the update&lt;br /&gt;
    // and what data to pass as parameter.&lt;br /&gt;
&lt;br /&gt;
    // An example for updating the pixel list is:&lt;br /&gt;
    BTA_FlashUpdateConfig flashUpdateConfig;&lt;br /&gt;
    flashUpdateConfig.target = BTA_FlashTargetPixelList;&lt;br /&gt;
    uint32_t dummydata = 0x12345678;&lt;br /&gt;
    flashUpdateConfig.data = (uint8_t *)&amp;amp;dummydata;&lt;br /&gt;
    flashUpdateConfig.dataLen = 4;&lt;br /&gt;
    printf(&amp;quot;BTAflashUpdate()\n&amp;quot;);&lt;br /&gt;
    status = BTAflashUpdate(btaHandle, &amp;amp;flashUpdateConfig, (FN_BTA_ProgressReport)&amp;amp;progressReport);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
    // This function simplifies the process of a firmware update allowing the user to pass a&lt;br /&gt;
    // connection handle and the name of a binary firmware file. Internally it uses BTAflashUpdate()&lt;br /&gt;
    printf(&amp;quot;BTAfirmwareUpdate()\n&amp;quot;);&lt;br /&gt;
    status = BTAfirmwareUpdate(btaHandle, (uint8_t *)&amp;quot;fw.bin&amp;quot;, (FN_BTA_ProgressReport)&amp;amp;progressReport);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    #ifdef THIS_SECTION_COMPROMISES_REGISTER_VALUES_PERMANENTLY    &lt;br /&gt;
    // Storing and restoring register settings&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // The register values can be stored in flash memory in order to be preserved beyond a&lt;br /&gt;
    // reboot/power cycle&lt;br /&gt;
    printf(&amp;quot;BTAwriteCurrentConfigToNvm()\n&amp;quot;);&lt;br /&gt;
    status = BTAwriteCurrentConfigToNvm(btaHandle);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
    // The restoring of the default configuration typically requires a reboot in order to take&lt;br /&gt;
    // immediate effect&lt;br /&gt;
    printf(&amp;quot;BTArestoreDefaultConfig()\n&amp;quot;);&lt;br /&gt;
    status = BTArestoreDefaultConfig(btaHandle);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    #endif&lt;br /&gt;
    &lt;br /&gt;
    // Grabbing the stream&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // The Blt libraries are able to write frames to disk. Very conveniently, all the frame data&lt;br /&gt;
    // is stored in a *.bltstream file. These files can later be replayed by the BtaStreamLib as&lt;br /&gt;
    // if the same sensor was connected.&lt;br /&gt;
&lt;br /&gt;
    BTA_GrabbingConfig grabbingConfig;&lt;br /&gt;
    printf(&amp;quot;BTAinitGrabbingConfig()\n&amp;quot;);&lt;br /&gt;
    status = BTAinitGrabbingConfig(&amp;amp;grabbingConfig);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
    grabbingConfig.filename = (uint8_t *)&amp;quot;test.bltstream&amp;quot;; // (ASCII coded)&lt;br /&gt;
    printf(&amp;quot;BTAstartGrabbing()\n&amp;quot;);&lt;br /&gt;
    status = BTAstartGrabbing(btaHandle, &amp;amp;grabbingConfig);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
    // Grabbing is taking place. Let it grab for 2 sec&lt;br /&gt;
    wait(2000);&lt;br /&gt;
    &lt;br /&gt;
    printf(&amp;quot;BTAstopGrabbing()\n&amp;quot;);&lt;br /&gt;
    status = BTAstartGrabbing(btaHandle, 0);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
    // Device Reset&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // If the device and the library choose to implement this functionality, a device reset can be&lt;br /&gt;
    // performed&lt;br /&gt;
&lt;br /&gt;
    status = BTAsendReset(btaHandle);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
    // Disconnecting&lt;br /&gt;
    //----------------------------------------------------------------------------------------------&lt;br /&gt;
    // When work is done and no other threads need to access the library&amp;#039;s functions,&lt;br /&gt;
    // disconnect the sensor and stop the service by simply calling BTAclose&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;BTAclose()\n&amp;quot;);&lt;br /&gt;
    status = BTAclose(&amp;amp;btaHandle);&lt;br /&gt;
    errorHandling(status);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    printf(&amp;quot;Hit &amp;lt;Return&amp;gt; to end the example\n&amp;quot;);&lt;br /&gt;
    fgetc(stdin);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>en&gt;Peter</name></author>
	</entry>
</feed>