Sensor Model | G2xxx, G3xxx |
Firmware version | 5.x, 6.x |
SDK version | All |
Question
How do I use the SDK to record data as a .rec file?
Answer
Using the GoSensor_StartRecordingStream() and GoSensor_GoSensorStopRecording() you're able to record profile or surface data as a .rec file to your PC. Note that before calling the GoSensor_StartRecordingStream function, the sensor is already running and recording is enabled. GoSensor_GoSensorStopRecording() should be called before executing any other sensor commands, with the exception of GoSensor_IsRecordingStreaming().
Example
Below an example that saves incoming data as myrecfile.rec to the pc.
#include <GoSdk/GoSdk.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define SENSOR_IP "192.168.1.10"
void main(int argc, char **argv)
{
kAssembly api = kNULL;
GoSystem system = kNULL;
GoSensor sensor = kNULL;
kStatus status;
kIpAddress ipAddress;
// construct Gocator API Library
if ((status = GoSdk_Construct(&api)) != kOK)
{
printf("Error: GoSdk_Construct:%d\n", status);
return;
}
// construct GoSystem object
if ((status = GoSystem_Construct(&system, kNULL)) != kOK)
{
printf("Error: GoSystem_Construct:%d\n", status);
return;
}
// Parse IP address into address data structure
kIpAddress_Parse(&ipAddress, SENSOR_IP);
// obtain GoSensor object by sensor IP address
if ((status = GoSystem_FindSensorByIpAddress(system, &ipAddress, &sensor)) != kOK)
{
printf("Error: GoSystem_FindSensor:%d\n", status);
return;
}
// create connection to GoSystem object
if ((status = GoSystem_Connect(system)) != kOK)
{
printf("Error: GoSystem_Connect:%d\n", status);
return;
}
// enable sensor data channel
if ((status = GoSystem_EnableData(system, kTRUE)) != kOK)
{
printf("Error: GoSensor_EnableData:%d\n", status);
return;
}
// enable recording
if ((status = GoSensor_EnableRecording(sensor, kTRUE)) != kOK)
{
printf("Error: GoSensor_EnableRecording:%d\n", status);
return;
}
// start sensor
if ((status = GoSensor_Start(sensor)) != kOK)
{
printf("Error: GoSystem_Start:%d\n", status);
return;
}
printf("Sensor is started.\n");
printf("Press any key to start the recording...\n");
getchar();
// start recording the data to c:/temp/myrecfile.rec
// Note: be sure the folder in where you save the file exists on your pc.
if ((status = GoSensor_StartRecordingStream(sensor, "c://temp//myrecfile.rec")) != kOK)
{
printf("Error: GoSensor_StartRecordingStream:%d\n", status);
return;
}
printf("Press any key to stop recording...\n");
getchar();
// stop the recording
if ((status = GoSensor_StopRecordingStream(sensor)) != kOK)
{
printf("Error: GoSensor_StopRecordingStream:%d\n", status);
return;
}
printf("Press any key to stop sensor...\n");
getchar();
// stop the sensor
if ((status = GoSensor_Stop(sensor)) != kOK)
{
printf("Error: GoSystem_Stop:%d\n", status);
return;
}
printf("Press any key to exit...\n");
getchar();
// destroy handles
GoDestroy(system);
GoDestroy(api);
printf("Press any key to continue...\n");
getchar();
return;
}
Comments
0 comments
Please sign in to leave a comment.