two solid red LEDs

Firmware/software/electronics/mechanics
6-H-05-T
Beginner
Posts: 12
Joined: Sun Mar 19, 2017 6:55 pm

two solid red LEDs

Post by 6-H-05-T »

Whenever I flash my code to my crazyflie, when it gets done and restarts in firmware mode, the two front red LEDs go solid and nothing else happens. Crazyflie Client won't connect.
I was able to get it to not do this and to reboot into firmware mode as normal by removing some lines of code, and I've been trying to pinpoint the problem by slowing adding my code back in line by line. What I have discovered by doing this is that it seems to be random. at one point it rebooted as normal, and then I cleaned, built, and reflashed (using radio) AFTER MAKING NO CHANGES TO CODE WHATSOEVER, and then it did the two solid red LEDs thing again.
Please help! What is wrong with my Crazyflie? I am nearing assignment deadline and can't make any progress on my project!
6-H-05-T
Beginner
Posts: 12
Joined: Sun Mar 19, 2017 6:55 pm

Re: two solid red LEDs

Post by 6-H-05-T »

UPDATE:
When I try to connect to Crazyflie Client while two red LEDs are solid, I get this on the console:

SYS: Assert failed src/modules/src/log.c:165
6-H-05-T
Beginner
Posts: 12
Joined: Sun Mar 19, 2017 6:55 pm

Re: two solid red LEDs

Post by 6-H-05-T »

UPDATE 2:

So removing my deck driver file and all references to it in Makefile and config.mk seems to have permanently solved the problem. Now I'm trying to add my stuff back in line-by-line again, but I would really like to know what the two solid red LEDs and the error message mean so I may be able to avoid problems in the future.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: two solid red LEDs

Post by tobias »

The two solid red LEDs means you hit an assert. Looking in the file "src/modules/src/log.c:165" I can see it asserted because of a too long name. The log group + log name cannot exceed 25 characters combined.
6-H-05-T
Beginner
Posts: 12
Joined: Sun Mar 19, 2017 6:55 pm

Re: two solid red LEDs

Post by 6-H-05-T »

What does that mean? I'm not doing anything to log group or log name in my code.
I've changed some things since initially posting this, and now I'm getting the two red LEDs again, and this time the assert that is failing is:

src/modules/src/param.c:98

Looking at the file it is param group or name too big. What am I doing wrong?
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: two solid red LEDs

Post by tobias »

That is strange. Can you share your code so we can replicate the problem here?
6-H-05-T
Beginner
Posts: 12
Joined: Sun Mar 19, 2017 6:55 pm

Re: two solid red LEDs

Post by 6-H-05-T »

Well, now I'm not getting the error message when I try to connect anymore!

Okay, so here's what I'm doing: I've got an IR emitter on the back of another robot, and I want to put two IR sensors on the front of my CF to allow it to locate and follow the robot. This is my first project with the CF and I feel like I must be reinventing the wheel a bit, but that is how I learn.
I'm still in the testing phase, so I've got my IR circuits breadboarded and I'm using the Breakout deck to test them. What I'm trying to do is put a DEBUG_PRINT line into the method that I'm passing into the timer in order to see what values I am getting from the sensors.

Code: Select all

/* debug mode */
#define DEBUG_MODULE "ir"
#include "debug.h"
/* end debug */

#include <stdint.h>
#include <stdlib.h>
#include "stm32fxxx.h"
#include "FreeRTOS.h"
#include "timers.h"
#include "deck.h"
#include "log.h"

/* Define expansion deck IOs */
#define IR_L DECK_GPIO_RX2  // left IR sensor
#define IR_R DECK_GPIO_TX2  // right IR sensor

static float IR[2][7]; // array for holding some sensor data
static xTimerHandle T;

static void Loop() {
	IR[0][0] = analogRead(IR_L);
	IR[1][0] = analogRead(IR_R);
	DEBUG_PRINT("%f\n", IRsensor[0][0]); // this is how I'm trying to see what values I'm getting from the sensor(s)
}

/* main initialization */
static void irInit() {
	pinMode(IR_L, INPUT);
	pinMode(IR_R, INPUT);

	T = xTimerCreate("Loop", M2T(10), pdTRUE, NULL, Loop);
	xTimerStart(T, 100);
}

static bool irTest() {
	return true;
}

static const DeckDriver irDriver =
{
		.name = "ir",
		.usedGpio = DECK_USING_RX2 | DECK_USING_TX2,
		.init = irInit,
		.test = irTest,
};

DECK_DRIVER(irDriver);
It compiles fine with or without that DEBUG_PRINT, and it flashes to the CF no problem, but when it restarts in firmware mode immediately after flashing, if the DEBUG_PRINT line is included, the two front LEDs go solid red. then when I try to connect to the CF through the client the console gives me no information, but the terminal window shows:

Code: Select all

INFO:cflib.crazyflie:Callback->Connection initialized[radio://0/80/250K]
INFO:cflib.crazyflie:We are connected[radio://0/80/250K], request connection setup
INFO:cflib.crazyflie:Callback->Connected to [radio://0/80/250K]
INFO:cflib.crazyflie:Resending for pattern (93,5)
INFO:cflib.crazyflie:Resending for pattern (93,5)
INFO:cflib.crazyflie:Resending for pattern (93,5)
INFO:cflib.crazyflie:Resending for pattern (93,5)
.
.
.
...and it just goes on like that forever.

I've read some stuff about using the log to monitor variables but I haven't figured out how to do that.
Another problem I've been having is that I want to write other methods and call them from my Loop() method so that I can compartmentalize my code better, but I get errors when I try to do that. I have tried to read up on freeRTOS to figure out a way to do this. There is SO MUCH documentation on freeRTOS and I don't understand it well enough yet to figure this issue out.
Any pointers or help you guys have would be great. Thanks.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: two solid red LEDs

Post by tobias »

Great to get some information around the project. Much easier to help then. Sound like you have a good approach.

What kind of IR sensors are you using?

You are probably flooding the communication with the DEBUG_PRINT as the loop is running 100 times per second. Or might be a stack overflow problem. Instead you should use the logging framework for that. Have a look at the wiki for some basic documentation and also check other source files for examples. It is fairly simple to use. Let me know how it goes.
6-H-05-T
Beginner
Posts: 12
Joined: Sun Mar 19, 2017 6:55 pm

Re: two solid red LEDs

Post by 6-H-05-T »

Thank you,

I've got this:

Code: Select all

LOG_GROUP_START(InfraRed)
LOG_ADD(LOG_FLOAT, InfraRed, &IR)
LOG_GROUP_STOP(InfraRed)
And then I get an "InfraRed" line in my Log TOC that has:

ID: 107
Unpack: <f
Storage: float

but there is nothing in the Log Blocks tab.

So how to I actually monitor the value of the variable?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: two solid red LEDs

Post by arnaud »

If you want to log your variable you need to create a log block with this variable in it using setting/logging configuration. You can add up to about 6 floats in each log block and chose the logging rate. The block can then be plotted in the plotter and you can start it and save it to an csv file in the log block tab.

Note that if plotting does not work, you can try to disable some log block in the log block tab. We are currently setting up the maximum amount of log block with the latest client and we need to increase the max number of log block in the Crazyflie.
Post Reply