bool decode(void)
{
    validMIRP_rx = 0;
    if(!PORTBbits.RB5)
    {
        if(checkStart()) 
        {
            /*mirpRx.id_h = decodeByte();
            mirpRx.id_l = decodeByte();
            mirpRx.spell_id = decodeByte();
            mirpRx.str = decodeByte();
            mirpRx.uuid = decodeByte();
            mirpRx.crc = decodeByte();*/
            /*mirp[0] = decodeByte(); //id_h
            mirp[1] = decodeByte(); //id_l
            mirp[2] = decodeByte(); //spell
            mirp[3] = decodeByte(); //str
            mirp[4] = decodeByte(); //uuid
            mirp[5] = decodeByte(); //crc*/
            IDH = decodeByte();
            IDL = decodeByte();
            SPELL = decodeByte();
            STR = decodeByte();
            UID = decodeByte();
            CRC = decodeByte();
        }
        validMIRP_rx = checkCRC();
    }
    counter_rx = 0; //move this out here
    return validMIRP_rx;
}
Пример #2
0
	void setup_filename(const x0::FlowParams& args, x0::FlowValue& result)
	{
		if (args.empty()) {
			result.set(filename_.c_str());
			return;
		}

		args[0].load(filename_);

		checkStart();
	}
Пример #3
0
jint Java_com_ruin_psp_PSP_readRAMU32(JNIEnv *env, jclass clazz, jint address) {
  u32 start = PSP_GetUserMemoryBase() + (u32)address;
  u32 size = 32;

  auto memLock = Memory::Lock();
  if (!PSP_IsInited())
    return 0;

  if (!checkStart(start, size))
    return 0;

  return (jint) Memory::Read_U32(start);
}
Пример #4
0
	void setup_step(const x0::FlowParams& args, x0::FlowValue& result)
	{
		if (args.empty()) {
			result.set(step_);
			return;
		}

		args[0].load(step_);

		if (step_)
			evTimer_.set(step_, step_);

		checkStart();
	}
Пример #5
0
jfloat Java_com_ruin_psp_PSP_readRAMU32Float (JNIEnv *env, jclass clazz, jint address) {
  u32 start = PSP_GetUserMemoryBase() + (u32)address;
  u32 size = 32;

  auto memLock = Memory::Lock();
  if (!PSP_IsInited())
    return 0;

  if (!checkStart(start, size))
    return 0;

  u32 dat = Memory::Read_U32(start);
  float f;
  memcpy(&f, &dat, sizeof(f));

  return (jfloat) f;
}
Пример #6
0
jbyteArray Java_com_ruin_psp_PSP_readRam(JNIEnv *env, jclass clazz, jint address, jint size) {
  u32 start = PSP_GetUserMemoryBase() + (u32)address;

  auto memLock = Memory::Lock();
  if (!PSP_IsInited())
    return 0;

  if (!checkStart(start, size))
    return 0;

  u8 *ptr = Memory::GetPointer(start);

  jbyte arr[size];

  memcpy(&arr, ptr, sizeof(arr));

  jbyteArray ret = env->NewByteArray(size);
  env->SetByteArrayRegion(ret, 0, size, arr);
  return ret;
}
Пример #7
0
void Service::checkServiceStart(void)
{
  int status = 0;
  int wpid;
  int options = WNOHANG | WUNTRACED;

  static int timeout;

  //
  // The child is the service launched by nxservice.
  // Each second we check for the child exit status.
  // If the child doesn't return, we use its logs to
  // retrieve the status.
  //

  #ifdef DEBUG
  logUser("Service::checkServiceStart: going to check the '%s' service status", getType());
  #endif

  for (;;)
  {
    #ifdef TEST
    logUser("Service::checkServiceStart: waiting for child pid %d.", getPid());
    #endif

    wpid = waitpid(getPid(), &status, options);

    if (wpid == -1)
    {
      #ifdef WARNING
      logUser("WARNING! Waitpid returns error: %d.", EGET());
      #endif

      //
      // "The process specified does not exist or is not
      // a child of the calling process."
      // We don't know why this happened, but we can try
      // to return a successful state.
      //

      exit(0);
    }
    else if (wpid == 0)
    {
      //
      // The child's state is not changed. Let's check
      // if there is a reason to believe it is running.
      //

      if (checkStart())
      {
        #ifdef DEBUG
        logUser("Service::checkServiceStart: '%s' successfully starts after waiting "
                    "for %d seconds.", getType(), timeout / 1000);
        #endif

        exit(0);
      }
    }
    else
    {
      //
      // The child's state changes, let's figure out why.
      //

      if (WIFSTOPPED(status))
      {
        #ifdef DEBUG
        logUser("Service::checkServiceStart: '%s' service has been stopped with signal %d "
                    "after waiting for %d seconds.", getType(), WSTOPSIG(status),
                        timeout / 1000);
        #endif

        exit(0);
      }
      else if (WIFEXITED(status))
      {
        #ifdef DEBUG
        logUser("Service::checkServiceStart: '%s' service exits with status %d after "
                    "waiting for %d seconds.", getType(), WEXITSTATUS(status),
                        timeout / 1000);
        #endif

        exit(WEXITSTATUS(status));
      }
      else if (WIFSIGNALED(status))
      {
        #ifdef DEBUG
        logUser("Service::checkServiceStart: '%s' service terminates with signal %d after "
                    "waiting for %d seconds.", getType(), WTERMSIG(status),
                        timeout / 1000);
        #endif

        //
        // FIXME: Do we need to better classify the signals?
        //

        switch (WTERMSIG(status))
        {
          case SIGABRT:
          case SIGSEGV:
          case SIGKILL:
            exit(1);
          default:
            exit(0);
        }
      }
      else
      {
        #ifdef WARNING
        logUser("Service::checkServiceStart: WARNING! Waitpid returns an unknown status: "
                    "%d.", status);
        #endif
      }
    }

    usleep(SERVICE_START_INTERVAL * 1000);

    timeout += SERVICE_START_INTERVAL;

    if (timeout / 1000 >= getTimeout())
    {
      #ifdef WARNING
      logUser("Service::checkServiceStart: WARNING! Assuming the '%s' starts after "
                  "waiting for %d seconds.", getType(), timeout / 1000);
      #endif

      exit(0);
    }
  }
}