in
Creating Smarter Networks

Driver rs485

Last post 10-31-2008 7:27 AM by moombasan. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-22-2008 3:29 AM

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

    Driver rs485

    Hi friends,

         I´m trying to develop different drivers for rs485 and rs232 port. In the last post I described my problem with rs232 port and now I have a question for rs485 port. I want to write and read using the rs485 port. When I use the functions for write (change speed, parity, ...) I have no problem with them but my problem appear when I want to read. I use the same functions that work properly for rs232 port but the driver stop to work and the SmartServer reboots itself when I use the read functions.

       The source code that I use for read is the next:

     ioctl (_rs485_fd,FIONREAD, (int)&nBytesToRead);

     

    if(rs485_read(_rs485_fd,Line,nBytesToRead) >= 0)

    {

    }

    I want to if there is somebody that have work with this port and read information properly.

     

    Best regards,

     

         Alex

     

    • Post Points: 20
  • 10-31-2008 7:27 AM In reply to

    • moombasan
    • Top 50 Contributor
    • Joined on 06-06-2008
    • germany
    • Posts 1
    • Points 5

    Re: Driver rs485

    hi alex,

    you cannot use ioctl(_rs485_fd, FIONREAD, (int)&nBytesToRead); to determine how many bytes to read. this will result in a call to rs232 with a potentially invalid handle.

    you need to use rs485_read( _rs485_fd, Line, nBytesToRead ) with a specific buffer size (nBytesToRead). rs485_read() returns the number of bytes that really were read. please see also the Programmability Tools User's Guide, appendix a, page 222: description of rs485_read() (especially the length parameter).

    note: looking into the readme of the new SmartServer Service Pack 2, there has also been a bugfix regarding rs485. so i would recommend using SmartServer Service Pack 2

    /best

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