09-12-2012 03:48 PM
I tried to create *.tdms file format with following codes. It did not create file and did not return any error codes. I could not find the problem. Would anyone let me know what the error was?
#define TDMS_FILE_TIT "Test 200 Hz TDMS data format"
#define TDMS_FILE_AUT "No Joen"
#define TDMS_ORION_200_HZ_CHANS 44
#define NUM_MAX_POINTS 44
//==============================================================================
// Types
//==============================================================================
// Static global variables
static const char * GROUP_NAME = "200 Hz data";
static const char * GROUP_DESC = "Test 200 Hz data collect by simulation test";
//==============================================================================
// Static functions
//==============================================================================
// Global variables
double startTime, elapsedTime;
TDMSFileHandle hTdmsTestFileHandle;
TDMSChannelGroupHandle hTdmsTestGroupHandle;
TDMSChannelHandle * phChannels;
//==============================================================================
// Global functions
/// HIFN The main entry-point function.
/// HIPAR argc/The number of command-line arguments.
/// HIPAR argc/This number includes the name of the command-line tool.
/// HIPAR argv/An array of command-line arguments.
/// HIPAR argv/Element 0 contains the name of the command-line tool.
/// HIRET Returns 0 if successful.
int main (int argc, char *argv[])
{
int tdmsError = 0;
int i = 0;
unsigned int usChan;
char szChanName[50];
char szChanDesc[50];
tdmsError = TDMS_CreateFile(TDMS_FILE_PATH, TDMS_Streaming, TDMS_FILENAME,
TDMS_FILE_DESC, TDMS_FILE_TIT, TDMS_FILE_AUT, &hTdmsTestFileHandle);
tdmsError = TDMS_AddChannelGroup (hTdmsTestFileHandle, GROUP_NAME, GROUP_DESC, &hTdmsTestGroupHandle);
phChannels = malloc (sizeof(TDMSChannelHandle) * TDMS_ORION_200_HZ_CHANS);
for (usChan = 0; usChan < TDMS_ORION_200_HZ_CHANS; usChan++)
{
sprintf (szChanName, "point_%d", usChan);
sprintf (szChanDesc, "Data for channel %d", usChan);
tdmsError = TDMS_AddChannel (hTdmsTestGroupHandle, TDMS_Double, szChanName, szChanDesc, 0, &phChannels[usChan]);
}
free (phChannels);
tdmsError = TDMS_CloseFile (hTdmsTestFileHandle);
return 0;
}
09-12-2012 04:57 PM
Found the problem. Resolved.
Thanks.
09-13-2012 10:07 AM
Hi NICoder,
If you could, please post and mark your solutions when you find them for anyone who happens to stumble upon the thread in the future
Cheers,
09-13-2012 12:11 PM
The above code did not have data section therefore the NI API did not created the TDMS file. It worked when I added data.