Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. //close port
  2.  
  3. {
  4. if(fdDataPort != -1)
  5. {
  6. MSG_NOTICE("Closing AT[Data] port %d",fdDataPort);
  7. close (fdDataPort);
  8. MSG_NOTICE("Closed AT[Data] port",NULL);
  9. fdDataPort= -1;
  10. }
  11. }
  12.  
  13. {
  14. struct termios tio;
  15. memset(&tio, 0, sizeof(termios));
  16.  
  17. if ((fdDataPort = open("/dev/ttyUSB2", O_RDWR | O_NOCTTY| O_SYNC | O_NONBLOCK )) != -1)
  18. {
  19. cfmakeraw (&tio);
  20.  
  21. tio.c_iflag = 0;//IGNCR;
  22. tio.c_cflag |= CLOCAL | CREAD;
  23. usleep(200000);
  24. tcflush(fdDataPort, TCIOFLUSH);
  25. tcsetattr(fdDataPort, TCSANOW, &tio);
  26. tcflush(fdDataPort, TCIOFLUSH);
  27. tcflush(fdDataPort, TCIOFLUSH);
  28. cfsetospeed(&tio, B115200);
  29. cfsetispeed(&tio, B115200);
  30. tcsetattr(fdDataPort, TCSANOW, &tio);
  31.  
  32. usleep(200000);
  33.  
  34. return true;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement