wrong output

hi i have this piece of code.

#include <SPI.h>

void pak_data();
void seriel_data_com();
int incomingByte = 0;

char data_tot[77];
char * dst1;
char data_fil[0xff];
char i=0;


void setup() {
  Serial.begin(9600);

}
void loop() {
  seriel_data_com();  
  pak_data(); 
  
  Serial.println(data_fil);
}
/**************************************************************/
void seriel_data_com()
{
  i=0;
  while(i<77)
  {
    if (Serial.available() > 0) 
    {  
      incomingByte = Serial.read();
      data_tot[i]=incomingByte;
      i++;

    }
  } 
i=0x00;
while (i<77)
{
Serial.print(data_tot[i]); //check whether I have received the right values
i++;
}




  
}
/************************************************************/
void pak_data()
{
  strcpy(data_fil,"&data=");
  dst1 = data_fil + strlen(data_fil);
  for (i = 0; i < 77; i++) {
    if (i > 0) {
      *(dst1++) = ',';
      delay (10);
    }
    dst1 += sprintf(dst1, "%d", data_tot[i]);
  }
  delay (100);   
}

kit receives this data string AA AA 00 01 01 00 01 90 42 01 9C 07 E4 FF FF FF FF FF FF FF FF FF FF 00 42 FF FF FF FF 09 36 FF FF FF FF 13 8A 05 E7 FF FF FF FF FF FF FF FF FF FF 00 00 9A 3A 00 00 1E C1 00 01 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 25 51

I check that it is received correctly :
22-03-2013 09:04:42.496 [TX] - AA AA 00 01 01 00 01 90 42 01 9C 07 E4 FF FF FF FF FF FF FF FF FF FF 00 42 FF FF FF FF 09 36 FF FF FF FF 13 8A 05 E7 FF FF FF FF FF FF FF FF FF FF 00 00 9A 3A 00 00 1E C1 00 01 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 25 51
22-03-2013 09:04:42.584 [RX] - AA AA 00 01 01 00 01 90 42 01 9C 07 E4 FF FF FF FF FF FF FF FF FF FF 00 42 FF FF FF FF 09 36 FF FF FF FF 13 8A 05 E7 FF FF FF FF FF FF FF FF FF FF 00 00 9A 3A 00 00 1E C1 00 01 00 00 00 00 FF FF 00 00 00 00 00 00 00 00 00 00 25 51

and it is received correctly
but when I then package it into a “file” data_fil things go wrong
22-03-2013 09:06:13.111 [RX] - &data=-86,-86,0,1,1,0,1,-112,66,1,-100,7,-28,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,66,-1,-1,-1,-1,9,54,-1,-1,-1,-1,19,-118,5,-25,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,-102,58,0,0,30,-63,0,1,0,0,0,0,-1,-1,0,0,0,0,0,0,0,0,0,0,37,81

where is the error

What error? It looks like you've got a simple misunderstanding of 2s complement numbers and sign-extension.

(int)0xFF = 0xFFFF 0xFFFF = -1

I’m sorry I do not quite understand what you are trying to teach me.

I expect that if I send 0xAA or 170 it’s what I pack into the “file” not -86

I expect that if I send 0xAA or 170 it's what I pack into the "file"

That's exactly what it does do. How you choose to interpret it is another matter - you could read groups of four bytes, and interpret them as a "float" if you so wished. If you write a value as, say an "unsigned char", but read it back as "int" what you have observed is what I expect, but the value in the file is unchanged and exactly what you wrote. The only problem occurs is if you write the values as ASCII representations of the numbers you're writing.

In pak_data(), you need to change the %d in the sprintf() string to a %02X.