예제 #1
0
bool EasyVR::getNextWordLabel(char* name)
{
  int8_t count;
  if (!recvArg(count, DEF_TIMEOUT))
    return false;
  if (count == -1)
    count = 32;
  
  for ( ; count > 0; --count, ++name)
  {
    int8_t rx;
    if (!recvArg(rx, DEF_TIMEOUT))
      return false;
    
    if (rx == '^' - ARG_ZERO)
    {
      if (!recvArg(rx, DEF_TIMEOUT))
        return false;
      
      *name = '0' + rx;
      --count;
    }
    else
    {
      *name = ARG_ZERO + rx;
    }
  }
  *name = 0;
  return true;
}
// ============================================================================
// RCwrtRegistryClientSession::getAttributeL()
// Returns the attribute value for the widget
//
// ============================================================================
EXPORT_C QVariant RWACRegistryClientSession::getAttributeL( const QString& appId,
                                                           const QString& attribute,
                                                           const QVariant& defaultValue )
    {
    const TInt maxSize = 5120;

    CBufFlat* sendBuf = CBufFlat::NewL( maxSize );
    CleanupStack::PushL( sendBuf );
    RBufWriteStream stream( *sendBuf );
    CleanupClosePushL( stream );
    SerializeStringL( stream, appId );
    SerializeStringL( stream, attribute );
    SerializeStringL( stream, defaultValue.toString() );
    CleanupStack::PopAndDestroy( &stream );

    CBufFlat* recvBuf = CBufFlat::NewL( maxSize );
    CleanupStack::PushL( recvBuf );
    recvBuf->ExpandL( 0, maxSize );

    TPtr8 sendArg( sendBuf->Ptr(0) );
    TPtr8 recvArg( recvBuf->Ptr(0) );

    User::LeaveIfError(
            SendReceive( EOpCodeGetWebAttribute, TIpcArgs( &sendArg, &recvArg ) )
            );

    // deserialize
    RDesReadStream rstream( recvArg );
    CleanupClosePushL( rstream );
    QString attrValue = DeserializeStringL( rstream );
    CleanupStack::PopAndDestroy( 3, sendBuf ); // rstream, recvBuf, sendBuf

    return ( QVariant( attrValue ) );
    }
