CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Error with function pointer

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
afk_pic



Joined: 02 Jun 2020
Posts: 19

View user's profile Send private message

Error with function pointer
PostPosted: Wed Sep 08, 2021 9:15 am     Reply with quote

Hello,

I have this error and I need help, because this code works in other projects.

I have this error:
Code:

*** Error 144 "source\main.c" Line 297(1,1): No valid assignment made to function pointer  1779  from=??0 0 SCR=9430


My code gets a character from UART on every interrupt and it stores all chars received until the char "\0" carriage return. Then I pass this string by parameter to a function to analyze this string and parse arguments.

My main have this code:

main.c
Code:

#include "halRS232.h"

#if EXEC_UART_INT
#INT_RDA                     //interrupciones del puerto rs232 rx
void  rda_isr(void)
{
   char rx = getc(UART1);
   char endMsg = rxStringFromRS232(rx, rxRs232, 20);

   if (endMsg == 1)
   {
      msgDecoder(rxRs232, cmd, arg1, arg2, arg3);    //the error is here
      flagRS2323RxMsg = TRUE;
   }

   /////////////////////////////////////////////////////////////
   clear_interrupt(INT_RDA);
   enable_interrupts(INT_RDA);
}
#else
#endif



halRS232.c

Code:

void msgDecoder (char* msgToAnlze, char* cmd, char* arg1, char* arg2, char* arg3)
{

   static char* stringResult;
   char delimiter[] = " ";
   char numArgs = 0;

   strcpy(cmd, "");
   strcpy(arg1, "");
   strcpy(arg2, "");
   strcpy(arg3, "");

   stringResult = strtok(msgToAnlze, delimiter);
   strcpy(cmd, stringResult);

   if(stringResult != NULL){
      while(stringResult != NULL){

         numArgs = numArgs + 1;

            switch (numArgs) {
              case 1:
                 strcpy(cmd, stringResult);
                 break;
              case 2:
                 strcpy(arg1, stringResult);
                 break;
              case 3:
                 strcpy(arg2, stringResult);
                 break;
              case 4:
                 strcpy(arg3, stringResult);
                 break;
              default:
                 break;
         }

            stringResult = 0;
         stringResult = strtok(NULL, delimiter);

      }

   }

   //fin
}


halRS232.h
Code:

void msgDecoder (char* msgToAnlze, char* cmd, char* arg1, char* arg2, char* arg3);


Any idea??

Regards and thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 08, 2021 9:46 am     Reply with quote

I don't see a declaration of a function pointer anywhere in your program.
You also didn't post your variable declarations.

This guy is actually using function pointers and he gets the same
error message as you do:
http://www.ccsinfo.com/forum/viewtopic.php?t=59013&start=4
afk_pic



Joined: 02 Jun 2020
Posts: 19

View user's profile Send private message

PostPosted: Wed Sep 08, 2021 11:50 pm     Reply with quote

Hello,
this are my variables:

Quote:

unsigned char rxRs232[20];
unsigned char dummyString[20];
unsigned char command[10], argv1[10], argv2[10], argv3[10];
bool flagRS2323RxMsg = FALSE;



I insist in the fact that this code works in other project, has the same variable declarations even halRS232.c /.h are identical...very strange.

Thanks!



EDIT:

I have solved the issue: only I moved the function declaration msgDecoder to a new file .h and .c

EDIT2:

Calling the function in my void main (void) it's works. But if I call the function in the interrupt routines gives me the same error, check the op thread.


Code:

#if EXEC_UART_INT
#INT_RDA         //interrupciones del puerto rs232 rx
void  rda_isr(void)
{
   char rx = getc(UART1);
   char endMsg = rxStringFromRS232(rx, rxRs232, 20);

   if (endMsg == 1)
   {
      msgDecoder(rxRs232, command, argv1, argv2, argv3);
      flagRS2323RxMsg = TRUE;
   }

   /////////////////////////////////////////////////////////////
   clear_interrupt(INT_RDA);
   enable_interrupts(INT_RDA);
}
#else
#endif




EDIT3:

Looks the problem is with the name of the header/source file...I copied the function to another header/source file and it works.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group