LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

read typedef in binaryfile from cvi 8.0 / conversion from c++

// I have problems converting this code into cvi 8.0 - does anyone tried this before? Thanks in advance,
// kind regards, Martin Schmal
//
// working code in c++
 
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
 
...
 
typedef struct MeasureHeader

  unsigned int  MeasureCount;
  char          LackNr[5];
  char          Karosse[3];
  unsigned char Ort;
  char          FileNamePart[19];
} t_MeasureHeader;
 
...
 
ifstream file("filname.dat", ios::binary);
file.seekg(0, ios_base::beg);                                                    //jump to begin of file
file.read( ( char* )&head, sizeof(t_MeasureHeader));
cout << head.MeasureCount << " Measuee Count " << head.Karosse << " Karosse Typ"; 
...
 
 
0 Kudos
Message 1 of 3
(3,383 Views)
Hi Martin,

the problem is, that LabWindows/CVI is an ANSI C compiler, not a C++ compiler. Have you already heard of Measurement Studio? It's an AddOn for Microsoft VisualStudio. This makes it possible for you to use C++ code as well (but still not within CVI).

Here are three links to the Measurement Studio Editions:

NI Measurement Studio Standard Edition:
http://sine.ni.com/nips/cds/view/p/lang/de/nid/1434

NI Measurement Studio Professional Edition
http://sine.ni.com/nips/cds/view/p/lang/de/nid/1413

NI Measurement Studio Enterprise Edition
http://sine.ni.com/nips/cds/view/p/lang/de/nid/2460

Hope this helps...

Daniel
NIG
0 Kudos
Message 2 of 3
(3,359 Views)
I finally found a way to read the binaryfile with ansi_c / cvi:
 
 
 
char *DATEI="test.001";  //init
 
typedef struct MeasureHeader {  
  
  unsigned int MeasureCount;
  char          LackNr[5];
    char          Karosse[3];
    unsigned char Ort;
    char          FileNamePart[19];
  } t_MeasureHeader;

FILE*file=NULL;
DATEI = (char *) malloc(1000); 
  
 switch (event)
  {
 case EVENT_COMMIT:
  GetProjectDir (&*DATEI);
  if (FileSelectPopup (&*DATEI, "*.001", "", "Data file to load", VAL_LOAD_BUTTON, 0, 0, 1, 0, DATEI) == VAL_NO_FILE_SELECTED)
 return 0;  
   

  file=fopen(DATEI,"rb"); 
  fread(&head,sizeof(t_MeasureHeader),1,file); 
 
  Count=head.MeasureCount;
  Lack=head.LackNr;
  Karo=head.Karosse;
  Ort=head.Ort;
  Dateiname=head.FileNamePart;
0 Kudos
Message 3 of 3
(3,328 Views)