Tài liệu Chapter-19-Serial communications ppt

15 515 0
Tài liệu Chapter-19-Serial communications ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

2 April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 325 In this chapter: • Terminology • Asynchronous and synchronous communication • Serial por ts • Modems • Modem commands 19 Serial communications UNIX has always had a high level of support for serial lines, but their purpose has changed dramatically In the early 70s, the standard ‘‘terminal’’ was a Teletype KSR35, a 10-character-per-second serial printer with keyboard Early UNIX serial line support was geared towards supporting these devices, either directly connected, or via a modem Even in the early 80s, when 4.2BSD introduced network support, things didn’t change much: the network support used different hardware By this time, the Teletypes had been replaced with glass ttys, in other words serial terminals with a monitor instead of a printer The speeds had gone up from the 110 bps of the Teletype to 9600 bps, but the underlying principles hadn’t changed It wasn’t until the last 10 years that the glass ttys were replaced by display boards directly connected to the system bus, or by other machines connected by Ethernet The role of the serial port has changed completely: nowadays, they’re used mainly for mice and dialup Internet connections This change in use has invalidated a few basic concepts Only a few years ago, the standard ‘‘high-speed’’ modem was a V.22bis 2400 bps modem, even then too slow for an Internet connection The standard data communication line was 56 kb/s, and it was invariably a leased line As a result, the Internet grew up assuming that connections were leased lines, and therefore permanently connected Even today, the Internet protocols not deal well with dialup access On the other hand, UUCP did use dialup access As a result, provisions for dialup access in UNIX tend to be derived from UUCP This doesn’t make for smooth integration modems.mm,v v4.10 (2003/04/02 03:11:02) 325 April 2003, 17:00:47 The Complete FreeBSD ( /tools/tmac.Mn), page 326 The Complete FreeBSD 326 In this chapter, we’ll look at the way FreeBSD handles serial communications, at how modems work, and how the two fit together Terminology Any serial connection has two ends, which may be computers, terminals, printers or modems In modem terminology, the computers are Data Terminal Equipment or DTE (this terminology arose at a time when the device connected to a modem was usually a terminal), and modems are Data Communication Equipment or DCE You’ll also sometimes hear the name dataset for a modem Asynchronous and synchronous communication There are two different ways to transmit serial data, called synchronous and asynchronous communication They grew up in different worlds: Asynchronous communication Asynchronous communication predates computers It was originally developed to run teletypewriters, electrical typewriters that were run off a serial data stream, the bestknown of which were made by the Teletype corporation These machines were frequently used to provide a remote transcript of what somebody was typing miles away, so they would typically print one character at a time, stop, and wait for the next In the early days of UNIX, the standard terminal was a Teletype model KSR35, commonly just called teletype or tty (pronounced ‘‘titty’’) Here’s a picture of a typical byte encoding: 1 1 1 StartParity D7 D6 D5 D4 D3 D2 D1 D0 Stop Stop Bit Bit Figure 19-1: Asynchronous byte encoding This figure shows an encoding for the letter j, in binary 01101011 We’ll see a number of things about it: modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 327 327 Chapter 19: Serial communications • Before the character starts, the line is idle, which shows as a high level: this indicates to the teletype that the line is still connected • First comes a start bit In the olden days, this bit started the motor of the teletype mechanism Now it signals that data is coming • Next comes a parity bit To detect any transmission errors, this character is encoded with even parity The parity bit is set to if the character contains an odd number of bits, and to otherwise, which ensures that the character, including the parity bit, always has an even number of bits If a single bit is corrupted during transmission, the character will arrive with odd parity, and the receiver will detect an error • Next come the bits of the character, last bit first We represent with a low level and with a high level • Finally come one or two stop bits The stop bits were originally intended to give the teletype time to stop the motor, but they are now largely superfluous You needed two stop bits for a teletype, but nowadays you should always use one • This example also shows something else of importance: there are a number of ways to encode the character How many bits? How many stop bits? Odd parity? Even parity? No parity? Mark parity (always a bit)? Space parity (always a bit)? How much time from one bit to the next (what bit rate)? They’re all set with the stty program (see man page stty(1)), but if you set them wrongly, you’ll run into trouble • The encoding isn’t very efficient For every character you send, you also send a start bit and a stop bit Most communications no longer use the parity bit, but this still means that you have a 25% overhead on communication: for every bits, you send 10, and you could send up to 12, as in this example We’ll see that synchronous communication doesn’t have this problem Users of synchronous communication protocols often refer to asynchronous communication as start-stop communication Synchronous communication By contrast with asynchronous communication, synchronous communication comes from the mainframe world, and it assumes that data does not come one byte at a time Instead, it transmits data in blocks Each block is preceded by one or two SYN characters that tell the receiver that data is coming, and that enable it to determine the correct orientation of the bits in the data All modern modems use synchronous communication on the phone line, because it is more efficient, and it’s the basis of protocols such as SNA and X.25, but you will almost never see any other use of it in UNIX systems modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 328 Asynchronous and synchronous communication 328 Serial ports Nowadays, all PCs come equipped with two serial ports, which are called COM1: and COM2: in the DOS world UNIX names are different, and FreeBSD calls these same devices sio0 and sio1 It’s possible to connect up to four direct serial ports on a standard PC, but due to the design of the board, each one requires a separate IRQ line If you put two serial ports on the same interrupt line, neither of them will work The first two devices, sio0 and sio1, normally use the default IRQs and By default, however, PC manufacturers put COM3: and COM4: also at IRQs and How can this work? It can’t, if you also have COM1: and COM2: enabled at those IRQs However, DOS tends to only one thing at a time, so you can use different ports at different times on the same IRQ, as long as the interrupts aren’t enabled on more than one of the ports at a time This restriction is unacceptable for UNIX, so we have to put them somewhere else The only unused interrupt available to 8-bit boards is IRQ 5, originally intended for a second parallel printer port There’s a very good chance that IRQ will already be occupied What can you do? If one of the boards has a 16-bit or better interface, you can check if one of the interrupts 10 to 15 is available All EISA and PCI boards fit into this category, and so ISA boards with two connectors to the motherboard Unfortunately, a lot of ISA serial cards only have an 8-bit interface The only alternative is an intelligent serial board that only occupies a single interrupt In this case, you will probably have to build a custom kernel See the man page sio(4) Connecting to the port Theoretically, a serial line can consist of only three wires: a Receive Data line, often abbreviated to RxD, a Transmit Data line (TxD), and a Signal Ground line (SG) In fact, it is possible to get a link to work like this, but there are a number of problems: • How we know when the other end is able to accept data? It may be busy processing data it has already received • How we know when it’s even switched on? • In the case of a modem, how we know when it is connected to the modem at the other end? We solve these questions, and more, by the use of additional lines The most common standard is RS-232, also known as EIA-232, a standard for DCE to DTE connection In Europe, it is sometimes confused with the CCITT V.24 standard, though V.24 does not in fact correspond exactly to RS-232 Most external modems display some of these signals on LED, but modem manufacturers love to create alternative abbreviations for signal names Here are the signals that RS-232 defines, with some of the more common abbreviations that you may see on external modems modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 329 329 Chapter 19: Serial communications Table 19-1: RS-232 signals and modem LEDs RS-232 name Modem LED PG Pin TxD TD D1 Transmitted data: data coming from the DTE to the modem RxD RD D2 Received data: data coming from the modem to the DTE RTS Request to send Indicates that the device has data to output CTS Clear to send Indicates that the device can receive input DSR SG DCD CD M5 Carrier detect Indicates that the modem has connection with another modem DTR 20 DTR S1 Data terminal ready Indicates that the terminal or computer is ready to talk to the modem RI 22 AA Ring indicator Raised by a modem to indicate that an incoming call is ringing The AA indicator on a modem will usually flash when the incoming call is ringing AA ‘‘Auto Answer.’’ Indicates that the modem will answer an incoming call HS ‘‘High Speed.’’ Indicates that the modem is running at a higher speed than its minimum Individual modems interpret this differently, but you can assume that something is wrong if your modem has this indicator and it’s off during transmission MNP Indicates that error correction is active OH ‘‘Off hook.’’ Indicates that the modem has some connection with the phone line PW Indicates that modem power is on May or may not imply DSR MR ON PW Purpose Protective ground Used for electrical grounding only Data set ready Indicates that the modem is powered on and has passed self-test On some modems, PW indicates that power is on, and MR indicates that it is operative Signal ground Return for the other signals The line DCD tells the DTE that the modem has established a connection We’ll look at how to use this information on page 335 In addition to these signals, synchronous modems supply clocks on pins 17 and 19 For more details about RS-232, see RS-232 Made easy by Martin Seyer modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 330 Serial por ts 330 When can I send data? There are two ways to determine if the other end is prepared to accept data: hardware handshaking and software handshaking Both are also referred to as flow control In each case, the handshaking is symmetrical We’ll look at it from the point of view of the DTE, because this is the more common viewpoint In hardware handshaking, the DCE raises CTS (Clear to Send) when it’s ready to accept input The DTE only transmits data when CTS is asserted from the other end You’ll often see that the DTE asserts RTS (Request to send) when it wants to send data This is a throwback to the days of half-duplex modems, which could only transmit in one direction at a time: RTS was needed to switch the modem into send mode Software handshaking is also called X-on/X-off The DCE sends a character (X-off, which corresponds to Ctrl-S) when the buffer is full, and another (X-on, corresponding to CtrlQ) when there is space in the buffer again You can also use this method on a terminal to temporarily stop the display of a lot of data, and then restart it It’s no longer a good choice for modems For hardware handshake to work, your modem must be configured correctly, and you must have the correct cables If it isn’t, the symptoms will be very slow response when transferring large quantities of data: at a higher level, TCP can recover from these overruns, but it takes at least a second to so every time We’ll see how to check that your modem has the correct kind of flow control on page 333 Modems A modem is a device that transfers digital data into a form suitable for transmission over a transmission line, which is usually a telephone line Telephone lines are limited to a frequency of about 3.6 kHz, and this limited the speed of older modems to about 1200 bits per second Modern modems use many sophisticated techniques to increase the speed way beyond this Current modems transmit at 56 kilobits per second Let’s consider the modem connection in the reference network on page 294, which is repeated in figure 19-2 As we can see, there are three connections: • The connection from the router gw to the local modem, connected at 57,600 bits per second • The connection between the modems, at 56,000 bits per second • The connection from the ISP’s modem to his router, at 115,200 bits per second You’ll also note another value specified here: the connection between the modems is 2,400 baud Isn’t a baud the same thing as a bit per second? No, not always The term baud is a representation of the frequency of data on a serial line On the connections between the systems and the modem, which handle raw digital data, it corresponds to the bit rate On the modem line, it doesn’t Here, it indicates that 2,400 units of data are sent per second modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 331 331 Chapter 19: Serial communications Unfortunately, many people use the term baud where bit rate should be used This didn’t make any difference in the old days with simple modems where the bit rate and baud rate were the same, but nowadays it’s confusing • DTE DCE DCE DTE gw Router • • modem • • modem • • ISP Local modem connection, 57,600 bps PPP link, 56,000 bps, 2400 baud ISP modem connection, 115,200 bps router • Figure 19-2: Network modem connection Modem speeds Two factors determine the data transmission speed of a modem: the protocol and the use of data compression Table 19-2 on page 332 gives an overview of modem protocols and their speeds Currently, the most popular modem protocol is V.90 V.90 pushes modem technology to the limit, and it only works when the other end of the link is a digital (ISDN) connection You can’t get a 56 kb/s connection with any kind of analogue modem at the other end As a result, they’re really only suitable for connection to a large ISP site In addition, the actual speed of the connection depends greatly on the telephone line quality, so the difference between a V.90 and a V.34bis modem may not be as much as it appears Data compression In addition, you usually have a choice of data compression: V.42bis or MNP-5 The choice depends on what the modem at the other end of the line does You can set most modems to negotiate either protocol These protocols include related error correction standards, called V.42 or MNP2-4 respectively If you believe the sales claims, these compression protocols will give you up to 100% increase in data throughput Consider this the upper limit; a lot of data is binary, and when ftp’ing a typical gzipped tar archive, you will probably get almost no speed improvement modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 332 Modems 332 Data compression has one negative side: it increases the data rate, but it also increases latency, the time it takes for data to get from the local DTE to the remote DTE The data doesn’t take as long on the line, but it spends more time in the modems being compressed and uncompressed If you’re running a protocol like PPP that supplies optional compression in the software, you may find it advantageous to turn off compression We’ll look at that again in Chapter 20, Configuring PPP Table 19-2: Modem protocols and speeds Protocol Bell 203 V.21 Bell 212 V.22 V.22bis V.32 V.32bis V.34 V.34bis V.90 Speed (bps) 300 300 1200 1200 2400 9600 14400 28800 33600 56000 The link speed The standard PC serial hardware can run at speeds that are a fraction of 115,200 bps (in other words, 115200 divided by a small integer) This gives the following combinations: Table 19-3: Serial line speeds Divisor Speed (bps) 115200 57600 38400 28800 23040 19200 You’ll notice that it can’t run at 33600 or 56000 bps Also, looking at the example above, you’ll note that all three links run at different speeds How can that work? Only a few years ago, it wouldn’t, but modern modems can buffer data For example, the ISP can send data to the modem far faster than the modem can send it to the other modem It stores the data in internal memory until it can be transmitted This can also happen at the other end If you misconfigure your line so that the local link runs at 9600 bps, things will still work, but of course the total speed is the speed of the slowest link, in this case 9600 bps modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 333 333 Chapter 19: Serial communications This flexibility brings a problem with it: the modem can’t know in advance how fast the connection to the computer is It needs a way to find out The modem solves the question of local line speed by a trick: all commands start with AT or at (you’re not allowed to mix cases, like aT or At) It can recognize these characters even if they arrive at the wrong speed, and thus it can establish the speed of the connection Dialing out Nowadays, all modems are capable of dialing That wasn’t always the case, and in some old documentation you may find references to an Auto-Call Unit or ACU, which is simply the dialler part of a modem connected via a separate port Typically, one ACU could serve multiple modems Nearly every modern modem uses a command set designed by Hayes Corporation, which is thus called the Hayes Command Set We’ll look at it in the following section It is also sometimes called the AT command set, because nearly all the commands start with the sequence AT The CCITT also created an autodial recommendation, V.25, which was occasionally implemented, but now appears to be dead Modem commands Modern modems store their state in a number of registers, called S registers The register use varies somewhat from manufacturer to manufacturer, but most modems have a number in common They each store a one-byte value, ranging between and 255 Here’s a list of the more important ones for a Rockwell V.34 chip set The name of the chip set is not the same as the name of the modem You’ll note that one of the commands enables you to find out the chip set version, as we’ll see in the example that follows Table 19-4: Selected S registers Register number S0 Purpose Number of rings until auto-answer disables auto-answer Set to for no automatic answer, or for auto-answer S2 The escape character, which lets you return from online mode to command mode Normally, this character is a + To return to command mode, wait a second after any previous input, enter +++, and wait a second, after which the modem should reply with OK S6 The time, in seconds, to wait before blind dialing If you have set your modem to not wait for a dial tone (maybe because it doesn’t understand the dial tone), it will wait this long and then try to dial anyway modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 334 Modem commands Register number S7 S11 334 Purpose The number of seconds to wait after dialing before DCD must be asserted (before a connection is established) If this is set too short, you will not be able to establish a connection If it’s too long, you will waste time when there is no answer or the line is busy The duration of DTMF (dialing) tones If these are set incorrectly, the telephone exchange may not understand the number you dial The AT command set tells the modem to something specific Here are some of the more important ones Table 19-5: Selected AT commands Command A/ ATA Meaning Redial the last number Answer an incoming call manually This is an alternative to auto-answer by setting S0 ATDnumber Dial number This command has a large number of options, but if your modem is set up correctly, you probably won’t need any of them ATEnumber Enable command echo if number is 1, disable it if number is The setting of this parameter can be important for some chat scripts, which may not respond correctly otherwise ATH0 Disconnect the line ATInumber Display modem identification The values of number vary from one modem to the next See the examples below ATLnumber Set the speaker volume number ranges from to means ‘‘speaker off,’’ is the loudest ATMnumber Determine when the speaker is on means ‘‘always off,’’ means ‘‘speaker on until connect,’’ means ‘‘speaker always on,’’ and means ‘‘speaker off during dialing and receiving.’’ ATO0 Go back online from command mode You don’t need this command when dialing: the modem automatically goes online when the connection is established ATP Select pulse dial If your exchange doesn’t understand DTMF (tone) dialing, you should set this mode Never use it if your exchange understands DTMF: pulse dialing (also known as steam dialing) is much slower ATQnumber If number is 0, suppress result codes (like OK after every command) If number is 1, enable them This value can be of importance for chat scripts modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 335 335 Chapter 19: Serial communications ATSr=n Meaning Set the value of S register r to n ATSnumber? Display the contents of an S register See the example below ATT Set tone (DTMF) dialing ATVnumber If number is 0, return result codes in numeric form If it’s 1, return text Don’t rely on either form to be consistent from one modem to the next ATXnumber Determine the form of the result codes This depends a lot on the manufacturer, but it’s important for chat scripts If you run into trouble, with chat scripts, check your modem documentation ATZ Reset modem configuration to default values AT&Knumber Select flow control method Normally, enables RTS/CTS flow control, which is what you want AT&Rnumber If number is 0, CTS is only asserted if the DTE asserts RTS, even if the modem is able to receive data If it’s set to 1, it behaves normally Make sure this value is set to AT&Tnumber Perform modem-specific test number This command is the origin of the statement: ‘‘UNIX is a trademark of AT&T in the USA and other countries AT&T is a modem test command.’’ AT&V View the current configuration See the example below AT&Wnumber Store the current configuration as profile number Most external modems can store two profiles, or configurations If number is not specified, write the profile specified in a previous AT&Y command See the example below Decide which profile (0 or 1) will be loaded when the modem is reset, and which will be written by the command AT&W Command AT&Ynumber Dialing out manually In this section, we’ll look at what needs to be done to establish a dial-out connection You don’t normally this yourself: some software will it for you automatically It’s useful to know what goes on, though: it can be of immense help in solving connection problems There are two distinct things that you want to with the modem: first, you send commands to the modem to set up the link Once the link is established, you don’t want to talk to the modem any more, you want to talk to the system at the other end of the link In the old days, the system used a separate ACU to establish the connection, and the solution was simple: the system issued the dialing commands to the ACU and opened the modem in such a manner that the open did not complete until a connection had been established Nowadays, the modem handles both dialing and the establishment of connection But to so, the system has to open the modem before communication has modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 336 Modem commands 336 been established The terminal parameter clocal enables communication with a device that is not asserting DCD (such as a modem that hasn’t established a connection yet) When it starts, the software sets clocal When it has finished talking to the modem and wants to wait for the connection to be established, it resets (turns off) clocal and waits for DCD You can check this with the stty command: # stty -f /dev/cuaa2 -a ppp disc; speed 57600 baud; rows; columns; lflags: -icanon -isig -iexten -echo -echoe -echok -echoke -echonl -echoctl -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo -extproc iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel ignbrk -brkint -inpck ignpar -parmrk oflags: -opost -onlcr -oxtabs cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb crtscts -dsrflow -dtrflow -mdmbuf cchars: discard = ˆO; dsusp = ˆY; eof = ˆD; eol = ; eol2 = ; erase = ˆ?; intr = ˆC; kill = ˆU; lnext = ˆV; = 1; quit = ˆ\; reprint = ˆR; start = ˆQ; status = ˆT; stop = ˆS; susp = ˆZ; time = 0; werase = ˆW; This example, taken when the modem is connected, shows clocal reset As you can see, this is indicated by the text -clocal There’s a problem here: what if this line is also enabled for dialup? As we shall see on page 338, there will be a getty process in the process of opening the line It won’t succeed until DCD is asserted, so we can dial with no problem But when the connection is established, how we stop getty from being there first? The FreeBSD solution is to create separate devices for each case For the second serial port, sio1, the system creates a file /dev/cuaa1 for dialing out, and /dev/ttyd1 for dialing in If cuaa1 is open, an open on ttyd1 does not complete when connection is established Dialing out—an example For an example of what you might look at, let’s consider a manual dialup to an ISP This assumes that you are using user PPP (see page 348) and that have an entry ISP in your /etc/ppp/ppp.conf If you don’t have an entry for an ISP, you can still test the modem, but in this case you won’t be able to dial In this case, simply omit the text ISP # ppp ISP User Process PPP Written by Toshiharu OHNO Using interface: tun0 Interactive mode ppp ON freebie> term go into direct connect mode Enter to terminal mode Type ‘˜?’ for help at synchronize with the modem OK at&v look at the modem profile ACTIVE PROFILE: B0 E1 L0 M1 N1 Q0 T V1 W0 X4 Y0 &C1 &D2 &G0 &J0 &K4 &Q5 &R1 &S0 &T5 &X0 &Y0 S00:000 S01:000 S02:043 S03:013 S04:010 S05:008 S06:002 S07:060 S08:002 S09:006 S10:014 S11:090 S12:050 S18:000 S25:005 S26:001 S36:007 S37:000 S38:020 S44:020 S46:138 S48:007 S95:000 modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 337 337 Chapter 19: Serial communications STORED PROFILE 0: B0 E1 L0 M1 N1 Q0 T V1 W0 X4 Y0 &C1 &D2 &G0 &J0 &K4 &Q5 &R1 &S0 &T5 &X0 S00:000 S02:043 S06:002 S07:060 S08:002 S09:006 S10:014 S11:090 S12:050 S18:000 S36:007 S37:000 S40:104 S41:195 S46:138 S95:000 STORED PROFILE 1: B0 E1 L1 M1 N1 Q0 T V1 W0 X4 Y0 &C1 &D2 &G0 &J0 &K3 &Q5 &R1 &S0 &T5 &X0 S00:000 S02:043 S06:002 S07:060 S08:002 S09:006 S10:014 S11:090 S12:050 S18:000 S36:007 S37:000 S40:104 S41:195 S46:138 S95:000 TELEPHONE NUMBERS: 0=T1234567890 2= 1= 3= OK The term profile refers to a set of the complete configuration information for the modem External modems can usually store two different profiles Some modems may not have any stored profiles, or they may have a different number The AT&V command shows the current configuration (‘‘active profile’’) and the two stored profiles The first line reflects the parameters set with AT commands (for example, L0 means that the command ATL0, turn off the speaker, has been issued) The next two or three lines reflect the values of the S registers In addition, this modem can store up to four telephone numbers, a feature that is seldom of great interest If you look at this profile, you’ll notice that the active profile includes the parameter &K4 This means ‘‘use XON/XOFF flow control.’’ This is not desirable: it’s better to use RTS/CTS flow control To fix it, at&k3 set RTS/CTS flow control OK at&w write the active profile OK at&v and check ACTIVE PROFILE: B0 E1 L0 M1 N1 Q0 T V1 W0 X4 Y0 &C1 &D2 &G0 &J0 &K3 &Q5 &R1 &S0 &T5 &X0 &Y0 S00:000 S01:000 S02:043 S03:013 S04:010 S05:008 S06:002 S07:060 S08:002 S09:006 S10:014 S11:090 S12:050 S18:000 S25:005 S26:001 S36:007 S37:000 S38:020 S44:020 S46:138 S48:007 S95:000 STORED PROFILE 0: B0 E1 L0 M1 N1 Q0 T V1 W0 X4 Y0 &C1 &D2 &G0 &J0 &K3 &Q5 &R1 &S0 &T5 &X0 S00:000 S02:043 S06:002 S07:060 S08:002 S09:006 S10:014 S11:090 S12:050 S18:000 S36:007 S37:000 S40:104 S41:195 S46:138 S95:000 STORED PROFILE 1: B0 E1 L1 M1 N1 Q0 T V1 W0 X4 Y0 &C1 &D2 &G0 &J0 &K3 &Q5 &R1 &S0 &T5 &X0 S00:000 S02:043 S06:002 S07:060 S08:002 S09:006 S10:014 S11:090 S12:050 S18:000 S36:007 S37:000 S40:104 S41:195 S46:138 S95:000 TELEPHONE NUMBERS: 0=T1234567890 2= 1= 3= OK The active profile includes the parameter &Y0, so the AT&W command writes back to stored profile The AT&V command doesn’t show all the S registers Some of them relate to the current modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 338 Modem commands 338 state of the modem, and aren’t part of the configuration For example, my modem includes an S register S86, the Call Failure Reason Code If a call fails, it could be interesting to look at it To so: show contents of S86 Connection dropped by other end ats86? 012 With this background, we can now proceed to establish a connection: just dial atd1234567 CONNECT 57600 ppp ON freebie> PPP ON freebie> Dialing in Traditionally, UNIX distinguishes between local serial terminals and terminals connected by modem by whether they assert the DCD signal It starts a getty (for Get TTY ) process for each line getty opens the line, but for modems the line state is set in such a way that the call to open does not complete until the DCE asserts DCD This is done by resetting the flag clocal If you look at the line state with the stty program, it will show -clocal if the flag is reset To set up a line for dialing in, add information about the line in the file /etc/ttys The default file contains a number of lines like: ttyd0 "/usr/libexec/getty std.9600" unknown off secure This information has the following meaning: • The first column is the name of the terminal special file, relative to /dev In other words, this entry represents the file /dev/ttyd0 • The next field consists of the text /usr/libexec/getty std.9600 This is the invocation for getty: the getty program is /usr/libexec/getty, and it is invoked with the parameter std.9600 This is a label in the file /etc/gettytab, and describes a standard 9600 bps connection You’ll probably want to upgrade to std.57600 • unknown refers to the terminal type This is the value to which getty sets the environment variable TERM If you know that only people with VT100 terminals dial in, you might change this string to vt100, but you should this with care It can cause a real mess on the screen, and even make it impossible to work with it • The remaining fields can occur in any order off means ‘‘don’t start the getty after all.’’ If you want to run a getty on this line, change this string to on secure means that only people you trust can access this line, so you can allow a root login on this line That’s fine for a direct connect terminal in the same room, for example It’s not a good idea for a modem to which anybody can dial up If the line is not secure, just omit the string After changing /etc/ttys, send init (process 1) a HUP signal to tell it to re-read /etc/ttys: modems.mm,v v4.10 (2003/04/02 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 339 339 # kill -1 modems.mm,v v4.10 (2003/04/02 03:11:02) Chapter 19: Serial communications ... page 326 The Complete FreeBSD 326 In this chapter, we’ll look at the way FreeBSD handles serial communications, at how modems work, and how the two fit together Terminology Any serial connection... 03:11:02) April 2003, 17:00:47 The Complete FreeBSD (modems.mm), page 327 327 Chapter 19: Serial communications • Before the character starts, the line is idle, which shows as a high level: this... isn’t very efficient For every character you send, you also send a start bit and a stop bit Most communications no longer use the parity bit, but this still means that you have a 25% overhead on

Ngày đăng: 11/12/2013, 00:15

Tài liệu cùng người dùng

Tài liệu liên quan