Task unexpected restart when sending bytes to usart.
Daniel Li
ludvig.lee at gmail.com
Fri Aug 28 02:59:39 UTC 2020
Hi Joel
I think you are right, it is a complete reset. I don't know the reason
for the system reset. My test code is as below. System will reset after
about 40min.
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <rtems/error.h>
#include <rtems/libio.h>
#include <rtems/stackchk.h>
#include <libchip/chip.h>
#include <bsp.h>
#define PORT "/dev/ttyUART1"
#define PIN_UART1_RXD
{PIO_PA5C_URXD1, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT}
#define PIN_UART1_TXD
{PIO_PA4C_UTXD1, PIOA, ID_PIOA, PIO_PERIPH_C, PIO_DEFAULT}
#define PIN_LED_0
{PIO_PC9, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}
const Pin pins[] = { PIN_UART1_RXD, PIN_UART1_TXD, PIN_LED_0 };
rtems_task task_send( rtems_task_argument task_index )
{
char* send_string =
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
; /* character count : 400 */
int index = 1;
rtems_status_code sc = rtems_termios_bufsize( 512, 512, 512 );
if (sc > 0) {
perror("rtems_termios_bufsize(): failed \n");
}
int fd = open(PORT, O_RDWR);
if (fd < 0) {
perror("open(): failed to open /dev/ttyUART1 \n");
}
while (1) {
int len = write(fd, send_string, 200);
if (len < 0) {
perror("write(): failded to write\n");
close(fd);
exit(-1);
}
(void) rtems_task_wake_after( rtems_clock_get_ticks_per_second() / 20
);
}
}
rtems_task task_led( rtems_task_argument task_index )
{
while(1) {
if (PIO_GetOutputDataStatus(&pins[2]))
PIO_Clear(&pins[2]);
else
PIO_Set(&pins[2]);
(void) rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
}
}
rtems_task Init( rtems_task_argument argument )
{
rtems_id task_id[ 4 ];
rtems_name task_name[ 4 ];
task_name[ 1 ] = rtems_build_name( 'S', 'N', 'D', ' ' );
task_name[ 2 ] = rtems_build_name( 'L', 'E', 'D', ' ' );
PIO_Configure(pins, PIO_LISTSIZE(pins));
puts("This is the Init Thread.\n");
(void) rtems_task_create(
task_name[ 1 ], 1, RTEMS_MINIMUM_STACK_SIZE * 4, RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &task_id[ 1 ]
);
(void) rtems_task_create(
task_name[ 2 ], 2, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES, &task_id[ 2 ]
);
(void) rtems_task_start( task_id[ 1 ], task_send, 1 );
(void) rtems_task_start( task_id[ 2 ], task_led, 2 );
(void) rtems_task_delete( RTEMS_SELF );
}
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
#define CONFIGURE_TICKS_PER_TIMESLICE 5
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 10
#define CONFIGURE_INIT_TASK_STACK_SIZE (2 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_EXTRA_TASK_STACKS (4 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_MAXIMUM_TASKS 5
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
Thanks
Daniel
On Thu, Aug 27, 2020 at 7:52 PM Joel Sherrill <joel at rtems.org> wrote:
>
>
> On Thu, Aug 27, 2020, 2:33 AM Daniel Li <ludvig.lee at gmail.com> wrote:
>
>>
>> Hello world
>>
>> I'm using RTEMS5 as an uart2udp converter. I'm observing a task restart
>> when I send bytes to uart for a long time ( for 20min @ about 200 bytes/s
>> ), and there is no error reported. I don't know how to overcome, anyone
>> encountered this problem?
>>
>
> Are you sure it isn't a complete reset? That would make more sense to me
> as a possibility.
>
>>
>> Thanks
>>
>> Daniel
>>
>> _______________________________________________
>> users mailing list
>> users at rtems.org
>> http://lists.rtems.org/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20200828/266bed1d/attachment-0001.html>
More information about the users
mailing list