home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / biz / sco / general / 4915 < prev    next >
Encoding:
Text File  |  1992-12-31  |  1.8 KB  |  56 lines

  1. Newsgroups: biz.sco.general
  2. Path: sparky!uunet!world!apl
  3. From: apl@world.std.com (Anthony P Lawrence)
  4. Subject: Re: Capturing data from a RS232 Port
  5. Message-ID: <C057r1.Gyw@world.std.com>
  6. Organization: The World Public Access UNIX, Brookline, MA
  7. X-Newsreader: Tin 1.1 PL3
  8. References: <73@shady.UUCP>
  9. Date: Thu, 31 Dec 1992 21:30:36 GMT
  10. Lines: 44
  11.  
  12. kevin@shady.UUCP (Kevin Smith) writes:
  13. :     while :
  14. :     do
  15. :         read line
  16. :         echo "$line" >>$LOGFILE
  17. :     done
  18. :     # Note: If the input data is non-ascii but fixed length you
  19. :     # could use dd instead of the read/echo combo.  Remember to
  20. :     # set -icanon on the port.
  21. :     #   while :
  22. :     #   do
  23. :     #       dd bs=?? count=1 >>$LOGFILE
  24. :     #   done
  25. :     ) <$TTY
  26.  
  27. I think you've covered most of the problems he could run into here,
  28. except that of validating the data, and the possibility of variant
  29. record lengths (assuming non-line oriented data).
  30.  
  31. If this is more than a casual grabbing (it sounds like it is), I
  32. would think he'd want to validate "on the fly" rather than later.
  33. I guess this could be done with shell tools (probably some perl
  34. hacker would just love to do it!), but I think I'd get pretty
  35. frustrated trying it!
  36.  
  37. Varying record lengths present another problem easily handled in
  38. C (or whatever) but a little tougher in the shell.  Well, maybe
  39. not tougher, but certainly messier.
  40.  
  41. Other advantages would be that a C program could eliminate the
  42. need for cron, or could dump it's log on receipt of a signal (yeah,
  43. I know: you can do that in the shell, too), etc.
  44.  
  45. I'm a fan of doing things with shell tools whenever possible, but
  46. this is a case where I would go with C.
  47.  
  48.  
  49.         Tony   apl@world.std.com
  50.  
  51. Lawrence & Clark, Inc        (617) 762-0707    (206) 323-2864
  52. Xenix/Unix support,etc           Boston         Seattle
  53.        Kevin Clark is embarrassed by most of what I say.
  54.