Problem with messages

Aleix Conchillo Flaqué aconchillo at ieec.cat
Tue Mar 20 11:52:36 UTC 2007


The parameters are inverted, you should have "1,40" instead of  
"40,1", that is one message in the queue of maximum size 40.

Cheers,

Aleix

On 20 Mar 2007, at 11:24, Leon Pollak wrote:

> But the buflen parameter is set to 40.
>
> On Tuesday 20 March 2007, you wrote:
>> Hi Mr. Pollak,
>>
>> thank you very much for your quick response.
>>
>> When I change the message buffer length parameter at queue creation
>> to 4 or 8 bytes width, unfortunately it doesn't change anything.
>>
>> Kind regards,
>> Hank
>>
>> Quoting Leon Pollak <leonp at plris.com>:
>>> IMHO, you have defined message length parameter (in queue creation)
>>> as 1 byte,
>>> but try to send a pointer, which is 4 bytes length.
>>>
>>> On Tuesday 20 March 2007, hwulf at et-inf.fho-emden.de wrote:
>>>> Hi,
>>>>
>>>> I'm rather new to RTEMS and I wanted to try out the message queues.
>>>> I'm checking the status codes with a hand-written  
>>>> print_status_code()
>>>> function. Creating of the message queues is successful, but when
>>>> trying to send a message from user_task_1 to user_task_2, RTEMS
>>>> says "RTEMS_INVALID_SIZE".
>>>>
>>>> Does anybody have an idea?
>>>>
>>>> The example code is shown below.
>>>>
>>>> Thank you very much and kind regards,
>>>> Hank
>>>>
>>>>
>>>>
>>>>
>>>> / 
>>>> ******************************************************************* 
>>>> ****
>>>> *** **** *
>>>>   * INIT
>>>>   *
>>>>   *
>>>> ******************************************************************* 
>>>> *****
>>>> *** */ rtems_task Init(rtems_task_argument argument)
>>>> {
>>>> 	rtems_status_code status;
>>>>
>>>>
>>>> 	puts("\n\n*** TASK COMMUNICATION TEST ***");
>>>> 	/*
>>>> 	 * Building necessary names
>>>> 	 */
>>>> 	Task_name[1] = rtems_build_name('T', 'S', 'K', '1');
>>>> 	Task_name[2] = rtems_build_name('T', 'S', 'K', '2');
>>>> 	Queue_name[1] = rtems_build_name('Q', 'U', 'E', '1');
>>>> 	Queue_name[2] = rtems_build_name('Q', 'U', 'E', '2');
>>>> //	Semaphore_name[1] = rtems_build_name('S', 'E', 'M', '1');
>>>> //	Semaphore_name[2] = rtems_build_name('S', 'E', 'M', '2');
>>>>
>>>> 	/*
>>>> 	 * Create the user tasks
>>>> 	 */
>>>> 	status = rtems_task_create(Task_name[1], 1,  
>>>> RTEMS_MINIMUM_STACK_SIZE *
>>>> 2, RTEMS_DEFAULT_MODES | RTEMS_PREEMPT | RTEMS_TIMESLICE,
>>>> RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 1 ]);
>>>>    	print_status_code(status, "Creating Task 1");
>>>>
>>>> 	status = rtems_task_create(Task_name[2], 1,  
>>>> RTEMS_MINIMUM_STACK_SIZE *
>>>> 2, RTEMS_DEFAULT_MODES | RTEMS_PREEMPT | RTEMS_TIMESLICE,
>>>> RTEMS_DEFAULT_ATTRIBUTES, &Task_id[ 2 ]);
>>>>    	print_status_code(status, "Creating Task 2");
>>>>
>>>> 	/*
>>>> 	 * Create the message queues
>>>> 	 */
>>>> 	status = rtems_message_queue_create(Queue_name[1], 40, 1,
>>>> 							RTEMS_LOCAL, &Queue_id[1]);
>>>> 	print_status_code(status, "Creating Message Queue 1");
>>>>
>>>> 	status = rtems_message_queue_create(Queue_name[2], 1, 1,
>>>> 							RTEMS_FIFO | RTEMS_LOCAL, &Queue_id[2]);
>>>> 	print_status_code(status, "Creating Message Queue 2");
>>>>
>>>> 	/*
>>>> 	 * Create the semaphores
>>>> 	 */
>>>> //	status = rtems_semaphore_create(Semaphore_name[1], 1,
>>>> //							RTEMS_FIFO | RTEMS_BINARY_SEMAPHORE |
>>>> //							RTEMS_NO_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING |
>>>> //							RTEMS_LOCAL, 2, &Semaphore_id[1]);
>>>> //	print_status_code(status, "Creating Semaphore 1");
>>>>
>>>> //	status = rtems_semaphore_create(Semaphore_name[2], 1,
>>>> //							RTEMS_FIFO | RTEMS_BINARY_SEMAPHORE |
>>>> //							RTEMS_NO_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING |
>>>> //							RTEMS_LOCAL, 2, &Semaphore_id[2]);
>>>> //	print_status_code(status, "Creating Semaphore 2");
>>>>
>>>> 	status = rtems_task_start( Task_id[ 1 ], user_task_1, 0 );
>>>> //	rtems_task_wake_after( 100 );
>>>> 	status = rtems_task_start( Task_id[ 2 ], user_task_2, 0 );
>>>>
>>>> //	rtems_task_wake_after( 5000 );
>>>>
>>>> 	status = rtems_task_delete( RTEMS_SELF );
>>>> }
>>>> #include <stdio.h>
>>>>
>>>> / 
>>>> ******************************************************************* 
>>>> ****
>>>> *** **** *
>>>>   * USER_TASK1
>>>>   *
>>>>   *
>>>> ******************************************************************* 
>>>> *****
>>>> *** */ rtems_task user_task_1(rtems_task_argument unused)
>>>> {
>>>> //	rtems_id          tid;
>>>> //	rtems_unsigned32  task_index;
>>>> 	rtems_status_code status;
>>>> //	rtems_event_set task1_event;
>>>> 	char buffer[40] = "Hello World!\n";
>>>> 	rtems_unsigned32 buflen = 40;
>>>>
>>>> 	status = rtems_message_queue_send(Queue_id[1], (void*)buffer,  
>>>> buflen);
>>>> 	print_status_code(status, "Message sent.");
>>>> 	printf("Task 1: This message was sent to Task 2: %s\n", buffer);
>>>> 	//rtems_message_queue_receive(Queue_id[1], (void*)&buffer,  
>>>> &buflen,
>>>> RTEMS_WAIT, RTEMS_NO_TIMEOUT);
>>>>
>>>> 	rtems_task_wake_after(100);
>>>>
>>>>
>>>> }
>>>>
>>>> / 
>>>> ******************************************************************* 
>>>> ****
>>>> *** **** *
>>>>   * USER_TASK2
>>>>   *
>>>>   *
>>>> ******************************************************************* 
>>>> *****
>>>> *** */ rtems_task user_task_2(rtems_task_argument unused)
>>>> {
>>>> 	rtems_id          tid;
>>>> 	rtems_unsigned32  task_index;
>>>> 	rtems_status_code status;
>>>> 	rtems_event_set task2_event = 100;
>>>> 	char buffer[40] = "Hello World back!\n";
>>>> 	rtems_unsigned32 buflen = 40;
>>>>
>>>> 	//rtems_message_queue_send(Queue_id[1], (void*)&buffer, buflen);
>>>> 	status = rtems_message_queue_receive(Queue_id[1], (void*)&buffer,
>>>> &buflen, RTEMS_NO_WAIT, 10);
>>>> 	print_status_code(status, "Message received.");
>>>> 	//printf("Task 2: This message was received: %s\n", buffer);
>>>> 	//rtems_task_wake_after(1);
>>>> }
>>>>
>>>> _______________________________________________
>>>> rtems-users mailing list
>>>> rtems-users at rtems.com
>>>> http://rtems.rtems.org/mailman/listinfo/rtems-users
>>>
>>> --
>>> Dr.Leon M.Pollak
>>>     Director
>>> PLR Information Systems Ltd.
>>> Tel.:+972-98657670
>>> Fax.:+972-98657621
>>> Mob.:+972-544739246
>>> _______________________________________________
>>> rtems-users mailing list
>>> rtems-users at rtems.com
>>> http://rtems.rtems.org/mailman/listinfo/rtems-users
>
>
>
> -- 
> Dr.Leon M.Pollak
>     Director
> PLR Information Systems Ltd.
> Tel.:+972-98657670
> Fax.:+972-98657621
> Mob.:+972-544739246
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users




More information about the users mailing list