Ejemplo n.º 1
0
WebIDBConnectionToServer::WebIDBConnectionToServer()
{
    relaxAdoptionRequirement();

    m_isOpenInServer = sendSync(Messages::DatabaseToWebProcessConnection::EstablishIDBConnectionToServer(), m_identifier);
    m_connectionToServer = IDBClient::IDBConnectionToServer::create(*this);
}
Ejemplo n.º 2
0
/*

  Send the corresponding wave signal based on the plug code and the action.

*/
void sendSequence(unsigned short plug_code, int action)
{
    /*
     Start the sequence
     Send House code + Switch code + ON/OFF code + Sync code
     */
     // Validate plug code is different than zero.
    if (plug_code) {
      printf("%hx\n", plug_code);
      unsigned short idx = 0x0400;
      // Check every bit of the code and send the correspondent signal. 
      // At the end, send the desired action, followed with the 
      // synchronization sequence.
      do {
        idx = idx>>1;
        if(plug_code & idx) {
          sendHigh();
        }
        else
        {
          sendLow();
        }
      } while(!(idx & 0x0001));
    
      if(action == TYPE_SWITCH_ON)
      {
        sendOn();
      }
      else
      {
        sendOff();
      }
      sendSync();
    }
}
Ejemplo n.º 3
0
static void slaveMode(void) {
    int fd = context->fd;
    unsigned long long payload = sendSync(fd);
    char buf[1024];

    fprintf(stderr,"SYNC with master, discarding %llu "
                   "bytes of bulk transfer...\n", payload);

    /* Discard the payload. */
    while(payload) {
        ssize_t nread;

        nread = read(fd,buf,(payload > sizeof(buf)) ? sizeof(buf) : payload);
        if (nread <= 0) {
            fprintf(stderr,"Error reading RDB payload while SYNCing\n");
            exit(1);
        }
        payload -= nread;
    }
    fprintf(stderr,"SYNC done. Logging commands from master.\n");

    /* Now we can use hiredis to read the incoming protocol. */
    config.output = OUTPUT_CSV;
    while (cliReadReply(0) == REDIS_OK);
}
Ejemplo n.º 4
0
template<typename U> bool NetworkResourceLoader::sendSyncAbortingOnFailure(const U& message, const typename U::Reply& reply)
{
    bool result = sendSync(message, reply);
    if (!result)
        abortInProgressLoad();
    return result;
}
void NetworkProcessProxy::sendProcessWillSuspendImminently()
{
    if (!canSendMessage())
        return;

    bool handled = false;
    sendSync(Messages::NetworkProcess::ProcessWillSuspendImminently(), Messages::NetworkProcess::ProcessWillSuspendImminently::Reply(handled), 0, std::chrono::seconds(1));
}
Ejemplo n.º 6
0
void AGOSEngine_PuzzlePack::opp_sync() {
	// 120: sync
	uint a = getVarOrWord();
	if (a == 8001 || a == 8101 || a == 8201 || a == 8301 || a == 8401) {
		_marks &= ~(1 << 2);
	}
	sendSync(a);
}
Ejemplo n.º 7
0
bool Download::shouldDecodeSourceDataOfMIMEType(const String& mimeType)
{
    bool result;
    if (!sendSync(Messages::DownloadProxy::ShouldDecodeSourceDataOfMIMEType(mimeType), Messages::DownloadProxy::ShouldDecodeSourceDataOfMIMEType::Reply(result)))
        return true;

    return result;
}
Ejemplo n.º 8
0
void AGOSEngine_Simon2::clearName() {
	if (getBitFlag(79)) {
		sendSync(202);
		_lastNameOn = NULL;
		return;
	}

	AGOSEngine_Simon1::clearName();
}
Ejemplo n.º 9
0
void WebProcessProxy::sendProcessWillSuspendImminently()
{
    if (!canSendMessage())
        return;

    bool handled = false;
    sendSync(Messages::WebProcess::ProcessWillSuspendImminently(), Messages::WebProcess::ProcessWillSuspendImminently::Reply(handled),
        0, std::chrono::seconds(1), IPC::InterruptWaitingIfSyncMessageArrives);
}
Ejemplo n.º 10
0
void Tx433_Nexa::sendPackets(String grp, String dev, String onoff) {
  for (int i = 0; i < RETRANSMIT; i++) {
	  sendSync();
	  sendCode(TxCode, TxCode.length());
	  sendCode(grp, grp.length());
	  sendCode(onoff, onoff.length());
	  sendCode(ChCode, ChCode.length());
	  sendCode(dev, dev.length());
	  sendPause();
  }
}
Ejemplo n.º 11
0
String Download::retrieveDestinationWithSuggestedFilename(const String& filename, bool& allowOverwrite)
{
    String destination;
    SandboxExtension::Handle sandboxExtensionHandle;
    if (!sendSync(Messages::DownloadProxy::DecideDestinationWithSuggestedFilename(filename), Messages::DownloadProxy::DecideDestinationWithSuggestedFilename::Reply(destination, allowOverwrite, sandboxExtensionHandle)))
        return String();

    m_sandboxExtension = SandboxExtension::create(sandboxExtensionHandle);
    if (m_sandboxExtension)
        m_sandboxExtension->consume();

    return destination;
}
Ejemplo n.º 12
0
/*
#define	SYNC	13
#define SDA 	7
#define	SCL 	6

void sendBit(uint8_t);
void sendByte(uint8_t);
void sendSync(void);
void sendStart(void);
uint8_t test9bit(void);
*/
int main(void){

	init();

/*
	pinMode(SYNC, OUTPUT);
	pinMode(SDA, INPUT);
	pinMode(SCL, OUTPUT);
*/

	Serial.begin(9600);

	PCF8574_LCD lcd;

	//lcd.begin();

	digitalWrite(SDA, HIGH);
	digitalWrite(SCL, HIGH);
	while(1){

		sendSync();
/*
		pinMode(SDA, OUTPUT);

		sendStart();

		sendByte(0x40);

		err = test9bit();

		if(err == true){
			pinMode(SDA, OUTPUT);
			sendStart();
			sendByte(0xAA);
			err = test9bit();
		}

*/
		lcd.write((uint8_t)0xAA);
		//Serial.println("1");
		delay(20);
	}

	Serial.print("AAAA\n");

	lcd.print(0x23);

	while(1);

	return 0;
}
Ejemplo n.º 13
0
  void deviceManager() {
    // todo: init, recover... (e.g. when to start/stop sending SYNCs)
    while (true) {
      auto tic = std::chrono::high_resolution_clock::now();
      for (auto device : devices) {
	if (device.second.initialized) {
	  devices[device.first].updateDesiredPos();
	  sendPos(device.second.CANid_, device.second.desiredPos_);
	}
      }
      sendSync();
      std::this_thread::sleep_for(syncInterval - (std::chrono::high_resolution_clock::now() - tic ));
    }
  }
