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