Crazyflie 2.0 communicate with Gps module by UART.

Firmware/software/electronics/mechanics
Post Reply
cha8138
Beginner
Posts: 12
Joined: Wed Jul 05, 2017 7:46 am

Crazyflie 2.0 communicate with Gps module by UART.

Post by cha8138 »

Hi. I'm an undergraduate. I progress some project.
first, I had to communicate between Crazyflie 2.0 and Gps module.(Ublox EVK-M8T or NEO-M8T)
I tested communication by Arduino. It was succeeded and there is no problem.

So, I edited Crazyflie 2.0 firmware. like this.(I referred to "Gtgps.c")

Code: Select all

//directory : src/deck/drivers/src/commUart.c
#define DEBUG_MODULE "uartDeck"
#include "debug.h"

#include "deck.h"
#include "deck_core.h"

#include "log.h"
#include "FreeRTOS.h"
#include "stdbool.h"
#include "timers.h"

#include "uart1.h"
#include "console.h"
#include "task.h"


//static xTimerHandle timer;
char cData;


void receiveData(void *param)
{
	while(1)
	{
		char ch;
		char msg[100]="";
		uart1Getchar(&ch);
		msg[0]=cData=ch;
		if(ch=='$')
		{
			int i =1;
			for(;ch!='\n';i++)
			{
				uart1Getchar(&ch);
				msg[i] = cData= ch;
			}
			i++;
			msg[i]='\0';
			DEBUG_PRINT("%s",msg);
		}
	}
}


static void uartCommInit(DeckInfo *info)
{
  uart1Init(9600);
  xTaskCreate(receiveData, "commUart",configMINIMAL_STACK_SIZE, NULL, /*priority*/1, NULL);
  DEBUG_PRINT("Inited uartComm deck.\n");
}


static const DeckDriver uartCommDriver = {
  .name = "commUart",
  .usedGpio = 0,
  .init = uartCommInit,
};

DECK_DRIVER(uartCommDriver);

LOG_GROUP_START(myUartData)
LOG_ADD(LOG_UINT16, character, &cData)
LOG_GROUP_STOP(myUartData)
It work very well....
Image

After few minutes. It occur problem.
Crazyflie was stopped and turned on M1, M4 LED in red.
Image

#Q1
What's mean that M1, M4 turned on in red?

#Q2
Does any problem in my code?

p.s. I'm not good at English. I don't know if I explained well... :cry:
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Crazyflie 2.0 communicate with Gps module by UART.

Post by tobias »

Well done so far!
The 2xRed + blue most likely is a hard fault or an ASSERT. Easiest to find out why is to use a debugger.

Does the problem happen if you don't get any characters from the GPS, e.g. turn it off?
cha8138
Beginner
Posts: 12
Joined: Wed Jul 05, 2017 7:46 am

Re: Crazyflie 2.0 communicate with Gps module by UART.

Post by cha8138 »

Last edited by cha8138 on Wed Jul 05, 2017 10:44 am, edited 1 time in total.
cha8138
Beginner
Posts: 12
Joined: Wed Jul 05, 2017 7:46 am

Re: Crazyflie 2.0 communicate with Gps module by UART.

Post by cha8138 »

tobias wrote:Well done so far!
The 2xRed + blue most likely is a hard fault or an ASSERT. Easiest to find out why is to use a debugger.

Does the problem happen if you don't get any characters from the GPS, e.g. turn it off?
Tobias, Thank you for reply. :)
I am the first to use debugger in embedded system.
Can I debug using by crazyradio? or, Need I debugging adapter kit? (https://www.bitcraze.io/debug-adapter-kit/)
If I use debugging adapter kit, Could you let me know tutorial page? I can't found using it.

Yeah.. I need character data. because algorithm of my project is using from string data(ex, $GNGGA, 080021, 00... ...).
So, I send character data to server by crazyradio. Then, calculating and re-send to crazyflie.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Crazyflie 2.0 communicate with Gps module by UART.

Post by tobias »

Yes you need the debug adapter kit or make your own cable + a debugger like the STLinkV2.

You might be able to find the problem without the dubugger so try that first. Back to the question is the hard fault related to your code (my best guess is a memory overflow problem).
cha8138
Beginner
Posts: 12
Joined: Wed Jul 05, 2017 7:46 am

Re: Crazyflie 2.0 communicate with Gps module by UART.

Post by cha8138 »

tobias wrote:Yes you need the debug adapter kit or make your own cable + a debugger like the STLinkV2.

You might be able to find the problem without the dubugger so try that first. Back to the question is the hard fault related to your code (my best guess is a memory overflow problem).
Aha.. Okay. Thank you.
I'll check character array.
Post Reply