/**
 * gain: 0-221 (0=inf, 221=20db, 201=10db, 181=0db, 161=-10db, 141=-20db, 121=-30db, 101=-40db, 21=-80db)
 */
void ClientDbxZonePro::setInputGain(uint8_t b0, uint8_t b1, uint16_t gain) {
	_resetBuffer();

	_insertMsgId(0x0100);	// Set Command
	_insertObjectId(b0, b1, 0x01, 0x01);

	_insertSVID(0x0000);	
	_insertDataType(3);
	_insertData(gain);

	_sendBuffer();
}
/**
 * Read from client buffer
 */
void ClientSonyDeckControlUDP::_readFromClient() {

  // Read from Serial Port 1:
  while (_Udp.available()) {
      uint8_t inputValBuf[2];
	  
      uint8_t inputVal;
  	_Udp.read(inputValBuf, 1);
	inputVal = inputValBuf[0];

 /*   if (_serialOutput)
      Serial.println(inputVal,HEX);
*/
    if (_bufferWriteIndex < _binBufferSize) {
      _binarybuffer[_bufferWriteIndex] = inputVal;

      if (_bufferWriteIndex == 0) {                                       // start of session... init it
        _binarybufferCheckSum = 0;                                        // Reset checksum register
        _binarybufferExpectedLength = (_binarybuffer[0] & B00001111) + 2; // Get length of the packet
      }
      // If the pointer is equal to the expected length it means we have just read the checksum byte, so lets evaluate that:
      if (_bufferWriteIndex == _binarybufferExpectedLength) {
        if (_binarybufferCheckSum == _binarybuffer[_bufferWriteIndex]) {
          _bufferWriteIndex++;
          _parselineDispatch();
          _resetLastIncomingMsg();
          _resetBuffer();
        } else {
          if (_serialOutput)
            Serial.println(F("Bad checksum"));
          delay(5); // Let more data arrive, so we can flush it.
          while (_Udp.available()) {
            _Udp.read();
          }
        }
        _bufferWriteIndex = 0;
        _pendingAnswer = false;
      } else {
        // If we are not at the end (checksum byte), we continously calculate the checksum:
        _binarybufferCheckSum += _binarybuffer[_bufferWriteIndex];
        _bufferWriteIndex++;
      }
    } else {
      if (_serialOutput)
        Serial.println(F("ERROR: Buffer overflow."));
      delay(5); // Let more data arrive, so we can flush it.
      while (_Udp.available()) {
        _Udp.read();
      }
      _pendingAnswer = false;
    }
  }
}
/**
 * Setting output master volume
 * level: 0-221 (0=inf, 221=20db, 201=10db, 181=0db, 161=-10db, 141=-20db, 121=-30db, 101=-40db, 21=-80db)
 */
void ClientDbxZonePro::setOutputMaster(uint8_t b0, uint8_t b1, uint16_t level) {
	_resetBuffer();

	_insertMsgId(0x0100);	// Set Command
	//_insertFlags(0x0400);	
	_insertObjectId(b0, b1, 0x05, 0x01);

	_insertSVID(0x000c);	// Master is SV_ID 12 on a ZonePro 1260m
	_insertDataType(3);
	_insertData(level);

	_sendBuffer();
}
/**
 * Setting volume on a given input for the output
 * input = 1-12
 * level: 0-415 (0=inf, 415=20db, 315=10dB, 215=0db, 115=-10db)
 */
void ClientDbxZonePro::setOutputMix(uint8_t b0, uint8_t b1, uint8_t input, uint16_t level) {
	_resetBuffer();

	_insertMsgId(0x0100);	// Set Command
	//_insertFlags(0x0400);	
	_insertObjectId(b0, b1, 0x05, 0x01);

	_insertSVID(0x0000+(input-1));	
	_insertDataType(3);
	_insertData(level);

	_sendBuffer();
}
/**
 * Setting output master mute
 */
void ClientDbxZonePro::setOutputMute(uint8_t b0, uint8_t b1, bool mute) {
	_resetBuffer();

	_insertMsgId(0x0100);	// Set Command
	//_insertFlags(0x0400);	
	_insertObjectId(b0, b1, 0x05, 0x01);

	_insertSVID(0x000d);	
	_insertDataType(1);
	_insertData(mute?1:0);

	_sendBuffer();
}
示例#6
0
void DataOStream::_flush()
{
    EQASSERT( _enabled );
    if( !_connections.empty( ))
    {
        void* ptr = _buffer.getData() + _bufferStart;
        const uint64_t size = _buffer.getSize() - _bufferStart;

        _compressorState = STATE_UNCOMPRESSED;
        _compress( ptr, size, STATE_PARTIAL );
        sendData( ptr, size, false );
    }
    _dataSent = true;
    _resetBuffer();
}
/**
 * Read from client buffer. (Overloading from superclass)
 */
