コード例 #1
0
ファイル: protocol_t1.c プロジェクト: timoRo/oscam-stable
static int32_t Protocol_T1_ReceiveBlock (struct s_reader *reader, T1_Block ** block)
{
  BYTE buffer[T1_BLOCK_MAX_SIZE];
  int32_t ret;

  /* Receive four mandatory bytes */
  if (ICC_Async_Receive (reader, 4, buffer))
      ret = ERROR;
  else
      if (buffer[2] != 0x00) {
          /* Set timings to read the remaining block */
          ICC_Async_SetTimings (reader, reader->CWT);

          /* Receive remaining bytes */
          if (ICC_Async_Receive (reader, buffer[2], buffer + 4))
              ret = ERROR;
          else {
              (*block) = T1_Block_New (buffer, buffer[2] + 4);
              ret = OK;
            }
          /* Restore timings */
          ICC_Async_SetTimings (reader, reader->BWT);
        }
      else {
          ret = OK;
          (*block) = T1_Block_New (buffer, 4);
        }

	if (ret == ERROR)
		(*block) = NULL;
  return ret;
}
コード例 #2
0
ファイル: protocol_t1.c プロジェクト: bowman-gh/oscam
static int32_t Protocol_T1_ReceiveBlock(struct s_reader *reader, uint8_t *block_data, uint32_t *block_length, uint8_t *rsp_type) {
	int32_t ret, length;
	
	/* Receive four mandatory bytes */
	if (ICC_Async_Receive (reader, 4, block_data, 0, reader->read_timeout))
		ret = ERROR;
	else {
		length = block_data[2];
		if (length != 0x00) {
			*block_length = (length + 4 > T1_BLOCK_MAX_SIZE) ? T1_BLOCK_MAX_SIZE : length + 4;

			/* Receive remaining bytes */
			if (ICC_Async_Receive(reader, *block_length - 4, block_data + 4, 0, reader->read_timeout))
				ret = ERROR;
			else
				ret = OK;
		} else {
			ret = OK;
			*block_length = 4;
		}
	}
	*rsp_type = ((block_data[1] & 0x80) == T1_BLOCK_I) ? T1_BLOCK_I : (block_data[1] & 0xEF);

	return ret;
}