char *serialdev = "/dev/ttyAPP1";
int RS485_GPIO_NUM = 103;
uartDevWriteBuf_plc_state = EMPTY;
uartDevReadBuf_plc_state = EMPTY;
bzero(&uartDev, sizeof(uartDev));
bzero(&uartDevReadBufA, sizeof(uartDevReadBuf_t));
bzero(&uartDevReadBufB, sizeof(uartDevReadBuf_t));
uartDevReadBuf_drv = &uartDevReadBufA;
uartDevReadBuf_plc = &uartDevReadBufB;
bzero(&uartDevWriteBufA, sizeof(uartDevWriteBuf_t));
bzero(&uartDevWriteBufB, sizeof(uartDevWriteBuf_t));
uartDevWriteBuf_drv = &uartDevWriteBufA;
uartDevWriteBuf_plc = &uartDevWriteBufB;
if((err = rt_mutex_create (&UART_WriteMutex, "UART_WriteMutex")))
if((err = rt_mutex_create (&UART_ReadMutex, "UART_ReadMutex")))
RS485_GPIO_dev = gpio_open(RS485_GPIO_NUM);
fprintf(stderr, "Error while initializing RS485 GPIO.\n");
UART_fd = openserial(serialdev);
fprintf(stderr, "Error while initializing %%s.\n", serialdev);
if((err = rt_task_create(&UART_task, "UART_task", 0, 50, T_JOINABLE)))
if(rt_task_start(&UART_task, &UART_task_proc, NULL))