storing TWI input in a char[]

Hi,

My arduino is recieving some data from a wiimote over TWI. I have the arduino capture about 190 bytes, then the arduino transmits those back to my PC over a serial connection. Currently I am storing the data in an uint8_t array and transmitting them over serial with Serial.print (storebuf~~,DEC). That works fine and minicom reads the data fine. ~~
What I would like to do is store the data in a character array. That way I could put in some spaces are commas between the data. Right now I don’t know where one set of receiveevents starts/stops. So I wanted to insert a comma. The problem is when I store the data in a char array and send it back to my pc with Serial.print (storebuf~~), I get strange characters instead of the numbers. So it looks like my numbers from Wire.recieve don’t like to be translated into characters.
Any thoughts on how I can store this as character data and have it transmit back over serial in a readable format?
thanks
chad
Here is part of my code:
uint8_t storebuf[200];
int cnt = 0;
void
receiveEvent (int howMany)
{
while (Wire.available ())
{
int c = Wire.receive (); // receive byte as a character~~
~~ storebuf[cnt] = c;
cnt++;
if (cnt > 100)
{
print ();
}
}
}
void
print ()
{
int s = 0;
Serial.println (“start data dump”);
while (s < (cnt - 1))
{
Serial.print (storebuf
,DEC);
s++;
}
Serial.println (“end data dump”);
cnt = 0;
}
Here is what I tried, but sent back bad characters. Only the comma would print correctly:
char storebuf[200];
int cnt = 0;
void
receiveEvent (int howMany)
{
while (Wire.available ())
{
char c = Wire.receive (); // receive byte as a character~~
~~ storebuf[cnt] = c;
cnt++;
if (cnt > 100)
{
print ();
}
}
storebuf[cnt] = ‘,’; // Add in a comma~~
~~ cnt++;
}
void
print ()
{
int s = 0;
Serial.println (“start data dump”);
while (s < (cnt - 1))
{
Serial.print (storebuf
);
s++;
}
Serial.println (“end data dump”);
cnt = 0;
}~~

The problem is that you want to store two different kinds of data in your array: bytes received over TWI and something else as a delimiter. Assuming that you could get any byte from the wiimote, there's no way to distinguish the delimiter (since it could have come from the wiimote) if you store everything in the same array. You have a few options. One is to send the data to the computer after each event, and just print a comma directly. Another is to keep track, in a separate array, the number of bytes or the ending bytes of the data received with each event. Another is to use an int array and make your delimiter something that doesn't fit in a byte (i.e. a number bigger than 255) - then when you go to print them out, you can add an if that prints anything less than 256 as a DEC, but if it sees anything greater prints a comma. Does that make sense?