Stm Cube IDE ERROR : Comparison error for function - function

I am experimenting with the STM32f407vg board through the STMBUBEIDE program.
First of all, I prepare my own library file and make the settings in the interrupt section.
What if the reason I can't get rid of this error?
First of all, I have a griodriver.c file for my src file. And my definition in it:
uint8_t portcode = GPIO_BASE_ADDR_TO_CODE (pGPIOHandle-> pGPIOx);
Then I write my function so that this comes back.
uint16_t GPIO_BASE_ADDR_TO_CODE(*x)
{
if(x==GPIOA) { return 0; }
else if(x==GPIOB) { return 1; }
else if(x==GPIOC) { return 2; }
else if(x==GPIOD) { return 3; }
else if(x==GPIOE) { return 4; }
else if(x==GPIOF) { return 5; }
else if(x==GPIOG) { return 6; }
}
If I remove the pointer inside the loop, I get a comparison between pointer and interger error.
Whenever I compile I get an error.
My error says this for the function:
This is warnings error.
Description Resource Path Location Type
implicit declaration of function 'GPIO_BASE_ADDR_TO_CODE'; did you mean 'GPIOJ_BASEADDR'?
[- Wimplicit-function-declaration] stm32f407xx_gpio_driver.c /stm32f407xx/drivers/Src
line 253 C/C++ Problem
But there are 2 other errors I get as ERROR.
enter image description here
enter image description here
First:
1. ERROR: Description Resource Path Location Type
make: *** [drivers/Src/subdir.mk:18: drivers/Src/stm32f407xx_gpio_driver.o]
Error 1 stm32f407xx C/C++ Problem
SEcond:
Description Resource Path Location Type
expected declaration specifiers or '...' before '*' token stm32f407xx_gpio_driver.c
/stm32f407xx/drivers/Src line 168 C/C++ Problem
Error Screen:
enter image description here

When I change this part like a below,
uint16_t GPIO_BASE_ADDR_TO_CODE(uint8_t x)
{
if( x==GPIOA) { return 0; }
else if(x==GPIOB) { return 1; }
else if(x==GPIOC) { return 2; }
else if(x==GPIOD) { return 3; }
else if(x==GPIOE) { return 4; }
else if(x==GPIOF) { return 5; }
else if(x==GPIOG) { return 6; }
return 0;
}
My errors change like that :
enter image description here

Instead of calling it in a function, I defined it as #define for
GPIO_BASEADDR_TO_CODE
Also removed if else condition. I used a C third conditional.
Now is no errors after 3 days later:))
You can see it below pictures what I did.
#define GPIO_BASEADDR_TO_CODE(x) ((x == GPIOA)?0 :\
(x == GPIOB)?1 :\
(x == GPIOA)? :\
(x == GPIOA)?3 :\
(x == GPIOA)?4 :\
(x == GPIOA)?5 :\
(x == GPIOA)?6 :\
(x == GPIOA)?7 :0 )
enter image description here

Related

Function Output is double but i get an error

For my following function I get the error message: This method must return a result of type double
But my output is a double. Where is my error?
if (currentAgent == Halteteil && predecessor == Oberteil) {
return 40.4;
} else if (currentAgent == Oberteil && predecessor == Ring) {
return 13.5;
}
Haltetil, Oberteil and Ring are my Agents.
The Output is the delaytime for my service Block
There is a possibility that neither condition is triggered. Java "sees" that and tells you via the error. You must provide a "fallback" as below:
if (currentAgent == Halteteil && predecessor == Oberteil) {
return 40.4;
} else if (currentAgent == Oberteil && predecessor == Ring) {
return 13.5;
}
return 0.;
If you like, you can "catch" that via an error msg or by returning -infinity but you have to give Java the ability to always return a double

how to check database limit and input no of count?

