Linux °æ (¾«»ªÇø)
·¢ÐÅÈË: clx (³þÁôÏã), ÐÅÇø: Unix
±ê Ìâ: Linux Serial HOWTO ÖÐÒë°æ(13)
·¢ÐÅÕ¾: ×Ï ¶¡ Ïã (Sat Jun 27 17:18:03 1998), תÐÅ
Linux Serial HOWTO ÖÐÒë°æ : ¸ü½øÒ»²½...
Previous: ´®ÁÐʹÓÃÃؾ÷
Next: ¹ÊÕÏÅųý
12. ¸ü½øÒ»²½...
ÕâÒ»½Ú²¢²»ÐèÒªÔĶÁ£¬µ«ÊÇ¿ÉÄÜ´ø¸øÄãһЩ¶Ôì¶ Unix ÒÔ¼°µç×Óͨ
ѶÊÀ½ç¸ü½øÒ»²½µÄÁ˽⣮
12.1. ʲ÷áÊÇËø¶¨µµ°¸(lock files)?
Lock files Ö»Êǵ¥´¿µÄÒ»¸öµµ°¸ÓÃÀ´±íʾij¸öÌض¨µÄÉ豸ÕýÔÚʹÓÃ
ÖУ® ËüÃDZ£´æÔÚ /usr/spool/uucp »òÊÇ /var/lock ÀïÃ森 Linux µÄ
lock files Ãû×Ö¶¼ÊÇ LCK..name£¬ÆäÖÐµÄ name ²»ÊÇÉ豸Ãû³Æ¾ÍÊÇ
Ò»¸ö UUCP ½ÚµãÃû³Æ£® ÓÐЩ³ÌÐò½¨Á¢ÕâЩ locks ÒÔ±ãÈÃËüÃÇ×Ô¼º
¿ÉÒÔ¶ÀÕ¼¸ÃÉ豸µÄ´æȡȨ£® ÀýÈçÈç¹ûÄã´ÓÄãµÄÊý¾Ý»ú²¦ºÅ³öÈ¥£¬½«
»á³öÏÖÒ»¸ö lock ¸æËßÆäËü³ÌÐòÏÖÔÚÒѾÓÐÈËÕýÔÚʹÓÃÊý¾Ý»ú£®
Lock files ÀïÃæÖ÷ÒªÊÇ°üº¬Ëøס¸ÃÉ豸µÄ³ÌÐòµÄÐг̺ÅÂë(PID)£®
´ó²¿·ÝµÄ³Ìʽ»á²éÔÄ lock£¬È»áá¼ì²éÐг̱í(process table)ÖÐËø
¶¨¸ÃÉ豸µÄÐгÌÀ´ÊÔÖø¾ö¶¨Õâ¸ö lock ÊÇ·ñÈÔÈ»ÓÐЧ£® Èç¹û·¢ÏÖÕâ
¸ö lock ÊÇÓÐЧµÄ»°£¬Õâ¸ö³Ìʽ(Ó¦¸Ã)Òª½áÊø£® Èç¹û²»ÊÇ£¬Ä³Ð©³Ì
ʽ»áɾ³ý¹ýʱµÄ lock£¬È»ááʹÓøÃÉ豸£¬²¢ÔÚÐгÌÖ´ÐÐʱ½¨Á¢ËûÃÇ
×Ô¼ºµÄ lock£® ÆäËüµÄ³Ìʽ¾ÍÖ»ºÃ½áÊø²¢¸æËßÄã¸ÃÉ豸ÕýÔÚʹÓÃ
ÖУ®
12.2. ``baud'' ¶Ô ``bps''
``baud'' ¸ú ``bps'' ¿ÉÄÜÊǵçÄÔ/µç×ÓͨѶÕâ¸öÁìÓòÀï×î³£±»´íÓÃ
µÄÊõÓïÖ®Ò»£® µ±ËüÃÇÊÂʵÉϲ¢²»ÏàͬµÄʱºò£¬ºÜ¶àÈËÈÔ½»ÌæʹÓÃÕâ
ЩÊõÓ
±«ÂÊ(baud)
±«ÂÊÊÇÿÃëÖÓÊý¾Ý»ú(µ÷±ä½âµ÷Æ÷£¬modulator-demodulator)
Ëͳö¶àÉÙ´ÎѶºÅ¸Ä±äµÄ¶ÈÁ¿£® ÀýÈ磬±«ÂÊΪ 1200 µÄº¬ÒâÊÇÐÅ
ºÅÿ¸ô 833 ΢Ãë(microsecond)¼´¸Ä±äÒ»´Î£® ÆÕ±éµÄ±«ÂÊÓÐ
50, 75, 110, 300, 600, 1200 ÒÔ¼° 2400£®´ó²¿·ÝµÄ¸ßËÙÊý¾Ý
»úËùʹÓõı«ÂÊΪ 2400£® ÒòΪÓïÒô¼¶(voice-grade)µç»°Ïß·
µÄƵ¿íÏÞÖÆ£¬³¬¹ý 2400 µÄ±«ÂʺÜÄÑ´ïµÄµ½£¬¶øÖ»ÄÜÔڷdz£´¿
¾»µÄµç»°ÏßÆ·ÖÊϲÅÄÜÔË×÷£® ``baud''Ò»´ÊÔÚ Emile Baudot
Ö®áá²ÅÓУ¬ËûÊÇ·Çͬ²½µç±¨Ó¡±í»ú(asynchronous telegraph
printer)µÄ·¢Ã÷Õߣ®
ÿÃë´«ÊäλԪ(bps)
ÿÃëλԪ´«ÊäÂÊÊÇÿÃëÖÓ´«Êä¶àÉÙλԪµÄ¶ÈÁ¿£®ÆÕ±éÿÃëλԪ
´«ÊäÂÊÓÐ 50, 75, 110, 300, 1200, 2400, 4800, 9600, ...
115200£® ÔÚʹÓà V.42bis ѹËõ(ѹËõ×î´óÂÊ 4:1)µÄÊý¾Ý»ú
Ï£¬ÀíÂÛÉÏÿÃëλԪ´«ÊäÂÊ¿ÉÒԸߴï 115200£® ÕâÊÇÐí¶àÈËÔÚ
´íÓà ``baud'' Õâ¸ö×ÖʱËùÖ¸µÄÒâ˼£®
ËùÒÔ£¬Èç¹û¸ßËÙÊý¾Ý»úÒÔ 2400 baud ÔË×÷£¬ËüÃÇÈçºÎÄܹ»´«ËÍ
14400 bps? Êý¾Ý»ú¶Ôÿ¸ö baud ±àÂëÀ´±íʾijһÊýÁ¿µÄλԪ¶øʹµÃ
bps ÄÜ´óì¶ baud£® ÕâÑùÒ»À´£¬µ±¶þ¸ö»ò¸ü¶àλԪ±àÂë³ÉÒ»¸ö baud
µÄʱºò£¬bps ¾Í»á³¬Ô½ baud£® Èç¹ûÄãµÄÊý¾Ý»úÊÇÒÔ 14400 bps Á¬
ÏߵĻ°£¬Ëü½«»áÒÔ 2400 baud µÄËÙ¶Èÿ¸ö baud ´«ËÍÁù¸öλԪ£®
Õâ¸ö»ìÏýÊÇÔõ÷áÑù¿ªÊ¼µÄ? àÅ£¬»Øµ½½ñÌìµÄµÍËÙÊý¾Ý»ú»¹ÊÇ×òÌìµÄ
¸ßËÙÊý¾Ý»úÄǸöʱ´ú£¬Ã¿ÃëλԪ´«ÊäÂʸúÐźŸıäÂÊʵ¼ÊÉÏÊÇÍêÈ«
ÏàµÈµÄ£® ÿ¸ö bit ±àÂë³ÉÒ»¸ö baud£®ÈËÃǽ»ÌæʹÓà bps ÒÔ¼°
baud ÊÇÒòΪËüÃǵÄÊý×ÖÏàͬ£® ÀýÈçһ̨ 300 bps µÄÊý¾Ý»úÆäÐźÅ
¸Ä±äÂÊÒ²ÊÇ 300£® µ±¸ßËÙÊý¾Ý»úÆÕ¼°ááÒ»Çж¼¸Ä±äÁË£¬¶øÇÒÿÃëλ
Ôª´«ÊäÂʳ¬¹ýÁËÐźŸıäÂÊ£®
12.3. ʲ÷áÊÇ UARTs? ËüÃÇÈçºÎÓ°ÏìЧÄÜ?
UARTs (ͨÓ÷Çͬ²½½ÓÊÕת»»Æ÷£¬Universal Asyncronous Receiver
Transmitter)ÊÇÄã PC ´®Áп¨Éϵľ§Æ¬£® ËüÃǵŦÓÃÊÇ°Ñ×ÊÁÏת³É
λԪ£¬½«ÕâЩλԪËÍÉÏ´®ÁÐÏß·£¬È»ááÔÚÁíÒ»¶ËÖØн¨Á¢×ÊÁÏ£®
UARTs ÊÇÒÔλԪ×éΪµ¥Î»´¦Àí×ÊÁÏ£¬ºÜ·½±ãµØÒ²ÊÇÃÀ¹ú±ê×¼½»»»Âë
(ASCII)µÄ×ÖÔª´óС£®
¼Ù¶¨ÊÇÄãÓÐһ̨Á¬½Óµ½Äã PC µÄÖն˻ú£®µ±Äã¼üÈëÒ»¸ö×ÖԪʱ£¬ÖÕ
¶Ë»ú°ÑËü½»¸øËüµÄת»»Æ÷(Ò²ÊÇ UART µÄÒ»ÖÖ)£® ¸Ãת»»Æ÷ÒÔÖ¸¶¨µÄ
ËÙÂÊ°ÑÕâ¸öλԪ×éË͵½´®ÁÐÏß·ÉÏ£¬Ã¿´ÎÒ»¸öλԪ£® ÔÚ PC ÕâÒ»
¶Ë£¬½ÓÊÕλԪµÄ UART ÄÃ×ßËùÓеÄλԪ£¬È»ááÖØÐÂ×é³ÉλԪ×é²¢ÇÒ·
ŵ½»º³åÇøÀïÈ¥£®
ÓÐÁ½ÖÖ²»Í¬µÄ UARTs ÀàÐÍ£®Äã¿ÉÄÜÓÐÌý¹ýÓÞ´ÀµÄ(dumb)UARTs -
8250 »¹ÓÐ 16450£¬ÒÔ¼°ÏȽøÏȳöʽ UARTs - 16550A£® ÒªÁ˽âËüÃÇ
µÄ²»Í¬£¬Ê×ÏÈÈÃÎÒÃÇÀ´¼ìÑéµ± UART Ëͳö»ò½ÓÊÕÒ»¸öλԪ×éʱËù·¢
ÉúµÄÊ£®
Õâ UART ±¾Éí²¢²»ÄܶÔ×ÊÁÏ×öʲ÷á´¦Àí£¬ËüÖ»ÊÇËͳöÒÔ¼°½ÓÊÕËü£®
ÿ´ÎËͳö»ò½ÓÊÕÒ»¸öλԪ×éʱ£¬CPU ¶¼»á´Ó´®ÁÐÉ豸½Óµ½Ò»¸öÖÐ
¶Ï£® È»áá CPU ¾Í°Ñ½ÓÊÕµ½µÄλԪ×é´Ó UARTs µÄ»º³åÇø°áµ½¼ÇÒäÌå
µÄij´¦£¬»òÊÇÌṩÁíÒ»¸öλԪ×é¸ø UART ´«ËÍ£® 8250 ÒÔ¼° 16450
UARTs Ö»ÓÐÒ»¸öλԪ×éµÄ»º³åÇø£®Õâ¸öÒâ˼ÊÇ£¬Ã¿Ëͳö»ò½ÓÊÕÒ»¸ö
λԪ×é¾Í»áÖÐ¶Ï CPU Ò»´Î£® ÔÚµÍËÙµÄÇé¿öÏÂÕâÑùûÓÐÎÊÌ⣮µ«ÊÇ
ÔÚ¸ßËٵĴ«ÊäÂÊÏ£¬CPU »áæ춴¦Àí UART ¶øûÓÐʱ¼äÕÕÁÏÆäËü¹¤
×÷£® ÔÚijЩÇé¿öÏ£¬CPU ûÓÐ×ã¹»µÄâÅÔ£¼°Ê±´¦ÀíÖжϷþÎñ£¬¸Ãλ
Ôª×齫Òò×ÊÁÏÈç´Ë¿ìËٵش«Èë¶ø±»¸²Ð´£®
Õâ¾ÍÊÇ 16550A UARTs ÓÐÓõĵط½£®ÕâЩ¾§Æ¬¾ßÓÐ 16 ¸öλԪ×éµÄ
ÏȽøÏȳöØùÁУ® Õâ¸öÒâ˼ÊÇËüÔÚ±ØÐëÖÐ¶Ï CPU ֮ǰ¿ÉÒÔ½ÓÊÕ»òת
»»´ï 16 ¸öλԪ×飮 Ëü²»½öÊÇÄܵȣ¬¶øÇÒ CPU ÏÖÔÚÒ²¿ÉÒÔͬʱ´«
ËÍÈ«²¿ 16 ¸öλԪ×éµÄ×ÊÁÏ£® ËäÈ»ÖжϽçÏÞ(threshold)ºÜÉÙÓÐÉè
µ½ 16 µÄ£¬Õâ¶Ôì¶ÆäËüÖ»ÓÐÒ»¸öλԪ×黺³åÇøµÄ UARTs ¶øÑÔÈÔÈ»ÊÇ
Ò»¸öÖØÒªµÄÓŵ㣮 CPU ÊÕµ½½ÏÉÙµÄÖжϣ¬Òò´Ë¿ÉÒÔ×ÔÓɵØ×öÆäËüÊÂ
Ç飮×ÊÁϲ»»á©ʧ£¬Ã¿¸öÈ˶¼ºÜ¸ßÐË£® (Ò²ÓÐ 16550 Õâ¸ö UART£¬
µ«ÊÇËü¸ú 16450 Ò»ÑùÒòΪËüÓÐÎÊÌ⣮)
Ò»°ãÀ´Ëµ£¬ 8250 ÒÔ¼° 16450 UARTs Ó¦¸ÃÄܹ»Ê¤Èθߴï 38400 bps
µÄ¹¤×÷ËÙÂÊ£® ÔÚ¸ßì¶ 38400 bps µÄËÙÂÊÏ£¬Äã¿ÉÄÜ¿ªÊ¼¼ûµ½×ÊÁÏ
©ʧ£® ÆäËüµÄ PC ×÷ҵϵͳ(ÕâÀïµÄ¶¨ÒåºÜ¿íËÉ)£¬Ïñ DOS ²¢·ÇÊÇ
¶à¹¤µÄ£¬ËùÒÔËüÃÇÓпÉÄÜ¿ÉÒÔÓà 8250 »ò 16450s È´Ó¦¸¶µÄ¸üºÃ£®
Õâ¾ÍÊÇΪʲ÷áÓÐЩÈ˲¢Ã»Óп´µ½×ÊÁÏ©ʧ£¬Ö±µ½ËûÃǸÄÓà Linux ²Å
·¢Éú£®
ÎÞ-UART(Non-UART)ÒÔ¼°ÖÇ»ÛÐͶ಺¿¨Ê¹ÓÃÊýλ´¦Àí»ú(DSP)¾§Æ¬À´
´¦Àí¶îÍâµÄ»º³åÒÔ¼°¿ØÖÆ£¬Èç´Ë¸üÄܼõÇá CPU µÄ¸ºµ££® ÀýÈ磬
Cyclades Cyclom ¼° Stallion EasyIO ÕâЩ¿¨Ê¹Óà Cirrus Logic
CD-1400 RISC ¾§Æ¬£¬»¹ÓÐÐí¶à¿¨Ê¹Óà 80186 CPU »ò¸üÌرðµÄ RISC
CPU À´´¦Àí´®ÁÐÊä³öÈ룮
ÐÄÀïÒª¼ÇµÃ£¬ÕâЩÓÞ´ÀÐ굀 UART ²¢·ÇÊÇ»µµÄ£¬Ö»ÊÇËüÃDz»ÊʺÏ×ö
¸ßËÙ´«Ê䣮 µ±Ä㽫Öն˻ú»ò»¬ÊóÁ¬½Óµ½ÕâЩ UARTs ʱӦ¸Ã²»»áÔâ
ÓöÀ§ÄÑ£® µ«ÊǶԸßËÙÊý¾Ý»ú¶øÑÔ£¬16550A ¿ÉÒÔ˵ÊDZØÐëµÄ£®
Äã¿ÉÒÔ»¨¶àÒ»µãµãµÄÇ®¹ºÂòÓÐ 16550A UARTs µÄ´®Áп¨£¬Ö»ÒªÑ¯ÎÊ
µçÄÔÉ̸ÿ¨ËùʹÓõÄÊÇʲ÷áÐÍºÅµÄ UARTs ¼´¿É£® »òÕßÄãÏëÉý¼¶Äã
ÏÖÔڵĿ¨£¬Äã¿ÉÒÔÖ»Òª¼òµ¥µØ¹ºÂò 16550A ¾§Æ¬²¢ÇÒÖû»ÄãÏÖÔÚµÄ
16450 UARTs ¾§Æ¬£® ËüÃǵĽÅλÏàÈÝ(pin-to-pin compatible)£®
ÓÐЩ¿¨ÓÐ UARTs ²å²ÛÀ´×÷Õâ¸öÓÃ;ʹÓã® Èç¹û²»ÊǵĻ°Äã¿ÉÒÔº¸
½Ó£®×¢Ò⣬Èç¹ûÄãÓÐÇ®£¬ÂòÒ»ÕÅп¨½«¿ÉÄÜ»áÊ¡µôÄãÐí¶àÂé·³£¬Ëü
ÃÇÔÚ $50 ÔªÃÀ½ðÒÔÏ£®
Linux Serial HOWTO ÖÐÒë°æ : ¸ü½øÒ»²½...
Previous: ´®ÁÐʹÓÃÃؾ÷
Next: ¹ÊÕÏÅųý
--
¡ù À´Ô´:£®×Ï ¶¡ Ïã bbs.hit.edu.cn£®[FROM: 202.118.244.16]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º2.619ºÁÃë