Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by eugenio Monti
Fri, 17 Mar 2006 08:13
Serial port management with RTS_TOGGLE
Author: eugenio Monti
Date: Fri, 17 Mar 2006 08:13
Date: Fri, 17 Mar 2006 08:13
23 lines
1891 bytes
1891 bytes
I have an application developed with C++Builder6 that manages a serial protocol with external devices on a RS485 bus. It manages a COM device using Windows API. The way to enable the TX section of RS485 transceiver is drive the RTS signal, so I used the SetCommState API setting the fRtsControl field of DCB to RTS_TOGGLE value. This approach works fine in any PC I tried from Windows95 to WinXP. I have a problem on a DELL notebook with WinXP SP2 and CENTRINO processor. My application sends a frame but RTS signal remains high for 15 ms. instead of 1-2 ms.!!!!! I tried to install the trial versione of BDS2006 and recompile my project and...suprise...it works well and RTS signal goes down in 1 ms.! I was convinced that Windows APIs were Windows APIs so they aren't affected by other layers of development tools...but probably isn't true! Is there someone can explain me this behaviour? How can I work around this bug using C++Builder6? Thanks in advance. Bye. Eugenio Monti
Re: Serial port management with RTS_TOGGLE
Author: SF
Date: Fri, 17 Mar 2006 13:12
Date: Fri, 17 Mar 2006 13:12
52 lines
2736 bytes
2736 bytes
> The way to enable the TX section of RS485 transceiver is > drive the RTS signal, so I used the SetCommState API setting > the fRtsControl field of DCB to RTS_TOGGLE value. > This approach works fine in any PC I tried from Windows95 > to WinXP. IMHO, you've only been lucky. At first, RTS_CONTROL_TOGGLE is not supported under Win95, Win98 and WinMe as stated in MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/dcb_str.asp. Secondly, as far as I know, there's no way to control the real end of transmission under WindowsNT/2000/XP. In the old time of DOS, we could read the status of the shift register. That could also be done under Win95/98 although not a clean solution. Nevertheless, through Windows API, we can check the status (empty or not) of the trasmission buffer that is not necessary the serial trasmission status (finished or not). > I have a problem on a DELL notebook with WinXP SP2 and > CENTRINO processor. > My application sends a frame but RTS signal remains high for > 15 ms. > instead of 1-2 ms.!!!!! That's strange, anyway. RTS goes down sooner than the end of transmission, usually. Maybe a particular serial driver is installed there. > I tried to install the trial versione of BDS2006 and recompile > my > project and...suprise...it works well and RTS signal goes down > in 1 ms.! I don't know about this. > Is there someone can explain me this behaviour? Not the last one. Instead, about how to handle properly a 485 transmission under WinXP, well, I've been looking for a good solution for years... no one found so far. > How can I work around this bug using C++Builder6? A good suggestion? Use a "smart" 232/485 converter. No need to drive the RTS signal any more. HTH, Stefano.
Re: Serial port management with RTS_TOGGLE
Author: Tom Woodrow
Date: Fri, 05 May 2006 01:39
Date: Fri, 05 May 2006 01:39
80 lines
3752 bytes
3752 bytes
Hi, I think that I agree. Even using the TX uffer empty is of no use because it just indicates that the last data has been tranfered to the USRT. As far as I know, there is no reliable way to tell just when the last bit has left the UART out into cyber space. Even calculating the how long it would take to transmit n bits at the current baud rate, parity and stop bit settings is unreliable. If you are driving RS232 into a radio its not much of a problem to add a little time but with RS485, the turnaround time is critical and you must switch to receive after the last bit is transmitted and before the external device responds. Tom Woodrow SF wrote: >>The way to enable the TX section of RS485 transceiver is >>drive the RTS signal, so I used the SetCommState API setting >>the fRtsControl field of DCB to RTS_TOGGLE value. > > >>This approach works fine in any PC I tried from Windows95 >>to WinXP. > > > IMHO, you've only been lucky. > > At first, RTS_CONTROL_TOGGLE is not supported under Win95, Win98 > and WinMe as stated in MSDN: > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/dcb_str.asp. > > Secondly, as far as I know, there's no way to control the real > end of transmission under WindowsNT/2000/XP. In the old time of > DOS, we could read the status of the shift register. That could > also be done under Win95/98 although not a clean solution. > Nevertheless, through Windows API, we can check the status > (empty or not) of the trasmission buffer that is not necessary > the serial trasmission status (finished or not). > > >>I have a problem on a DELL notebook with WinXP SP2 and >>CENTRINO processor. >>My application sends a frame but RTS signal remains high for >>15 ms. >>instead of 1-2 ms.!!!!! > > > That's strange, anyway. RTS goes down sooner than the end of > transmission, usually. Maybe a particular serial driver is > installed there. > > >>I tried to install the trial versione of BDS2006 and recompile >>my >>project and...suprise...it works well and RTS signal goes down >>in 1 ms.! > > > I don't know about this. > > >>Is there someone can explain me this behaviour? > > > Not the last one. Instead, about how to handle properly a 485 > transmission under WinXP, well, I've been looking for a good > solution for years... no one found so far. > > >>How can I work around this bug using C++Builder6? > > > A good suggestion? Use a "smart" 232/485 converter. No need to > drive the RTS signal any more. > > HTH, > > Stefano. > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads