For a project I have to send data to my mbed from my computer. I have a class where you can find those function :
void RFIDPc::Callback()
{
while(_cnt<_bufferlen)
{
_buff[_cnt] = pc1.getc();
_cnt++;
}
if (_cnt >= _bufferlen){
_available = 1;
}
}
int RFIDPc::Available()
{
if ( _available == 1 && ( _t.read_ms() > _waittime || _t.read_ms() < 0 ) )
{
retu 1;
}
retu 0;
}
void RFIDPc::ClearBuffer()
{
_t.reset();
_t.start();
_available = 0;
for (int i=0; i< _bufferlen ; i++)
{
_buff[i] = NULL;
}
_cnt = 0;
}
The callback function is used as an interruption.
pc1.attach(this ,&RFIDPc::Callback);
In my main file, I have this function :
void initRFID(char couleur[TAILLE])
{
while(!rfid.Available());
for(int i=0; i<=TAILLE-1; i++)
couleur[i] = buff[i];
rfid.ClearBuffer();
rfid.AfficherTrame(couleur);
wait(1);
}
"TAILLE" is defined as 4. The problem is that when in the initRFID function, it seems that my buffer isn't cleared. When I try to display the buffer I got this : Image
The first lines are the datas I send to my mbed. The two last lines are the displaying of the buffer. Any ideas ?
