Ejemplo n.º 1
0
Archivo: pc.c Proyecto: talkers/summink
void            tell_player(player * p, char *str)
{
   file            output;
   char           *oldstack, *script;
   oldstack = stack;
   if (((p->fd) < 0) || (p->flags & PANIC))
      return;
   if (!(sys_flags & PANIC))
      if (!test_receive(p))
	 return;
   output = process_output(p, str);
   if (p->script)
   {
      script = stack;
      sprintf(stack, "emergency/%s_emergency", p->lower_name);
      stack = end_string(stack);
      log(script, str);
      stack = script;
   }
   if (write(0, output.where, output.length) < 0)
   {
      p->flags |= PANIC;
      log("error", "PANIC trying to write to player.");
   }
   stack = oldstack;
}
Ejemplo n.º 2
0
void viewManager::sendBuffer()
{
	ofPixels pix;
	pix.allocate(buffer.getWidth(), buffer.getHeight(), 3);
	
	buffer.readToPixels(pix);
	unsigned char* raw = pix.getPixels();
	int numPix = pix.getWidth() * pix.getHeight();
	
	vector<unsigned char> sendBytes;
	sendBytes.clear();
	
	for (int i = 0;i < 3;i++)
	{
		int pxCnt = 0;
		int duplicated = 0;
		unsigned char current = raw[i];
	
		while (pxCnt < numPix) {
			
			if (raw[pxCnt * 3 + i] == current)
			{
				duplicated++;
				if (duplicated == 0xFF)
				{
					sendBytes.push_back(current);
					sendBytes.push_back(duplicated);
					duplicated = 0;
				}
			}else{
				sendBytes.push_back(current);
				sendBytes.push_back(duplicated);
				current = raw[pxCnt * 3 + i];
				duplicated = 1;
			}
			
			pxCnt++;
		}
		
		sendBytes.push_back(current);
		sendBytes.push_back(duplicated-1);
		sendBytes.push_back(0x0);
		sendBytes.push_back(0x0);//0x0が2回続いたら終端処理
	}
	
	
	sendBytes.push_back(0x0);
	sendBytes.push_back(0x0);
	sendBytes.push_back(0x0);
	sendBytes.push_back(0x0);//0x0が4回続いたら初期状態リクエスト
	
//	serial.writeBytes(&sendBytes[0],sendBytes.size());
	test_receive(&sendBytes[0], sendBytes.size());
}
Ejemplo n.º 3
0
int main(void)
{
	printf("Testing receiver...\n");
	test_receive();
	printf("DONE\n\n");

	printf("Testing sender...\n");
	test_send();
	printf("DONE\n\n");

	return 0;
}
Ejemplo n.º 4
0
int main(int argc, char **argv) {
  grpc_closure destroyed;
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  grpc_test_init(argc, argv);
  grpc_init();
  g_pollset = gpr_malloc(grpc_pollset_size());
  grpc_pollset_init(g_pollset, &g_mu);

  test_no_op();
  test_no_op_with_start();
  test_no_op_with_port();
  test_no_op_with_port_and_start();
  test_receive(1);
  test_receive(10);

  grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
  grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
  grpc_exec_ctx_finish(&exec_ctx);
  gpr_free(g_pollset);
  grpc_iomgr_shutdown();
  return 0;
}