Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!samsung!umich!caen!math.lsa.umich.edu!math.lsa.umich.edu!hyc From: hyc@math.lsa.umich.edu (Howard Chu) Newsgroups: comp.sys.atari.st Subject: Re: How to Get RS232 parameters? Keywords: RS232,parameters Message-ID: <1990Oct23.213419.13415@math.lsa.umich.edu> Date: 23 Oct 90 21:34:19 GMT References: <671@mrcu> <1990Oct23.035636.21144@ns.network.com> Sender: usenet@math.lsa.umich.edu Organization: University of Michigan Math Dept., Ann Arbor Lines: 38 In article <1990Oct23.035636.21144@ns.network.com> logajan@ns.network.com (John Logajan) writes: >In article <671@mrcu> ya16@mrcu (Ian Powell) writes: >>Does anyone know how to get the current RS232 parameters (modes an baud >>rate) form the ST, so that I can reset the RS232 as it was after use. >This state information is not saved by the OS as far as any of us have >been able to determine. In addtion, the serial hardware will not report >what its current configuration is. >It can't be done. :-) As pointed out in the TOS 1.4 release notes, the Rsconf call has been documented incorrectly for a long time. I think it mentions there that since TOS 1.2, passing a value of -2 for the baud rate parameter will cause the other parameters to be ignored, and the return value will be the current baud rate. Anyway, in all versions of TOS, Rsconf returns a long, but is usually documented to be of type void. The longword returned contains the 4 USART config bytes - receive status register, transmit control register, uart control reg, and sync character. You can use these return values to pick out the word size, parity, etc. as was described in a previous article. If you can't rely on the Rsconf behavior (e.g., will run on TOS 1.0) you can determine the baud rate with a simple timer loop. At the start of the loop you pick up the value of the 200hz system clock. Loop until the clock has incremented, say, a half second. (I don't remember the actual time to wait.) Set a countdown value for timer D at the startt of the loop. Retrieve the countdown value after the loop. By counting how many ticks occurred, you get the baud rate, since timer D is the baud rate generator. This is the technique used by Zmodem as hacked by Jwahar Bammi. This method is independent of CPU speed, so it works with accelerators and such. But, it doesn't work in MiNT. (Process switching throws the loop off. This really is a critical section, but I don't know how you can set it up appropriately.) -- -- Howard Chu @ University of Michigan one million data bits stored on a chip, one million bits per chip if one of those data bits happens to flip, one million data bits stored on the chip...