Advertisement
Guest User

Serial

a guest
Mar 15th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "serialib.h"
  3. #include "iostream"
  4. #include "string"
  5.  
  6.  
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9. std::string port;
  10. std::string address;
  11.  
  12. printf("Heartbeat Address: ");
  13. std::cin >> address;
  14.  
  15. printf("COM Port: ");
  16. std::cin >> port;
  17.  
  18. serialib Serial;
  19.  
  20. if(Serial.Open(port.c_str(), 9600) != 1) {
  21. printf("Serial communication established on COM%s\nSending ICMP heartbeat request to server on %s", port, address);
  22. while(true) {
  23. Serial.WriteChar('1');
  24. Sleep(1000);
  25. }
  26. }else {
  27. printf("Could not establish serial communication with hearbeat box on COM%s, exiting...", port);
  28. Sleep(2000);
  29. exit(EXIT_FAILURE);
  30. }
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement