RS485

      Hi,

      I try to initialize the RS845 serial port. In several examples that I've got to use the
      TIOCGRS485 to get the struct and TIOCSRS485 to write the structure back.

      Everytime I call the ioctl I receive an Invalid Argument error, which I think means
      that it's not supported on PicoCOM4. Do you have an example to initialize the RS485 correctly?

      Thanks

      Marc

      Source Code

      1. int initport ( int fd ) {
      2. struct termios options;
      3. // Get the current options for the port...
      4. tcgetattr ( fd, &options );
      5. // Set the baud rates to 19200...
      6. cfsetispeed ( &options, B38400 );
      7. cfsetospeed ( &options, B38400 );
      8. // Enable the receiver and set local mode...
      9. //options.c_cflag |= ( CLOCAL | CREAD );
      10. options.c_cflag = CS8|CREAD|IGNPAR;
      11. options.c_iflag = 0;
      12. options.c_oflag = 0;
      13. // DISABLE this: Echo input characters.
      14. options.c_lflag &= ~(ICANON);
      15. options.c_lflag &= ~(ECHO);
      16. // DISABLE this: If ICANON is also set, the ERASE character
      17. // erases the preceding input
      18. // character, and WERASE erases the preceding word.
      19. options.c_lflag &= ~(ECHOE);
      20. // DISABLE this: When any of the characters INTR, QUIT, SUSP,
      21. // or DSUSP are received, generate the corresponding signal.
      22. options.c_lflag &= ~(ISIG);
      23. // Minimum number of characters for non-canonical read.
      24. options.c_cc[VMIN]=1;
      25. // Timeout in deciseconds for non-canonical read.
      26. options.c_cc[VTIME]=0;
      27. struct serial_rs485 rs485conf;
      28. // Set the new options for the port...
      29. if (ioctl (fd, TIOCGRS485, &rs485conf) < 0) {
      30. printf("Error: TIOCGRS485 ioctl not supported.\n");
      31. }
      32. /* Enable RS485 mode: */
      33. rs485conf.flags |= SER_RS485_ENABLED;
      34. /* Set logical level for RTS pin equal to 1 when sending: */
      35. //rs485conf.flags |= SER_RS485_RTS_ON_SEND;
      36. /* or, set logical level for RTS pin equal to 0 when sending: */
      37. //rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND);
      38. /* Set logical level for RTS pin equal to 1 after sending: */
      39. //rs485conf.flags |= SER_RS485_RTS_AFTER_SEND;
      40. /* or, set logical level for RTS pin equal to 0 after sending: */
      41. //rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND);
      42. /* Set rts delay before send, if needed: */
      43. //rs485conf.delay_rts_before_send = ...;
      44. /* Set rts delay after send, if needed: */
      45. //rs485conf.delay_rts_after_send = ...;
      46. /* Set this flag if you want to receive data even whilst sending data */
      47. //rs485conf.flags |= SER_RS485_RX_DURING_TX;
      48. int retval = ioctl (fd, TIOCSRS485, &rs485conf);
      49. if (retval < 0) {
      50. printf("Error: TIOCSRS485 ioctl not supported.\n");
      51. }
      52. tcsetattr ( fd, TCSANOW, &options );
      53. return 1;
      54. }
      Hi,

      I've done some more investigations. It seems that the ttySAC1 is already used for console (may be it couldn't be set to rs485 when used).

      Source Code

      1. # cat /proc/cmdline
      2. console=ttySAC1,38400 mtdparts=pc4nand0:3m@0x100000(Kernel),-(TargetFS) init=linuxrc root=/dev/mtdblock1 rw rootfstype=jffs2 ethaddr=00:05:51:04:D1:89

      Is there a way to switch the console <> ttySAC1 binding off? Or, when its not possible to switch it to ttySAC0?

      Thanks for your help

      marc
      The serial driver of the PicoCOM4 does not support TIOCSRS485 and TIOCGRS485. In other words it does not support RS485. Sorry.

      Your F&S Support Team
      F&S Elektronik Systeme GmbH
      As this is an international forum, please try to post in English.
      Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.