home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / sgi / 16641 < prev    next >
Encoding:
Text File  |  1992-11-19  |  3.3 KB  |  78 lines

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!spool.mu.edu!agate!doc.ic.ac.uk!cc.ic.ac.uk!imperial.ac.uk!vulture
  3. From: vulture@imperial.ac.uk (Thomas Sippel - Dau)
  4. Subject: Re: Need help on serial I/O
  5. Message-ID: <1992Nov19.103056.16765@cc.ic.ac.uk>
  6. Keywords: TTY, Parity, driver, termio, serial
  7. Sender: vulture@carrion.cc.ic.ac.uk (Thomas Sippel - Dau)
  8. Nntp-Posting-Host: cscgc
  9. Reply-To: cmaae47@imperial.ac.uk
  10. Organization: Imperial College of Science, Technology and Medicine
  11. References: <1992Nov18.202226.23935@aio.jsc.nasa.gov>
  12. Date: Thu, 19 Nov 92 10:30:56 GMT
  13. Lines: 63
  14.  
  15. In article <1992Nov18.202226.23935@aio.jsc.nasa.gov>, john@zaphod.JSC.NASA.GOV (John Fwu/HawkEye) writes:
  16. - We got an 12-bit plus sign A/D converter with asynchronous
  17. - serial interace.  The way it send 12 bit is pad the 12 bit
  18. - into two bytes.  The lower byte has "even parity" and the upper
  19. - byte has "odd parity".  We need to base on the parity to figure
  20. - out the byte order then put the 12 bit data together.
  21. - Base on my experience, we can use ioctl set the serial (tty) port
  22. - to "none", "odd" or "even" parity.  How can we handle both parity
  23. - at the same time.  May be we may set the parity to "even", then 
  24. - the upper byte will cause a "parity error".  How can we detect
  25. - the "parity error" or it just not available in the UNIX tty
  26. - driver?  If we were able to detect the parity error, can we
  27. - also get the upper byte intact?
  28.  
  29. You need to set the port parity to none, because you want to 
  30. transfer eight bit data. If you get parity errors you need to
  31. improve the cabling. More likey you would loose bytes if you 
  32. disable inetrrupts for too long, though with the Indogo or PI 
  33. you would have to work hard to manage that.
  34.  
  35. The way I see this is that the controller uses the parity to flag
  36. whether it sends an upper or lower byte, with no guarantee that
  37. a lower byte will always be followed by an upper byte (or vice
  38. versa if you think big-endian).
  39.  
  40. Thus it might be that you get an upper byte, then a few lower bytes, 
  41.  
  42. viz:                      o2  e12  e15  e33 
  43. to mean that values:          212, 215, 233 
  44.  
  45. have been detected. You would need to confirm that. This does not
  46. allow you to detect parity errors.
  47.  
  48. Conversely, if there is always a pair of bytes, the first one lower,
  49. the next upper, then lower, then upper, etc. you would need a way
  50. to resynchronise in case you lost a byte.
  51.  
  52. Having got these values and decided which bytes to pair, you can set
  53. up a 256 entry table containing the values that the bytes represent, thus
  54.  
  55.       0)   0 + even parity      0
  56.       1)   1 +  odd parity    128     (assuming lower byte contains 7 bit)
  57.       2)   2 +  odd parity    256
  58.       3)   3 + even parity      3
  59. ...
  60.     128)   0 +  odd parity      0
  61.     129)   1 + even parity      1
  62.     130)   2 + even parity      2
  63. ...
  64.  
  65. and you can just use:  value = table [ byte 0 ] + table [ byte 1 ]
  66.  
  67. regardless of whether they come big-endian or little-endian.
  68.  
  69. Hope this helps.                      Thomas
  70.  
  71. -- 
  72. *** This is the operative statement, all previous statements are inoperative.
  73. *   email: cmaae47 @ ic.ac.uk (Thomas Sippel - Dau) (uk.ac.ic on Janet)
  74. *   voice: +44 71 589 5111 x4937 or 4934 (day), or +44 71 823 9497 (fax)
  75. *   snail: Imperial College of Science, Technology and Medicine
  76. *   The Center for Computing Services, Kensington SW7 2BX, Great Britain
  77.