I have 10 images. im inserted that 10 images into database.then im tring to insert one more image.i want to one error message "only 10 images are occur" how to check database limit and input no of count?using laravel can you give validation code using laravel
my write controller.php is here
if(ForumGallery::count>=5)
{return "only 5 images";}
else
{ return Redirect::route('addgallery');}
but an error occur
http://Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Undefined class constant 'count'
my validation part
$validate=Validator::make(Input::all(),array(
'galname'=>'required|max:20',
'galimg'=>'required|max:200kb|Mimes:jpeg,jpg,gif,png
,pneg',
));
In Laravel eloquent, to return count use:
$max_image = 5;
if(ForumGallery::all()->count() <= $max_image)
{
ForumGallery::create($input); //call the function to upload image here
return Redirect::route('addgallery');
}
else
{
return "max image upload reached!";
}
Controller.php page
public function getgallery()
{
$validate=Validator::make(Input::all(),array(
'galname'=>'required|max:20',
'galimg'=>'required|max:200kb|Mimes:jpeg,jpg,gif,png
,pneg',
));
if($validate->fails())
{
return Redirect::route('getgallery')
->withErrors($validate)->withInput();
}
else
{
$file=Input::file('galimg');
$filename=$file->getClientOriginalName();
//->getClientOriginalExtension();
//$file->move('uploads',$filename);
// ForumGallery::create([
// 'galname'=>Input::get('galname'),
// 'galimg'=>$filename
// ]);
$max_image = 2;
if(ForumGallery::all()->count() < $max_image)
{
$file->move('uploads',$filename);
ForumGallery::create([
'galname'=>Input::get('galname'),
'galimg'=>$filename
]);//call the function to upload image here
return Redirect::route('addgallery');
}
else
{
return "max image upload reached!";
}
}
return Redirect::route('gallery');
}

scala - swing - listener and reactions for TextField to pass data

issue:
reaction += EditDone is not passing proper parameter that i am requesting from listener(this).
question:
am i handling passing the data to the listener or reactions incorrectly? if either, can you please illustrate the issue with an example and where exactly the issue resides?
much appreciated
desired outcome:
to process the TextField input and print the output to a TextArea
contents += new TextField(16)
{
val textField2:TextField = new TextField(16)
{
val reg = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"
listenTo(this)
try
{
if (contents == reg)
{
reactions += {
case e: EditDone =>
if (textField2 != reg)
{
println("Please type a valid num.")
}
else
{
println("just testing print")
textArea.text = myFunctionToProcessTextInput(textField2).toString
}
}
}
else
{
println("Please type a valid num.")
}
}
catch
{
case e: Throwable => println("There was an error. \n" + e.getStackTrace())
}
val button:Button = new Button("Click to process")
{
listenTo(mouse.clicks)
}
contents += button
}

Golang, build error inside function

So I have a really frustrating build error I have been staring at for the past hour or two. It involves one of my functions in my linked list program. It thinks I have statements outside the function when they are clearly inside, and thinks the { : } ratio is off. Am I missing something really simple?
// Index returns the location of element e. If e is not present,
// return 0 and false; otherwise return the location and true.
func (list *linkedList) Index(e AnyType) (int, bool) {
var index int = 0
var contain bool = false
if list.Contains(e) == false {
return 0, false
}
for int i := 0; i < list.count; i++ { \\175
list.setCursor(i)
if list.cursorPtr.item == e {
index = list.cursorIdx
contain = true
}
}
return index, contain \\182
} \\183
Build errors
./lists.go:175: syntax error: unexpected name, expecting {
./lists.go:182: non-declaration statement outside function body
./lists.go:183: syntax error: unexpected }
I appreciate any help. Thank you.
Looks like it's all line 175's fault, should be
for i := 0; i < list.count; i++ {
note I removed int

Need assistance with script task component: Am getting Index outbounds of the array

I am currently creating a SSIS program that reads data from a file, does some processing with that data, and outputs it to a OLE DB Destination task. However, everytime I run my application, I keep getting this error: "An error occurred: Index was outside the bounds of the array".I have changed my code many of times within the script task, but I still seem to be getting this error. Does anyone have any idea on what could be the problem? If so, any hints and suggestions would greatly be appreciated. Thanks.
This is my code within script task..
bool found=false;
try
{
while (Row.NextRow())
{
int Rows = 0;
int length = 0;
//int length = Row.Source.Length;
foreach (char c in Row.Source)
{
length++;
Console.Write(length);
}
while (found == false || length==0)
{
char c = Row.Source[Rows];
Rows++;
if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
{
length = length - 1;
}
else
{
while (length != 0)
{
Rows++;
if (Row.Source[Rows] != ' ')
{
Row.Source01 = Row.Source.Replace(Row.Source[Rows], ' ');
}
length = length - 1;
}
found = true;
}
}
found = false;
}
}
catch (Exception e)
{
bool pbCancel = false;
this.ComponentMetaData.FireError(0, "myScriptComponent", "An error occurred: " + e.Message, "", 0, out pbCancel);
}
}
}