in
Creating Smarter Networks

Driver rs232 with parity

Last post 11-07-2008 7:40 AM by amingo. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-15-2008 7:56 AM

    • amingo
    • Top 10 Contributor
    • Joined on 05-05-2008
    • Posts 10
    • Points 155

    Driver rs232 with parity

    Hi friends,

         I have developed a FPM to control the RS-232 port of the SmartServer. I have worked with 9600 baudios and I can change the speed to 19200 baudios without problems using the function rs232_ioctl (). I can send and receive information without problems and monitor the data using an oscilloscope. My problem appear because I want to use even parity. I enable this option using the function rs232_ioctl () and the command and data IOCTL_PARITY and PARENB but when I send any information the parity bit doesn´t appear. The source code is the next:

    _rs232_fd = rs232_open(9600);

     

    rs232_ioctl(_rs232_fd,IOCTL_BAUDRATE,19200);

    rs232_ioctl(_rs232_fd,IOCTL_PARITY,PARENB);

     

    I want to know if is is neccesary initiliaze another parameter or it is impossible change the parity of the data.

    Thanks,

         Alejandro de Mingo

     

     

    • Post Points: 20
  • 10-28-2008 8:35 AM In reply to

    • chelo
    • Top 10 Contributor
    • Joined on 12-28-2007
    • Posts 11
    • Points 130

    Re: Driver rs232 with parity

     Hi Alejandro,

    to set parity, use the following function (See page 217 ióf the Programmability Tools User's Guide):
    rs232_ioctl(fd, IOCTL_SIO_HW_OPTS_SET, (options | PARENB | PARODD));

     

    I recommend to update to the new Service Pack 2 because there is a RS232 fix mentioned in the Readme. 

     

    • Post Points: 20
  • 11-07-2008 7:40 AM In reply to

    • amingo
    • Top 10 Contributor
    • Joined on 05-05-2008
    • Posts 10
    • Points 155

    Re: Driver rs232 with parity

    Hi Chelo,

     

         I have configured my serial port (computer) with 9600 baudios, 8 bits of data, without parity and one bit stop.

         If I open the with:

                 _rs232_fd = rs232_open(9600);

         the read and write is properly with rs232_read () and rs232_write functions().

         Now I configure my serial port (computer) with 9600 baudios, 8 bits of data, odd parity and one bit stop.

         In this case I use the next configuration:

              _rs232_fd = rs232_open(9600);

              int options = rs232_ioctl(_rs232_fd,IOCTL_SIO_HW_OPTS_GET, 0);

              rs232_ioctl(fd, IOCTL_SIO_HW_OPTS_SET, (options | PARENB | PARODD));

        After reboot the SmartServer the variable options has the value 0. The value 0 show me that the serial port has been opened properly. With the use of rs232_ioctl () function I update IOCTL_SIO_HW_IPTS_SET with the value 192 bit in this case I can not read or write information.

        I have updated my computer with the last servipack of the SmartServer.

        Is there another way to change the parity of the serial port?

     

        Best regards,

                  Alex

    • Post Points: 5
Page 1 of 1 (3 items)
©2008 Echelon Corporation