Esempio n. 1
0
static void queues2_execute(void) {
  unsigned i;
  size_t n;

  /* Initial empty state */
  test_assert_lock(1, chOQIsEmptyI(&oq), "not empty");

  /* Queue filling */
  for (i = 0; i < TEST_QUEUES_SIZE; i++)
    chOQPut(&oq, 'A' + i);
  test_assert_lock(2, chOQIsFullI(&oq), "still has space");

  /* Queue emptying */
  for (i = 0; i < TEST_QUEUES_SIZE; i++) {
    char c;

    chSysLock();
    c = chOQGetI(&oq);
    chSysUnlock();
    test_emit_token(c);
  }
  test_assert_lock(3, chOQIsEmptyI(&oq), "still full");
  test_assert_sequence(4, "ABCD");
  test_assert_lock(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY");

  /* Writing the whole thing */
  n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE);
  test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size");
  test_assert_lock(7, chOQIsFullI(&oq), "not full");
  threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL);
  test_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty");
  test_wait_threads();

  /* Testing reset */
  chSysLock();
  chOQResetI(&oq);
  chSysUnlock();
  test_assert_lock(9, chOQGetFullI(&oq) == 0, "still full");

  /* Partial writes */
  n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
  test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
  n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
  test_assert(11, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
  test_assert_lock(12, chOQIsFullI(&oq), "not full");

  /* Timeout */
  test_assert(13, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return");
}
Esempio n. 2
0
/**
 * @brief   Output queue read.
 * @details A byte value is read from the low end of an output queue.
 *
 * @param[in] oqp       pointer to an @p OutputQueue structure
 * @return              The byte value from the queue.
 * @retval Q_EMPTY      if the queue is empty.
 *
 * @iclass
 */
msg_t chOQGetI(OutputQueue *oqp) {
  uint8_t b;

  if (chOQIsEmptyI(oqp))
    return Q_EMPTY;

  b = *oqp->q_rdptr++;
  if (oqp->q_rdptr >= oqp->q_top)
    oqp->q_rdptr = oqp->q_buffer;
  chSemSignalI(&oqp->q_sem);
  return b;
}
Esempio n. 3
0
void PExTransmit(void) {
  if (!chOQIsEmptyI(&BDU1.oqueue)) {
    chThdSleepMilliseconds(1);
    BDU1.oqueue.q_notify(&BDU1.oqueue);
  }
  else {
    if (AckPending) {
      int ack[7];
      ack[0] = 0x416F7841; // "AxoA"
      ack[1] = 0; // reserved
      ack[2] = dspLoadPct;
      ack[3] = patchMeta.patchID;
      ack[4] = sysmon_getVoltage10() + (sysmon_getVoltage50()<<16);
      if (patchStatus) {
        ack[5] = UNINITIALIZED;
      } else {
        ack[5] = loadPatchIndex;
      }
      ack[6] = fs_ready;
      chSequentialStreamWrite((BaseSequentialStream * )&BDU1,
                              (const unsigned char* )&ack[0], 7 * 4);

#ifdef DEBUG_SERIAL
      chprintf((BaseSequentialStream * )&SD2,"ack!\r\n");
#endif

      if (!patchStatus)
        TransmitDisplayPckt();

      connected = 1;
      exception_checkandreport();
      AckPending = 0;
    }
    if (!patchStatus) {
      unsigned int i;
      for (i = 0; i < patchMeta.numPEx; i++) {
        if (patchMeta.pPExch[i].signals & 0x01) {
          int v = (patchMeta.pPExch)[i].value;
          patchMeta.pPExch[i].signals &= ~0x01;
          PExMessage msg;
          msg.header = 0x516F7841; //"AxoQ"
          msg.patchID = patchMeta.patchID;
          msg.index = i;
          msg.value = v;
          chSequentialStreamWrite((BaseSequentialStream * )&BDU1,
                                  (const unsigned char* )&msg, sizeof(msg));
        }
      }
    }
  }
}
Esempio n. 4
0
/**
 * @brief   Output queue read.
 * @details A byte value is read from the low end of an output queue.
 *
 * @param[in] oqp       pointer to an @p output_queue_t structure
 * @return              The byte value from the queue.
 * @retval Q_EMPTY      if the queue is empty.
 *
 * @iclass
 */
msg_t chOQGetI(output_queue_t *oqp) {
  uint8_t b;

  chDbgCheckClassI();

  if (chOQIsEmptyI(oqp))
    return Q_EMPTY;

  oqp->q_counter++;
  b = *oqp->q_rdptr++;
  if (oqp->q_rdptr >= oqp->q_top)
    oqp->q_rdptr = oqp->q_buffer;

  chThdDequeueNextI(&oqp->q_waiting, Q_OK);

  return b;
}
Esempio n. 5
0
/**
 * @brief   Output queue read.
 * @details A byte value is read from the low end of an output queue.
 *
 * @param[in] oqp       pointer to an @p OutputQueue structure
 * @return              The byte value from the queue.
 * @retval Q_EMPTY      if the queue is empty.
 *
 * @iclass
 */
msg_t chOQGetI(OutputQueue *oqp) {
    uint8_t b;

    chDbgCheckClassI();

    if (chOQIsEmptyI(oqp))
        return Q_EMPTY;

    oqp->q_counter++;
    b = *oqp->q_rdptr++;
    if (oqp->q_rdptr >= oqp->q_top)
        oqp->q_rdptr = oqp->q_buffer;

    if (notempty(&oqp->q_waiting))
        chSchReadyI(fifo_remove(&oqp->q_waiting))->p_u.rdymsg = Q_OK;

    return b;
}
Esempio n. 6
0
/**
 * @brief   Output queue read.
 * @details A byte value is read from the low end of an output queue.
 *
 * @param[in] oqp       pointer to an @p output_queue_t structure
 * @return              The byte value from the queue.
 * @retval Q_EMPTY      if the queue is empty.
 *
 * @iclass
 */
msg_t chOQGetI(output_queue_t *oqp) {
    uint8_t b;

    chDbgCheckClassI();

    if (chOQIsEmptyI(oqp)) {
        return Q_EMPTY;
    }

    oqp->counter++;
    b = *oqp->rdptr++;
    if (oqp->rdptr >= oqp->top) {
        oqp->rdptr = oqp->buffer;
    }

    chThdDequeueNextI(&oqp->waiting, Q_OK);

    return (msg_t)b;
}
Esempio n. 7
0
bool OutQueue::isEmptyI(void) {

    return (bool)chOQIsEmptyI(&oq);
}