Ejemplo n.º 14
0
void AGOSEngine_Feeble::inventoryDown(WindowBlock *window) {
	_marks = 0;
	checkDown(window);
	animate(4, 9, 23, 0, 0, 0);
	while (_currentBoxNum == 0x7FFC && getBitFlag(89)) {
		checkDown(window);
		delay(1);
	}
	waitForMark(2);
	checkDown(window);
	sendSync(924);
	waitForMark(1);
	checkDown(window);
}
Ejemplo n.º 15
0
/* This function implements --rdb, so it uses the replication protocol in order
 * to fetch the RDB file from a remote server. */
static void getRDB(void) {
    int s = context->fd;
    int fd;
    unsigned long long payload = sendSync(s);
    char buf[4096];

    fprintf(stderr,"SYNC sent to master, writing %llu bytes to '%s'\n",
        payload, config.rdb_filename);

    /* Write to file. */
    if (!strcmp(config.rdb_filename,"-")) {
        fd = STDOUT_FILENO;
    } else {
        fd = open(config.rdb_filename, O_CREAT|O_WRONLY, 0644);
        if (fd == -1) {
            fprintf(stderr, "Error opening '%s': %s\n", config.rdb_filename,
                strerror(errno));
            exit(1);
        }
    }

    while(payload) {
        ssize_t nread, nwritten;
        
        nread = read(s,buf,(payload > sizeof(buf)) ? sizeof(buf) : payload);
        if (nread <= 0) {
            fprintf(stderr,"I/O Error reading RDB payload from socket\n");
            exit(1);
        }
        nwritten = write(fd, buf, nread);
        if (nwritten != nread) {
            fprintf(stderr,"Error writing data to file: %s\n",
                strerror(errno));
            exit(1);
        }
        payload -= nread;
    }
    close(s); /* Close the file descriptor ASAP as fsync() may take time. */
    fsync(fd);
    fprintf(stderr,"Transfer finished with success.\n");
    exit(0);
}
Ejemplo n.º 16
0
 ErrorType UccSession::sendSync (IMessageType const & messageRq, IMessageType & messageRs)
 {
   return setError(sendSync(messageRq, messageRs,getTimeoutDefault()));
 }
Ejemplo n.º 17
0
void AGOSEngine::o_sync() {
	// 120: sync
	sendSync(getVarOrWord());
}