To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 10929
10928  |  10930
Subject: 
Re: Spirit.ocx in VC++
Newsgroups: 
lugnet.robotics
Date: 
Sun, 5 Mar 2000 14:49:05 GMT
Viewed: 
900 times
  
Hi Steve,

On Sun, 5 Mar 2000 01:19:22 GMT, you wrote:

Actually, the datatype is VARIANT, which is a typedef around a struct
that's used to support a slew of datatypes in a single type. The struct
contains a member "vt" that describes the datatype of the data that's
stored in the variant.  Based on the value of "vt", the actual data will
have a name corresponding to the type.

That's right. In the case of the datalog the type of the "vt" is
(VT_ARRAY | VT_I2), that is an array of 2-byte integers.

So, a possible chunk of code for checking the return from UploadDatalog
might look like this:

       VARIANT retVariant = UploadDatalog(From, Size);
       if (retVariant.boolVal == VARIANT_TRUE)
       {
           // it worked!
       }
       else
       {
           // it failed!
       }

Anyway, I hope this helps.

Thank you very much, Steve. Your message was helpful for me to
understand I'm in the right way to the solution.

Anyway, I think I need to explain better what is my problem.
I _successfully_ upload the datalog from the RCX into a VARIANT
variable, but I do not succeed in extracting the array of logged
values from that variable. I am surely doing something wrong with
the SafeArrayAccessData method.

Here follows the code I wrote to save the raw logged data in
the test.dat file:

//----------------------- cut here -----------------------------

VARIANT datalog;
short *loggedData;
CFile f;

f.Open( "test.dat", CFile::modeCreate | CFile::modeWrite);

VariantInit(&datalog);

datalog = m_ctrlego.UploadDatalog(1, 10);

if (datalog.vt == (VT_ARRAY | VT_I2))
{
   SafeArrayAccessData(datalog.parray, (void HUGEP* FAR*)&loggedData);
   SafeArrayUnaccessData(datalog.parray);
   f.Write(loggedData, datalog.parray->rgsabound->cElements);
}

f.Close();

//----------------------- cut here -----------------------------


The result is by far different from the datalog uploaded
using RCXcc, and I really can't understand why!


Bye,

      Antonio



Message has 1 Reply:
  Re: Spirit.ocx in VC++  [DAT]
 
Hi Steve, Len and All, I was closer to the solution than I thought! The code I posted this morning was correct. What I missed was the format of the datalog, which is very hard to understand from the docs of spirit.ocx. After hacking around for a (...) (25 years ago, 5-Mar-00, to lugnet.robotics)

Message is in Reply To:
  Re: Spirit.ocx in VC++
 
Antonio, Actually, the datatype is VARIANT, which is a typedef around a struct that's used to support a slew of datatypes in a single type. The struct contains a member "vt" that describes the datatype of the data that's stored in the variant. Based (...) (25 years ago, 5-Mar-00, to lugnet.robotics)

4 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR