OK. Those symbols should be visible if:
a) You are running a debug build of the project with debug symbols (the default)
b) You are stepping in the debugger within the scope of the function where those symbols are defined
(getSentence).
In a release build, optimizations and such make the debugging act strangely and many symbols aren't
visible while trying to debug.
In VC++6.0, I believe the menu item under "Project" was called "Settings". It is "Properties" in
the .NET version of the IDE.
Some example code would be helpful to us.
At line after the comment
//CXX0017
the variables bytesRead and workingBufIndex are listed in watch1 as
not found. Perhaps because they are static?
Thanks,
jh
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// debug version of getSentence
//
#include <stdafx.h>
#include <iostream>
extern "C"
{
//#include "hidsdi.h"
}
using namespace std;
//int readPuck(char* buffer, int timeout, int = 10);
const char START_SENTINEL = '$';
const char STOP_SENTINEL = '@';
char newBuf[34]; //Make new when instantiating, size of input report
size +1
char workingBuf[34];
// Simple overview: Search input from puck till $ is found, copy it
and following characters until
// newline \n is found. GPS sentence is nulled terminated and placed
at *outString.
void
getSentence(char* outString)
{
static int workingBufIndex; //Where we stopped scanning when we got a
\n.
static int bytesRead = 0; //How many bytes fn readPuck read, must
persist between calls.
static bool firstTime = true;
char* pc = outString;
// First time thru.
if(firstTime == true)
{
firstTime = false;
workingBufIndex = 0;
//Get a bufferful of data from device.
//if(!(bytesRead = readPuck(workingBuf, 100)))
{
//####Got an error, scream, shout, and dash about.
//####Return an error code of some sort.
}
}
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// At this point should be pointing at workingBuf at the point of the
// terminating \n or at its beginning if this is first time thru this
function.
// If at the end of workingBuf (workingBufIndex == bytesRead), read
new data in
// from device.
// Start where left off in last buffer and throw away anything but a
$. If the
// buffer end is reached before a $ is found the device should be
read again.
// When $ is found copy it then move to a copy loop.
//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Look for start sentinel in the current buffer. If at end of
buffer, read the
// puck again.
bool startSentinelFound = false;
while(startSentinelFound == false) //#### && haven't been looking too
long.
{
// First check for end of buffer and read input buffer (newBuf) if
necessary.
cout << "wbi: " << workingBufIndex << " bytesRead: " << bytesRead <<
endl;
//CXX0017
if(workingBufIndex == bytesRead) // At end of buffer from previous
loop or
{ // sentinel search above.
//Read newBuf until it has fresh data, not same as already in
workingBuf.
workingBufIndex = 0; //Reset to beginning , fetching a new
bufferful.
bool same = true;
while(same == true) //###?limit time allowed for searching for new
data.
{
// Read a bufferful of new characters into newBuf and make sure it
is not
// the same as what is already in workingBuf. Go ahead and copy
in
// the process of checking as it doesn't hurt.
//bytesRead = readPuck(newBuf, 100);
for(int i = 0; i < bytesRead; i++)
{
if(workingBuf[i] != newBuf[i]) same = false;
workingBuf[i] = newBuf[i];
}
}
}// Finished getting newBuf and copying into workingBuf, and it is
new data.
//Look for start sentinel
if(workingBuf[workingBufIndex++] == START_SENTINEL)
{
*(pc++) = START_SENTINEL;
startSentinelFound = true;
}
} // End of while(startSentinelFound == false) -- Finally made our
first buck.
}