Testing out the PPD42 Air Quality Sensor, with an MSP430 Launchpad and graphing the data with GNUplot.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.0 KiB

5 years ago
  1. /*-------------------------------------------------------------------------
  2. | rxtx is a native interface to serial ports in java.
  3. | Copyright 1997-2004 by Trent Jarvi taj@www.linux.org.uk
  4. |
  5. | This library is free software; you can redistribute it and/or
  6. | modify it under the terms of the GNU Library General Public
  7. | License as published by the Free Software Foundation; either
  8. | version 2 of the License, or (at your option) any later version.
  9. |
  10. | This library is distributed in the hope that it will be useful,
  11. | but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. | Library General Public License for more details.
  14. |
  15. | You should have received a copy of the GNU Library General Public
  16. | License along with this library; if not, write to the Free
  17. | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. --------------------------------------------------------------------------*/
  19. #include <termios.h>
  20. #include <unistd.h>
  21. #include <stdio.h>
  22. #include <sys/types.h>
  23. #include <sys/stat.h>
  24. #include <fcntl.h>
  25. #include <stdlib.h>
  26. int main(int argc, char *argv[])
  27. {
  28. int i, fd ;
  29. struct termios ttyset;
  30. if (argc < 1 )
  31. {
  32. printf("usage ./testSerial /dev/ttyS0\n");
  33. exit(1);
  34. }
  35. fd = open (argv[1], O_RDWR | O_NOCTTY | O_NONBLOCK );
  36. // wait for minicom/rxtx to start and user to press a key
  37. // You can set up the port in minicom/rxtx now. Dont
  38. // exit minicom until you have hit a key to continue.
  39. fgetc(stdin);
  40. // get the attributes.
  41. tcgetattr( fd, &ttyset );
  42. /* print the attributes */
  43. fprintf(stderr, "c_iflag=%#x\n", ttyset.c_iflag);
  44. fprintf(stderr, "c_lflag=%#x\n", ttyset.c_lflag);
  45. fprintf(stderr, "c_oflag=%#x\n", ttyset.c_oflag);
  46. fprintf(stderr, "c_cflag=%#x\n", ttyset.c_cflag);
  47. fprintf(stderr, "c_cc[]: ");
  48. for(i=0; i<NCCS; i++)
  49. {
  50. fprintf(stderr,"%d=%x ", i, ttyset.c_cc[i]);
  51. }
  52. fprintf(stderr,"\n" );
  53. exit(0);
  54. }