Xref: utzoo comp.os.msdos.programmer:471 alt.msdos.programmer:2029 Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer Path: utzoo!telly!robohack!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Subject: Re: Microsoft C & serial comms Message-ID: <1990Aug12.235217.25638@druid.uucp> Organization: D'Arcy Cain Consulting, West Hill, Ontario References: <990@dcl-vitus.comp.lancs.ac.uk> <32673@cup.portal.com> Date: Sun, 12 Aug 90 23:52:17 GMT In article <32673@cup.portal.com> PLFaith@cup.portal.com (Patrick L Faith) writes: >well "break" is used a couple of different ways, but they all come >down to this, if the serial port does not transfer a character at >the specified baud rate for the 8/7 bits of time it takes, then >there is a break set in the serial driver(atleast if you are using u8250). >So breaks are all to easy to send, just dont put anything out through >the port for a given amount of time - 500 mSec is fine - so is 2 seconds. >I like the book "C programmers guide to serial communications" of its 600+ >pages it devotes about 2 pgs to break, which isn't indexed either. > Bzzzzzzzzzzzzzzzzzzzzt!!!! In what universe? Do you mean that a caller to a BBS puts out a break between each keystroke while connected? Pay attention class. There will be a pop quiz at the end. on a serial connection the normal state of the 8250 SOUT pin is a logic 1. When a character is output a frame is assembled consisting of 1 start bit, 7 or 8 data bits, an optional parity bit and 1 or 2 stop bits. The start bit is a 0, the stop bits are 1 and the data and parity follows the data and 8250 parity generation setup. So say you transmit 'A' at 7 bit odd parity 1 stop then the frame looks like this: 0 1 0 0 0 0 0 1 1 When we add the idle bits before and after the character then we have: 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 As you can see the first 0 bit (the start bit) signals the receiver that a character is starting. It then assembles the next 7 bits into a character and one more bit for the parity. If the next bit is not a 1 then a framing error occurs. To send a break, you set a logic 0 long enough to have all zeros for the start, data, parity and stop bits. This special case is recognized by the receiver as a break condition. It looks like this: 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 As long as the number of zeros is more than the total of a normal frame. To generate this on a PC you set bit 6 in the line control register to 1 for the desired length of time. This register is at port 0x3fb for COM1 and 2fb for COM2. Don't forget to read the current contents first. Here is a snippet: int lcr; ... lcr = inportb(0x3fb); /* or 0x2fb for COM2 */ outportb(0x3fb, lcr | 0x40); delay(); /* for sufficient time */ outportb(3fb, lcr); /* restore it */ -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | MS-DOS: The Andrew Dice Clay West Hill, Ontario, Canada | of operating systems. + 416 281 6094 |