1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

Start updating the OSX UDP simulation to use a separate thread for receiving

but it needs two - one as a task (where the com callback occurs) and another
for the physical process stuff that doesn't need to suspend (like teh TCP
thread does)
This commit is contained in:
James Cotton 2012-03-15 03:19:56 -05:00
parent 5d0e513678
commit f491c924d6
4 changed files with 31 additions and 6 deletions

View File

@ -45,7 +45,7 @@ struct pios_udp_cfg {
typedef struct {
const struct pios_udp_cfg * cfg;
pthread_t rxThread;
xTaskHandle rxThread;
int socket;
struct sockaddr_in server;

View File

@ -134,8 +134,7 @@ static void *PIOS_TCP_RxThread(void *tcp_dev_n)
// Received is used to track the scoket whereas the dev variable is only updated when it can be
received = read(tcp_dev->socket_connection, incoming_buffer, INCOMING_BUFFER_SIZE);
while(fifoBuf_getFree(&tcp_dev->rx_fifo) < received)
usleep(10);
//while(fifoBuf_getFree(&tcp_dev->rx_fifo) < received);
fifoBuf_putData(&tcp_dev->rx_fifo, incoming_buffer, received);
} while(received > 0);

View File

@ -75,7 +75,7 @@ static pios_udp_dev * find_udp_dev_by_id (uint8_t udp)
/**
* RxThread
*/
void * PIOS_UDP_RxThread(void * udp_dev_n)
void PIOS_UDP_RxThread(void * udp_dev_n)
{
/* needed because of FreeRTOS.posix scheduling */
@ -151,7 +151,7 @@ int32_t PIOS_UDP_Init(uint32_t * udp_id, const struct pios_udp_cfg * cfg)
int res= bind(udp_dev->socket, (struct sockaddr *)&udp_dev->server,sizeof(udp_dev->server));
/* Create transmit thread for this connection */
pthread_create(&udp_dev->rxThread, NULL, PIOS_UDP_RxThread, (void*)udp_dev);
xTaskCreate(PIOS_UDP_RxThread, (signed char *)"UdpRx", 1024, (void*)udp_dev, 2, &udp_dev->rxThread);
printf("udp dev %i - socket %i opened - result %i\n",pios_udp_num_devices-1,udp_dev->socket,res);

View File

@ -54,6 +54,12 @@ const struct pios_tcp_cfg pios_tcp_telem_cfg = {
.ip = "0.0.0.0",
.port = 9001,
};
const struct pios_udp_cfg pios_udp_telem_cfg = {
.ip = "0.0.0.0",
.port = 9001,
};
const struct pios_tcp_cfg pios_tcp_gps_cfg = {
.ip = "0.0.0.0",
.port = 9001,
@ -151,7 +157,7 @@ void PIOS_Board_Init(void) {
TaskMonitorInitialize();
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_TELEMETRY_RF)
#if defined(PIOS_INCLUDE_TELEMETRY_RF) && 1
{
uint32_t pios_tcp_telem_rf_id;
if (PIOS_TCP_Init(&pios_tcp_telem_rf_id, &pios_tcp_telem_cfg)) {
@ -170,6 +176,26 @@ void PIOS_Board_Init(void) {
}
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
#if defined(PIOS_INCLUDE_TELEMETRY_RF) && 0
{
uint32_t pios_udp_telem_rf_id;
if (PIOS_UDP_Init(&pios_udp_telem_rf_id, &pios_udp_telem_cfg)) {
PIOS_Assert(0);
}
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_udp_com_driver, pios_udp_telem_rf_id,
rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN,
tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) {
PIOS_Assert(0);
}
}
#endif /* PIOS_INCLUDE_TELEMETRY_RF */
#if defined(PIOS_INCLUDE_GPS)
{
uint32_t pios_tcp_gps_id;