Ejemplo n.º 1
0
/**
 * @brief Callback that is called if data has been received by trx.
 *
 * @param rx_frame_array Pointer to data array containing received frame
 */
void tal_rx_frame_cb(uint8_t *rx_frame_array)
{
    uint8_t rx_payload_len = rx_frame_array[0] - FRAME_OVERHEAD;
    uint8_t *rx_payload_ptr = rx_frame_array + FRAME_OVERHEAD + LENGTH_FIELD_LEN - FCS_LEN;
    uint8_t sio_len_rx;

    /* Print received data to terminal program. */
    bool sio_ongoing = true;

    do
    {
        sio_len_rx = pal_sio_tx(SIO_CHANNEL, rx_payload_ptr, rx_payload_len);

        if (sio_len_rx < rx_payload_len)
        {
            rx_payload_len -= sio_len_rx;
            rx_payload_ptr += sio_len_rx;
            pal_task();
        }
        else
        {
            sio_ongoing = false;
        }
    } while (sio_ongoing);

    pal_led(LED_DATA_RX, LED_TOGGLE);    // indicating data recption
}
Ejemplo n.º 2
0
/**
 * @brief Application task handler
 */
static void app_task(void)
{
    uint8_t number_of_bytes_to_be_transmitted;
	uint8_t stop_data;
   if(Wireshark_Settings == INIT_STATE)
   {
        uint8_t input_channel = sio_getchar();
        sniffer_config_select(CHANNEL_SELECT_ID,input_channel);
        Wireshark_Settings = SET_START;
   }

   if(Wireshark_Settings == SET_START)
   {
        number_of_bytes_to_be_transmitted = sio_getchar();
        if(number_of_bytes_to_be_transmitted == 0x01)
        {
           sniffer_config_select(START_CAPTURE_ID,number_of_bytes_to_be_transmitted);
           Wireshark_Settings = WS_RESTART;
           sio_rx_data[0] = INIT_VALUE;
        }
   }

   if(Wireshark_Settings == WS_RESTART)
   {
        number_of_bytes_to_be_transmitted = pal_sio_rx(SIO_CHANNEL, sio_rx_data, 1);
        if((number_of_bytes_to_be_transmitted  == 1) && (sio_rx_data[0] == 0x02))
        {
                sio_rx_data[0] = INIT_VALUE;
                Wireshark_Settings = INIT_STATE;
                stop_data = STOP_CAP;
                while((number_of_bytes_to_be_transmitted = pal_sio_tx(SIO_CHANNEL, &stop_data, 1)) !=1);
        }
   }
}
Ejemplo n.º 3
0
/**
 * @brief Callback that is called once tx is done.
 *
 * @param status    Status of the transmission procedure
 */
void tal_tx_frame_done_cb(retval_t status)
{
    if (status == MAC_SUCCESS)
    {
        uint8_t tx_payload_len = tx_buffer[0] - FRAME_OVERHEAD;
        uint8_t *tx_payload_ptr = tx_buffer + FRAME_OVERHEAD + LENGTH_FIELD_LEN - FCS_LEN;
        uint8_t sio_len_tx;

        /* Print transmitted bytes to terminal program. */

        bool sio_ongoing = true;

        do
        {
            sio_len_tx = pal_sio_tx(SIO_CHANNEL, tx_payload_ptr, tx_payload_len);

            if (sio_len_tx < tx_payload_len)
            {
                tx_payload_len -= sio_len_tx;
                tx_payload_ptr += sio_len_tx;
                pal_task();
            }
            else
            {
                sio_ongoing = false;
            }
        } while (sio_ongoing);

        pal_led(LED_DATA_TX, LED_TOGGLE);    // indicating successfull data transmission

        /* After transmission is completed, allow next transmission. */
        tx_state = TX_IDLE;
    }
    else if (status == MAC_CHANNEL_ACCESS_FAILURE)
        /*
         * Channel access failure is the only transmission failure that makes sense
         * to be handled within this application. For handling other status codes,
         * such as MAC_NO_ACK, this is probably the wrong application on the wrong layer.
         * For absolutely reliable transmission, please use a MAC or TAL based
         * application. The Tiny-TAL is not designed for such a purpose.
         *
         * In case of channel access failure the frame is retried.
         */
    {
        /* Transmission was not successful, initiate retry. */
        tx_state = TX_RETRY;
        //TODO: retry counter?
    }
    else
        /*
         * Other transmission status codes, such as MAC_NO_ACK are not handled
         * within this application.
         * The transmission is considered as beeing completed for this frame.
         */
    {
        tx_state = TX_IDLE;

#if(ALERT_ON_ERROR==true)
        pal_alert();
#endif
    }
}
Ejemplo n.º 4
0
/**
 * @brief Transmits data through selected SIO unit
 *
 * This function transmits data through the selected SIO unit.
 *
 * @param data Pointer to the data to be transmitted is present
 * @param length Number of bytes to be transmitted
 *
 * @return Actual number of transmitted bytes
 */
uint8_t sniffer_sio_tx(uint8_t *data, uint8_t length)
{
    return(pal_sio_tx(SIO_CHANNEL, data, length));
}