AnsweredAssumed Answered

Blackfin BF537 and VDK_postmessage

Question asked by chambaud on Jun 24, 2011
Latest reply on Jul 5, 2011 by chambaud

Hi,

 

I've been starting a new projet with a BF537 on a EZKITLITE and Visual DSP++5.0. I'would like some precision in relation with post/pend messages between thow threads. I've 3 threads running. A init thread start at boot thread and create 2 threads readValue_thread and Work_thread. The goal is that readValue_thread post a message to the Work_thread and Work_thread gives a respons to the readValue_thread. The code developped doesn't work. Could you give me some help ? I post the projet in "nouveaudossier.zip"

 

Thank you for your response.

 

void
init_thread_RunFunction(void **inPtr)
{
    /* Put the thread's "main" Initialization HERE */
  VDK_CreateThread(kreadValue_thread);
  VDK_CreateThread(kWork_thread);
 
    while (1)
    {
        /* Put the thread's "main" body HERE */

VDK_PostSemaphore(kread_ready);        /* Use a "break" instruction to exit the "while (1)" loop */
VDK_PendSemaphore(kinit_ready, 0);
}

 

Void
readValue_thread_RunFunction(void **inPtr)
{
    /* Put the thread's "main" Initialization HERE */
char m_vOutBuf[100];

    char *buffer = (char*)malloc((100+1)*sizeof(char));
   
   sprintf(buffer,"sentmessageOK\n");
  

if (buffer == NULL)
    {
      printf("failed to allocate memory to message buffer \n");
      return;
    }
unsigned int Nvoie = 100;
VDK_MessageID msg = VDK_CreateMessage(CONSIGNE,100, buffer);

  
   
    while (1)
    {
        /* Put the thread's "main" body HERE */
  
  
   VDK_SetMessagePayload ( msg, CONSIGNE, sizeof(buffer), buffer );
   VDK_PostMessage(kWork_thread,msg,CONTROL_CHANNEL);

   VDK_MessageID currMsg = VDK_PendMessage(RETURN_BUFF_CHANNEL,0);
 


        /* Use a "break" instruction to exit the "while (1)" loop */
    }

    /* Put the thread's exit from "main" HERE */
    /* A thread is automatically Destroyed when it exits its run function */
}

 

 

void
Work_thread_RunFunction(void **inPtr)
{
    /* Put the thread's "main" Initialization HERE */

  char *buffer1 = (char*)malloc((100+1)*sizeof(char));
 

 


    while (1)
    {
        /* Put the thread's "main" body HERE */

   // Get the next message
  VDK_MessageID msg = VDK_PendMessage(CONTROL_CHANNEL, 0);     
 
  // Get the details of the message
      VDK_MsgChannel channel;
     VDK_ThreadID sender;
     VDK_GetMessageReceiveInfo(msg, &channel, &sender);

  // Get the payload
  int      type;
  unsigned size;
  void    *pPayload;
  VDK_GetMessagePayload(msg, &type, &size, &pPayload);
 

   VDK_PostMessage(sender, msg, RETURN_BUFF_CHANNEL);

//VDK_PostSemaphore(kread_ready);


 

  //VDK_Yield();
        /* Use a "break" instruction to exit the "while (1)" loop */
    }

    /* Put the thread's exit from "main" HERE */
    /* A thread is automatically Destroyed when it exits its run function */
}

Attachments

Outcomes