static int cable_vpi_out ( const uint8_t value )
{
  send_one_byte( value );

  uint8_t ack;
  do
  {
    ack = receive_one_byte();

  } while(ack != (value | 0x10));

  cable_vpi_wait();  // finish the transaction

  return APP_ERR_NONE;
}
static int cable_vpi_inout ( const uint8_t value, uint8_t * const inval )
{
  // Ask the remote VPI/DPI server to send us the out-bit.
  send_one_byte( 0x80 );

  // Wait and read the data.
  const uint8_t data_in = receive_one_byte();

  if ( data_in > 1 )
    fprintf(stderr, "Unexpected value: %i\n", data_in );

  cable_vpi_out( value );

  *inval = data_in;

  // Finish the transaction.
  cable_vpi_wait();

  return APP_ERR_NONE;
}
Exemplo n.º 3
0
int cable_vpi_inout(uint8_t value, uint8_t *inval)
{
  uint8_t dat;

  /* ask vpi to send us the out-bit */
  dat = 0x80;
  send(vpi_comm, &dat, 1, 0);

  /* Wait and read the data */
  recv(vpi_comm, &dat, 1, 0);

  if(dat > 1)
    fprintf(stderr, "Unexpected value: %i\n", dat);

  cable_vpi_out(value);

  *inval = dat;

  cable_vpi_wait();  // finish the transaction

  return APP_ERR_NONE;
}
Exemplo n.º 4
0
int cable_vpi_out(uint8_t value)
{
  uint8_t ack;
  int ret;

  /* Send the data to the socket */
  ret = send(vpi_comm, &value, 1, 0);
  debug("Sent %d, ret %d\n", value, ret);

  do {
    /* Ok, read the data */
    ret = recv(vpi_comm, &ack, 1, 0);
    if(ret < 0) {
      printf("Error during receive (%s)\n", strerror(errno));
      return APP_ERR_CONNECT;
    }
  } while(ack != (value | 0x10));

  cable_vpi_wait();  // finish the transaction

  return APP_ERR_NONE;
}