void ClientDbxZonePro::_readFromClient()	{
	// When we enter here we expect to read a full package at a time, so we reset buffer:
	_resetBuffer();
	uint16_t len = 0;
	bool overflow = false;
	
	while (_client.available()) {
		if (_bufferWriteIndex<_binBufferSize)	{
			_binarybuffer[_bufferWriteIndex++] = _client.read();
		} else {	// Overflow. Only theoretical because we should at some point reach "21" for the headersize, see below.
			overflow = true;
			_client.read();
			_bufferWriteIndex++; 
		}
		
		if (_bufferWriteIndex==21)	{	// Header has been retrieved completely. Subprocess this:
			if (_binarybuffer[1] || _binarybuffer[2])	{
				// Error, we don't have that large a buffer!
				if (_serialOutput)	Serial.println(F("ERROR: Too large package."));
			}
			len = (_binarybuffer[3]<<8) | _binarybuffer[4];
			
			_processPayload(len-_bufferWriteIndex);

			_resetBuffer();
			len = 0;
			overflow = false;
		}
		
		if (overflow)	{
			Serial.print(F("ERROR: Buffer overflow: Package was "));
			Serial.print(len);
			Serial.println(F(" bytes."));
		}
	}
}
/**
 * Read from client buffer
 */
void SkaarhojSerialClient::_readFromClient()	{
	while (_HardSerial.available()) {
		char c = _HardSerial.read();

		if (c==_EOLChar)	{	// Line feed, always used
			_parselineDispatch();
			_resetLastIncomingMsg();
			_resetBuffer();
		} else if (c==_EOTChar)	{	// Prompt 
			if (_serialOutput>1)	Serial.println(F("EOT received..."));
			_initialize();
			_resetLastIncomingMsg();
			_resetBuffer();
			_pendingEOT = false;
		} else if (c==13 || c==10)	{	// <CR> and <LF> ignored (they should be captured as _EOLChar if necessary)
			// Ignore.
		} else if (_bufferWriteIndex < _bufferSize-1)	{	// one byte for null termination reserved
			_buffer[_bufferWriteIndex] = c;
			_bufferWriteIndex++;
		} else {
			if (_serialOutput)	Serial.println(F("ERROR: Buffer overflow."));
		}
	}
}
示例#9
0
void ClientBMDVideohubTCP::routeInputToOutput(uint8_t input, uint8_t output, bool waitForConfirmedChange) {
  _resetBuffer();
  _addToBuffer_P(PSTR("VIDEO OUTPUT ROUTING:\n"));
  _addToBuffer(String(output - 1));
  _addToBuffer_P(PSTR(" "));
  _addToBuffer(String(input - 1));
  _addToBuffer_P(PSTR("\n\n"));
  _sendBuffer();
  
  if (waitForConfirmedChange)	{
	  unsigned long timer = millis();
	  while(_outputRouting[output - 1] != input-1 && millis()-500 < timer)	{	// 500 ms timeout if route is not set...
		  runLoop();
	  }
  }
}
示例#10
0
void App::init()
{
	static std::once_flag flag;
	std::call_once(flag, [this]()
	{
		assert(cudaGLSetGLDevice(0) == cudaSuccess);
		assert(SDL_Init(SDL_INIT_VIDEO) == 0);

		_window = SDL_CreateWindow("SPH DEMOSCENE", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
			_width, _height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
		assert(_window != nullptr);
		_context = SDL_GL_CreateContext(_window);
		glewInit();
		glGenBuffers(1, &_glPixelBuffer);
		_resetBuffer();
	});
	assert(cudaGraphicsGLRegisterBuffer(&_cudaGr, _glPixelBuffer, cudaGraphicsMapFlagsWriteDiscard) == cudaSuccess);
}
/**
 * Subscribes to a given object (shift+ctrl+o when you have selected an object in the ZonePro Program Screen - there you will see values for b0-b3)
 * Subscription means that the ZonePro will send you updates if the value is changed on the device.
 * Subscriptions DO NOT invoke a value message if you set the value yourself.
 */
void ClientDbxZonePro::_subscribe(uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) {
	_resetBuffer();

	_insertMsgId(0x0113);	// SubscribeAll
	_insertFlags(0x0400);	
	_insertObjectId(b0, b1, b2, b3);

	_binarybuffer[21] = highByte(_localNodeId);
	_binarybuffer[22] = lowByte(_localNodeId);
	_binarybuffer[23] = b3;
	_binarybuffer[24] = b2;
	_binarybuffer[25] = b1;
	_binarybuffer[26] = b0;
	_binarybuffer[27] = 0x01;
		
	_bufferWriteIndex=30;
	_sendBuffer();
}
示例#12
0
/**
 * Sends ping command. (Overloading from superclass)
 */
void ClientBMDVideohubTCP::_sendPing() {
  _resetBuffer();
  _addToBuffer_P(PSTR("PING:\n\n"));
  _sendBuffer();
}
示例#13
0
void DataOStream::reset()
{
    _resetBuffer();
}
/**
 * Sends ping command. (Overloading from superclass)
 */
void ClientKramerVSHDMIMatrix::_sendPing()	{
	_resetBuffer();
	_addToBuffer_P(PSTR("#\r"));
	_sendBuffer();
}