Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>RTS_CONTROL_TOGGLE</em> does not work (has a variable 1-15 millisecond delay before turning it off after transmit) on our embedded XP platform. It's possible I could get that down if I altered the time quantum to 1 ms using timeBeginPeriod(1), etc, but I doubt it would be reliable or enough to matter. (The device responds @ 1 millisecond sometimes)</p> <p>The final solution is really ugly but it works on this hardware. I would not use it on anything where the hardware is not fixed in stone.</p> <p>Basically:</p> <p>1) set the FIFOs on the serial port's device manager page to off or 1 character deep</p> <p>2) send your message + <strong>2 extra bytes</strong> using this code:</p> <pre><code>int WriteFile485(HANDLE hPort, void* pvBuffer, DWORD iLength, DWORD* pdwWritten, LPOVERLAPPED lpOverlapped) { int iOldClass = GetPriorityClass(GetCurrentProcess()); int iOldPriority = GetThreadPriority(GetCurrentThread()); SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); EscapeCommFunction(hPort, SETRTS); BOOL bRet = WriteFile(hPort, pvBuffer, iLength, pdwWritten, lpOverlapped); EscapeCommFunction(hPort, CLRRTS); SetPriorityClass(GetCurrentProcess(), iOldClass); SetThreadPriority(GetCurrentThread(), iOldPriority); return bRet; } </code></pre> <p>The WriteFile() returns when the last byte or two have been written to the serial port. They have NOT gone out the port yet, thus the need to send 2 extra bytes. One or both of them will get trashed when you do CLRRTS.</p> <p>Like I said... it's ugly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload