Pumpkin, Inc.

Pumpkin User Forums

Passing string (or other structure's) via SignalMsg

If you can't make Salvo do what you want it to do, post it here.

Re: Passing string (or other structure's) via SignalMsg

Postby sharaf_embedded » Mon Jan 10, 2005 5:13 am

Hii
I have problem signalling and waiting a string. When I tried the piece of code, I got the op as:
TaskA
TaskB
Message received is ag.
This is the same whatever character Dir[1] is.

My code is:

code:
void TaskA( void )
{
int i;
OStypeMsgP msgP;
printf("TaskA
");
while(1)
{
OS_WaitMsg(MSG_RELOAD_TIMER, &msgP, OSNO_TIMEOUT, TaskA1);
printf("Message received is: ");
for (i = 0; i < 2; i++)
{
printf("%c",*(unsigned char *)msgP);
msgP++;
}
OS_Yield(TaskA1);
}
}

unsigned char Dir[2] = "ax";
void TaskB( void )
{
printf("TaskB
");
OSSignalMsg(MSG_RELOAD_TIMER, (OStypeMsgP) &Dir);
OS_Yield(TaskB1);
}


Thanks,
Sharaf


[This message has been edited by aek (edited January 10, 2005).]

sharaf_embedded
 
Posts: 5
Joined: Tue Jan 04, 2005 12:00 am
Location: Malappuram, Kerala, India

Re: Passing string (or other structure's) via SignalMsg

Postby aek » Mon Jan 10, 2005 5:49 am

Hi Sharaf.

1) For a test like this, you should use OS_Stop() in TaskB(). O/wise the run-time behavior is undefined, as the code will "fall out of" TaskB() and go places where it shouldn't. Note the lack of an infinite loop to contain OS_Yield() in TaskB().

2) A quick look at your code suggests to me that the problem is in msgP++. Since msgP++ is of type OStypeMsgP, msgP++ does not do what you think (move to the next character in Dir[]). What you need to do is create a local unsigned char pointer which is a copy of msgP, and then you can increment it (the local pointer to unsigned char), etc.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Previous

Return to Coding

Who is online

Users browsing this forum: No registered users and 3 guests

cron