예제 #3
0
bool EasyVR::dumpCommand(int8_t group, int8_t index, char* name, uint8_t& training)
{
  sendCmd(CMD_DUMP_SD);
  sendGroup(group);
  sendArg(index);

  if (recv(DEF_TIMEOUT) != STS_DATA)
    return false;
  
  int8_t rx;
  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  training = rx & 0x07;
  if (rx == -1 || training == 7)
    training = 0;
  
  _status.v = 0;
  _status.b._conflict = (rx & 0x18) != 0;
  _status.b._command = (rx & 0x08) != 0;
  _status.b._builtin = (rx & 0x10) != 0;
  
  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  _value = rx;

  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  int8_t len = rx == -1 ? 32 : rx;
  for ( ; len > 0; --len, ++name)
  {
    if (!recvArg(rx, DEF_TIMEOUT))
      return false;
    if (rx == '^' - ARG_ZERO)
    {
      if (!recvArg(rx, DEF_TIMEOUT))
        return false;
      *name = '0' + rx;
      --len;
    }
    else
    {
      *name = ARG_ZERO + rx;
    }
  }
  *name = 0;
  return true;
}
예제 #4
0
bool EasyVR::dumpGrammar(int8_t grammar, uint8_t& flags, uint8_t& count)
{
  sendCmd(CMD_DUMP_SI);
  sendArg(grammar);

  if (recv(DEF_TIMEOUT) != STS_GRAMMAR)
    return false;
  
  int8_t rx;
  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  flags = rx == -1 ? 32 : rx;
  
  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  count = rx;
  return true;
}
예제 #5
0
int8_t EasyVR::getID()
{
  sendCmd(CMD_ID);
  if (recv(DEF_TIMEOUT) == STS_ID)
  {
    int8_t rx;
    if (recvArg(rx, DEF_TIMEOUT))
      return rx;
  }
  return -1;
}
예제 #6
0
bool EasyVR::getGroupMask(uint32_t& mask)
{
  sendCmd(CMD_MASK_SD);

  if (recv(DEF_TIMEOUT) == STS_MASK)
  {
    int8_t rx;
    for (int8_t i = 0; i < 4; ++i)
    {
      if (!recvArg(rx, DEF_TIMEOUT))
        return false;
      ((uint8_t*)&mask)[i] |= rx & 0x0F;
      if (!recvArg(rx, DEF_TIMEOUT))
        return false;
      ((uint8_t*)&mask)[i] |= (rx << 4) & 0xF0;
    }
    return true;
  }
  return false;
}
예제 #7
0
int8_t EasyVR::getID()
{
  sendCmd(CMD_ID);
  if (recv(DEF_TIMEOUT) == STS_ID)
  {
    if (recvArg(_id))
      return _id;
  }
  _id = -1;
  return _id;
}
예제 #8
0
int8_t EasyVR::getPinInput(int8_t pin, int8_t config)
{
  sendCmd(CMD_QUERY_IO);
  sendArg(pin);
  sendArg(config);

  if (recv(DEF_TIMEOUT) == STS_PIN)
  {
    int8_t rx;
    if (recvArg(rx, DEF_TIMEOUT))
      return rx;
  }
  return -1;
}
예제 #9
0
bool EasyVR::dumpSoundTable(char* name, int16_t& count)
{
  sendCmd(CMD_DUMP_SX);

  if (recv(DEF_TIMEOUT) != STS_TABLE_SX)
    return false;
  
  int8_t rx;
  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  count = rx << 5;
  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  count |= rx;
  
  if (!recvArg(rx, DEF_TIMEOUT))
    return false;
  int len = rx;
  for (int8_t i = 0, k = 0; i < len; ++i, ++k)
  {
    if (!recvArg(rx, DEF_TIMEOUT))
      return false;
    if (rx == '^' - ARG_ZERO)
    {
      if (!recvArg(rx, DEF_TIMEOUT))
        return false;
      ++i;
      name[k] = '0' + rx;
    }
    else
    {
      name[k] = ARG_ZERO + rx;
    }
  }
  name[len] = 0;
  return true;
}
예제 #10
0
bool EasyVR::dumpMessage(int8_t index, int8_t& type, int32_t& length)
{
  sendCmd(CMD_DUMP_RP);
  sendArg(-1);
  sendArg(index);

  int sts = recv(STORAGE_TIMEOUT);
  if (sts != STS_MESSAGE)
  {
    readStatus(sts);
    return false;
  }

  // if communication should fail
  _status.v = 0;
  _status.b._error = true;

  if (!recvArg(type))
    return false;

  int8_t rx;
  length = 0;
  if (type == 0)
    return true; // skip reading if empty

  for (int8_t i = 0; i < 6; ++i)
  {
    if (!recvArg(rx))
      return false;
    ((uint8_t*)&length)[i] |= rx & 0x0F;
    if (!recvArg(rx))
      return false;
    ((uint8_t*)&length)[i] |= (rx << 4) & 0xF0;
  }
  _status.v = 0;
  return true;
}
예제 #11
0
int8_t EasyVR::getGrammarsCount(void)
{
  sendCmd(CMD_DUMP_SI);
  sendArg(-1);

  if (recv(DEF_TIMEOUT) == STS_COUNT)
  {
    int8_t rx;
    if (recvArg(rx, DEF_TIMEOUT))
    {
      return rx == -1 ? 32 : rx;
    }
  }
  return -1;
}
예제 #12
0
int8_t EasyVR::getCommandCount(int8_t group)
{
  sendCmd(CMD_COUNT_SD);
  sendArg(group);

  if (recv(DEF_TIMEOUT) == STS_COUNT)
  {
    int8_t rx;
    if (recvArg(rx, DEF_TIMEOUT))
    {
      return rx == -1 ? 32 : rx;
    }
  }
  return -1;
}
예제 #13
0
bool EasyVR::hasFinished()
{
  int8_t rx = recv(NO_TIMEOUT);
  if (rx < 0)
    return false;
  
  _status.v = 0;
  
  switch (rx)
  {
  case STS_SUCCESS:
    return true;
  
  case STS_SIMILAR:
    _status.b._builtin = true;
    goto GET_WORD_INDEX;

  case STS_RESULT:
    _status.b._command = true;
  
  GET_WORD_INDEX:
    if (recvArg(rx, DEF_TIMEOUT))
    {
      _value = rx;
      return true;
    }
    break;
    
  case STS_TOKEN:
    _status.b._token = true;
  
    if (recvArg(rx, DEF_TIMEOUT))
    {
      _value = rx << 5;
      if (recvArg(rx, DEF_TIMEOUT))
      {
        _value |= rx;
        return true;
      }
    }
    break;
    
  case STS_TIMEOUT:
    _status.b._timeout = true;
    return true;
    
  case STS_INVALID:
    _status.b._invalid = true;
    return true;
    
  case STS_ERROR:
    _status.b._error = true;
    if (recvArg(rx, DEF_TIMEOUT))
    {
      _value = rx << 4;
      if (recvArg(rx, DEF_TIMEOUT))
      {
        _value |= rx;
        return true;
      }
    }
    break;
  }

  // unexpected condition (communication error)
  _status.v = 0;
  _status.b._error = true;
  return true;
}
예제 #14
0
void EasyVR::readStatus(int8_t rx)
{
  _status.v = 0;
  _value = 0;
  
  switch (rx)
  {
  case STS_SUCCESS:
    return;
  
  case STS_SIMILAR:
    _status.b._builtin = true;
    goto GET_WORD_INDEX;

  case STS_RESULT:
    _status.b._command = true;
  
  GET_WORD_INDEX:
    if (recvArg(rx))
    {
      _value = rx;
      return;
    }
    break;
    
  case STS_TOKEN:
    _status.b._token = true;
  
    if (recvArg(rx))
    {
      _value = rx << 5;
      if (recvArg(rx))
      {
        _value |= rx;
        return;
      }
    }
    break;
    
  case STS_AWAKEN:
    _status.b._awakened = true;
    return;
    
  case STS_TIMEOUT:
    _status.b._timeout = true;
    return;
    
  case STS_INVALID:
    _status.b._invalid = true;
    return;
    
  case STS_ERROR:
    _status.b._error = true;
    if (recvArg(rx))
    {
      _value = rx << 4;
      if (recvArg(rx))
      {
        _value |= rx;
        return;
      }
    }
    break;
  }

  // unexpected condition (communication error)
  _status.v = 0;
  _status.b._error = true;
  _value = 0;
}