1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

Telemetry and HID work, ugly hacks atm. Endianess needs checking. HID transmit doesn't work at all. Serialport works both ways

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@472 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
sambas 2010-04-10 16:22:08 +00:00 committed by sambas
parent 5d1229311d
commit 402b4e8e24
4 changed files with 33 additions and 17 deletions

View File

@ -153,12 +153,14 @@ static void telemetryTask(void* parameters)
UAVObjMetadata metadata;
int32_t retries;
int32_t success;
PIOS_COM_SendFormattedStringNonBlocking(telemetryPort, "sendtest");
// Loop forever
while(1)
{
// PIOS_LED_Toggle(LED2);
// Wait for queue message
if(xQueueReceive(queue, &ev, portMAX_DELAY) == pdTRUE)
if(xQueueReceive(queue, &ev, 0) == pdTRUE)
{
// Get object metadata
UAVObjGetMetadata(ev.obj, &metadata);
@ -191,14 +193,26 @@ static void telemetryTask(void* parameters)
}
/* This blocks the task until there is something on the buffer */
if(PIOS_COM_ReceiveBufferUsed(telemetryPort) > 0)
uint8_t bytes = PIOS_COM_ReceiveBufferUsed(telemetryPort);
if(bytes > 0)
{
UAVTalkProcessInputStream(PIOS_COM_ReceiveBuffer(telemetryPort));
PIOS_LED_Toggle(LED2);
uint8_t c=PIOS_COM_ReceiveBuffer(telemetryPort);
UAVTalkProcessInputStream(c);
//PIOS_COM_SendFormattedStringNonBlocking(COM_USART1, "%c", c);
}
else if(PIOS_COM_ReceiveBufferUsed(COM_USB_HID) > 0)
{
UAVTalkProcessInputStream(PIOS_COM_ReceiveBuffer(COM_USB_HID));
PIOS_LED_Toggle(LED2);
//UAVTalkProcessInputStream(PIOS_COM_ReceiveBuffer(COM_USB_HID));
uint8_t c=PIOS_COM_ReceiveBuffer(COM_USB_HID);
if(c!=255)
{
PIOS_COM_SendCharNonBlocking(COM_USART1, c);
UAVTalkProcessInputStream(c);
}
}
//vTaskDelay(200 / portTICK_RATE_MS);
}
}

View File

@ -111,10 +111,11 @@ int main()
/* Create a FreeRTOS task */
xTaskCreate(TaskTick, (signed portCHAR *)"Test", configMINIMAL_STACK_SIZE , NULL, 1, NULL);
xTaskCreate(TaskTesting, (signed portCHAR *)"TaskTesting", configMINIMAL_STACK_SIZE , NULL, 4, NULL);
//xTaskCreate(TaskTesting, (signed portCHAR *)"TaskTesting", configMINIMAL_STACK_SIZE , NULL, 4, NULL);
//xTaskCreate(TaskServos, (signed portCHAR *)"Servos", configMINIMAL_STACK_SIZE , NULL, 3, NULL);
//xTaskCreate(TaskSDCard, (signed portCHAR *)"SDCard", configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 2), NULL);
//GpsInitialize();
TelemetryInitialize();
/* Start the FreeRTOS scheduler */
vTaskStartScheduler();
@ -142,12 +143,12 @@ static void TaskTick(void *pvParameters)
for(;;)
{
/*
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"utc: %s alt:%d\r\n",GpsInfo.TimeOfFix,(int)GpsInfo.alt);
/*PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"utc: %s alt:%d\r\n",GpsInfo.TimeOfFix,(int)GpsInfo.alt);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"lat: %d lon: %d\r\n",(long)(GpsInfo.lat*10000),(long)(GpsInfo.lon*10000));
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"SV: %d\r\n",GpsInfo.numSVs);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"SV: %d Updates: %d\r\n",GpsInfo.numSVs,GpsInfo.updates);
PIOS_COM_SendFormattedStringNonBlocking(COM_DEBUG_USART,"Heading: %s Speed: %s\r\n",GpsInfo.heading,GpsInfo.speed);
*/
*/
PIOS_LED_Toggle(LED1);
vTaskDelayUntil(&xLastExecutionTime, 1000 / portTICK_RATE_MS);
}

View File

@ -194,7 +194,8 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
if (rxCount == 4)
{
// Search for object, if not found reset state machine
objId = (tmpBuffer[3] << 24) | (tmpBuffer[2] << 16) | (tmpBuffer[1] << 8) | (tmpBuffer[0]);
//objId = (tmpBuffer[3] << 24) | (tmpBuffer[2] << 16) | (tmpBuffer[1] << 8) | (tmpBuffer[0]);
objId = (tmpBuffer[0] << 24) | (tmpBuffer[1] << 16) | (tmpBuffer[2] << 8) | (tmpBuffer[3]);
obj = UAVObjGetByID(objId);
if (obj == 0)
{
@ -275,7 +276,7 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
tmpBuffer[rxCount++] = rxbyte;
if (rxCount == 2)
{
csRx = (tmpBuffer[1] << 8) | (tmpBuffer[0]);
csRx = (tmpBuffer[0] << 8) | (tmpBuffer[1]);
if (csRx == cs)
{
xSemaphoreTakeRecursive(lock, portMAX_DELAY);
@ -288,7 +289,6 @@ int32_t UAVTalkProcessInputStream(uint8_t rxbyte)
default:
state = STATE_SYNC;
}
// Done
return 0;
}
@ -504,7 +504,8 @@ static int32_t sendSingleObject(UAVObjHandle obj, uint16_t instId, uint8_t type)
txBuffer[dataOffset+length+1] = (uint8_t)((cs >> 8) & 0xFF);
// Send buffer
if (outStream!=NULL) (*outStream)(txBuffer, dataOffset+length+CHECKSUM_LENGTH);
if (outStream!=NULL)
(*outStream)(txBuffer, dataOffset+length+CHECKSUM_LENGTH);
// Done
return 0;

View File

@ -86,7 +86,7 @@ static volatile uint8_t rx_buffer_new_data_ctr = 0;
static volatile uint8_t rx_buffer_ix;
static uint8_t transfer_possible = 0;
static uint8_t rx_buffer[PIOS_USB_HID_DATA_LENGTH];
static uint8_t rx_buffer[PIOS_USB_HID_DATA_LENGTH] = {0};
/**
* Initialises USB COM layer
@ -196,10 +196,10 @@ int32_t PIOS_USB_HID_RxBufferGet(void)
/* This stops returning bytes after the first occurrence of '\0' */
/* We don't need to do this but it does optimise things quite a bit */
if(rx_buffer[rx_buffer_ix] == 0) {
//if(rx_buffer[rx_buffer_ix] == 0) {
/* TODO: Evaluate if this is really needed */
/* Clean the buffer */
for(uint8_t i = 0; i < PIOS_USB_HID_DATA_LENGTH; i++) {
/*for(uint8_t i = 0; i < PIOS_USB_HID_DATA_LENGTH; i++) {
rx_buffer[i] = 0;
}
@ -207,7 +207,7 @@ int32_t PIOS_USB_HID_RxBufferGet(void)
rx_buffer_ix = 0;
SetEPRxStatus(ENDP1, EP_RX_VALID);
return -1;
}
}*/
/* There is still data in the buffer */
uint8_t b = rx_buffer[rx_buffer_ix++];