milo@ndmath.UUCP (Greg Corson) (07/07/89)
Is there a method where I can read the number of characters currently stacked up in the serial driver OUTPUT buffer? I know there is a way to read the number of characters in the INPUT buffer, I need to be able to read the number in the OUTPUT buffer too. Greg Corson 19141 Summers Drive South Bend, IN 46637 (219) 277-5306 {pur-ee,rutgers,uunet}!iuvax!ndmath!milo
paul@taniwha.UUCP (Paul Campbell) (07/07/89)
In article <1472@ndmath.UUCP> milo@ndmath.UUCP (Greg Corson) writes: >Is there a method where I can read the number of characters currently >stacked up in the serial driver OUTPUT buffer? > >I know there is a way to read the number of characters in the INPUT buffer, >I need to be able to read the number in the OUTPUT buffer too. It depends what you mean by 'the output buffer' - there are two, the buffer you pass the data in, and a buffer in the SCC chip. A write completes when the last character is transfered from the memory buffer into the chip, NOT when the last character has been sent. On the current hardware the on chip buffer is 1 character. This is good and bad, good because it means you have 1 character time (say 1mS at 9600) to get the next write done, bad because you thought it had all been sent - if you are taking into account how long the data takes to send (for retries etc) your program will break on systems with bigger buffers (for example on a serial card with a large buffer [like mine - 6k] a 2k write might return almost right away). Very few programs currently seem to depend on this, I find that AppleLink is the worst offender [I had to put in an option to wait untill the output drains before writes complete so it wouldn't go so painfully slowly]. However I didn't answer your question, just made it harder .... and there isn't a 'standard' way to find out how many characters are stacked up, you can peek at the Mac serial driver's globals but then you will break if you use it with other serial cards, or in a future Mac system with memory protection etc Paul -- Paul Campbell UUCP: ..!mtxinu!taniwha!paul AppleLink: D3213 "Free Market": n. (colloq.) a primitive fertility goddess worshipped by an obscure cult in the late 20th C. It's chief priest 'Dow Jones' was eventually lynched by an enraged populace during an economic downturn (early 21st C).