コード例 #1
0
ファイル: optestutilities.c プロジェクト: rhardman/C4
C4Err compareResults(const void* expected, const void* calculated, size_t len,
                        DumpFormatType format, char* comment  )
{
    C4Err err = kC4Err_NoErr;
    
    err = CMP(expected, calculated, len)
    ? kC4Err_NoErr : kC4Err_SelfTestFailed;
    
    if( (err != kC4Err_NoErr)  && IsntNull(comment) && (format != kResultFormat_None))
    {
        OPTESTLogError( "\n\t\tFAILED %s\n",comment );
        switch(format)
        {
            case kResultFormat_Byte:
                OPTESTLogError( "\t\texpected:\n");
                dumpHex(IF_LOG_ERROR, ( uint8_t*) expected, (int)len, 0);
                OPTESTLogError( "\t\tcalulated:\n");
                dumpHex(IF_LOG_ERROR,( uint8_t*) calculated, (int)len, 0);
                OPTESTLogError( "\n");
                break;
                
            case kResultFormat_Long:
                OPTESTLogError( "\t\texpected:\n");
                dump64(IF_LOG_ERROR,( uint8_t*) expected, len);
                OPTESTLogError( "\t\tcalulated:\n");
                dump64(IF_LOG_ERROR,( uint8_t*) calculated, len );
                OPTESTLogError( "\n");
                break;
                
            case kResultFormat_Cstr:
                OPTESTLogError( "\t\texpected:\n");
                dump8(IF_LOG_ERROR,( uint8_t*) expected, len);
                OPTESTLogError( "\t\tcalulated:\n");
                dump8(IF_LOG_ERROR,( uint8_t*) calculated, len );
                OPTESTLogError( "\n");
                break;
               
                
            default:
                break;
        }
    }
    
    return err;
}
コード例 #2
0
ファイル: ox_debug_i2c.cpp プロジェクト: atu-guda/stm32ox
int cmd_i2c_recv_r2( int argc, const char * const * argv )
{
  if( argc < 2 ) {
    pr( "** ERR: reg required" NL );
    return -1;
  }
  uint8_t addr = (uint8_t)(user_vars['p'-'a']);
  uint16_t reg  = (uint8_t) strtol( argv[1], 0, 0 );
  uint16_t n = 1;
  uint8_t val = 0;

  if( argc > 2 ) {
    char *eptr;
    long l = strtol( argv[2], &eptr, 0 );
    if( eptr != argv[2] ) {
      n = (uint16_t)( l );
    }
    if( n > sizeof(gbuf_a) ) {
      n = sizeof(gbuf_a);
    }
  }

  pr( NL "I2C recv r2 from  " );
  pr_h( addr ); pr( ":" ); pr_h( reg ); pr( " n= " ); pr_d( n );

  i2c_dbg.init();

  int r = i2c_dbg.recv_reg2( addr, reg, (uint8_t*)(gbuf_a), n );
  pr_sdx( r );
  if( n == 1 ) {
    pr_h( val );
  } else {
    dump8( gbuf_a, n );
  }
  pr( NL );
  i2c_print_status( i2c_dbg );

  return 0;
}
コード例 #3
0
ファイル: ox_debug_i2c.cpp プロジェクト: atu-guda/stm32ox
int cmd_i2c_recv( int argc, const char * const * argv )
{
  // uint8_t v = 0;
  uint8_t addr = (uint8_t)(user_vars['p'-'a']);
  long l;
  int r, nr = 1;
  char *eptr;

  if( argc > 1 ) {
    l = strtol( argv[1], &eptr, 0 );
    if( eptr != argv[1] ) {
      addr = (uint8_t)(l);
    }
  }

  if( argc > 2 ) {
    l = strtol( argv[2], &eptr, 0 );
    if( eptr != argv[2] ) {
      nr = l;
    }
  }

  pr( NL "I2C Recv from " );  pr_h( addr );

  i2c_dbg.init();

  if( nr < 2 ) {
    r = i2c_dbg.recv( addr );
  } else {
    r = i2c_dbg.recv( addr, (uint8_t*)(gbuf_a), nr );
    dump8( gbuf_a, nr );
  }
  pr( "  Recv Result = " ); pr_d( r );
  pr( " 0x" ); pr_h( r ); pr( NL );

  i2c_print_status( i2c_dbg );

  return 0;
}