예제 #1
0
파일: rs.cpp 프로젝트: vcmman/librealsense
int rs_is_device_streaming(const rs_device * device, rs_error ** error) try
{
    VALIDATE_NOT_NULL(device);
    return device->is_capturing();
}
예제 #2
0
//handle our packets.
void process_host_packets()
{
  unsigned long start = millis();
  unsigned long end = start + PACKET_TIMEOUT;

#ifdef ENABLE_COMMS_DEBUG
    //Serial.print("IN: ");
#endif

  //do we have a finished packet?
  while (!hostPacket.isFinished())
  {
    if (Serial.available() > 0)
    {
      //digitalWrite(DEBUG_PIN, HIGH);

      //grab a byte and process it.
      byte d;
      d = Serial.read();
      hostPacket.process_byte(d);

#ifdef ENABLE_COMMS_DEBUG
      //Serial.print(d, HEX);
      //Serial.print(" ");
#endif
      serial_rx_count++;

      //keep us goign while we have data coming in.
      start = millis();
      end = start + PACKET_TIMEOUT;

      if (hostPacket.getResponseCode() == RC_CRC_MISMATCH)
      {
        //host_crc_errors++;
	digitalWrite(DEBUG_PIN, HIGH);

#ifdef ENABLE_COMMS_DEBUG
        Serial.println("Host CRC Mismatch");
#endif
      }
    }

    //are we sure we wanna break mid-packet?
    //have we timed out?
    if (millis() >= end)
    {
#ifdef ENABLE_COMMS_DEBUG
      Serial.println("Host timeout");
#endif
      break;  
    }
  }

  if (hostPacket.isFinished())
  {
    serial_packet_count++;

    byte b = hostPacket.get_8(0);
    // top bit high == bufferable command packet (eg. #128-255)
    if (b & 0x80)
    {
      if (is_capturing()) {
	// Capture this to the SD card
	capture_packet(hostPacket);
      } else {
	//do we have room?
	if (commandBuffer.remainingCapacity() >= hostPacket.getLength()) {
	  //okay, throw it in the buffer.
	  for (byte i=0; i<hostPacket.getLength(); i++)
	    commandBuffer.append(hostPacket.get_8(i));
	} else {
	  // Otherwise, we go on with an overflow packet.
	  hostPacket.overflow();
	}
      }
    }
    // top bit low == reply needed query packet (eg. #0-127)
    else
      handle_query(b);
  }

  //okay, send our response
  hostPacket.sendReply();
}
예제 #3
0
void CameraController::set_capture_mode(const capture_mode_t &the_mode)
{
    m_impl->m_capture_mode = the_mode;
    if(is_capturing()){ start_capture(); }
}