AnsweredAssumed Answered

RS485 with UART from LS1021a

Question asked by Jan Brand on Apr 12, 2016
Latest reply on Apr 13, 2016 by Jan Brand


I want to use RS485 through the UART1 from a costum Board. UART1_SIN, UART1_SOUT and UART1_RTS are connected to the RS485 Transceiver. I'm using the QorIQ 1.8 SDK. Receiving data from a PC through RS485 is possible with cat /dev/ttyS0.



For Sending data from my board there has to be a driver to set the RTS-Signal, because Linux thinks ttyS0 is a normal RS232 (correct me if I'm wrong). So I first modified my device tree for the board:


&duart0 {


  rs485-rts-delay = <0 200>;


  rs485-mode = <1>;

  status = "okay";



then i searched different communities and copied/wrote a little application trying to send data through RS485:



#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <string.h>

#include <asm-generic/ioctl.h>

#include <asm-generic/fcntl.h>

#include <errno.h>

#include <termios.h>

#include <linux/serial.h>

#include <asm-generic/ioctls.h>


//Control struct for setting the port in 485 mode


int main(void){

  struct serial_rs485 rs485conf;

  int rv, i;

  char buffer[20];


  int fd = open ("/dev/ttyS0", O_RDWR);

  if (fd < 0) {

         /* Error handling. See errno. */


  return 0;



  rs485conf.flags |= SER_RS485_ENABLED;

  rs485conf.flags |= SER_RS485_RTS_ON_SEND;

  rs485conf.delay_rts_before_send = 0;


  rv = ioctl(fd,TIOCSRS485, &rs485conf);


      printf("rv = %d\n", rv);

       perror("unable to set IOCTL:");



   for (i=0; i<20; i++){

       buffer[i] = 'A' + i;



  for (i=0; i<30;i++){

       printf("Writing [%d]\n", i);

       write(fd, buffer, 20);



  rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);




return 0;




when i execute this code after compiling and building, there comes the following message:

"unable to set IOCTL:: Inappropriate ioctl for device"


Does that mean, that the ioctl() does not support TIOCSRS485 and so the RS485 structure, yet? In the serial.h the struct serial_rs485 is already implementet. Do i missed something? I'm confused about the depth RS485 is integrated in the kernel...


What can i do, to get RS485 work?


king regards,