This is perhaps quite a simple one for some of you.

I was looking at the following serial read function and I can't quite comprehend what &prefix[2] does here. Does it mean only two bytes can be filled or something else ?

I should also mention this is part of the player/stage platform.

while (1)
{
  cnt = 0;
  while (cnt != 1)
  {
    if ((cnt += read(fd, &prefix[2], 1)) < 0)
    {
      perror("Error reading packet header from robot connection: P2OSPacket():Receive():read():");
      return (1);
    }
  }

  if (prefix[0] == 0xFA && prefix[1] == 0xFB)
  {
    break;
  }

  GlobalTime->GetTimeDouble(&timestamp);

  prefix[0] = prefix[1];
  prefix[1] = prefix[2];

}

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top