--- branches/linux-serial/serial1.cpp 2007/02/04 20:11:41 43 +++ branches/linux-serial/serial1.cpp 2007/02/04 23:11:02 46 @@ -1,8 +1,13 @@ // serial1.cpp : Defines the entry point for the console application. // +#ifdef _WINDOWS #include "stdafx.h" + #include "serial1.h" +#endif + + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -12,10 +17,10 @@ #include #include #include +#include -#include -void pause() +void my_pause() { char d[1]; std::cout << "Press enter to continue" << std::endl; @@ -27,13 +32,15 @@ { int count = 0; unsigned char c,input; - CH7Serial serial("com8", 9600); + CH7Serial serial; try { + serial.open("/dev/ttyS0", 9600); // tænd lysdiode S3 / RB1 std::cout << "--------------------------------------" << std::endl; serial.writeTarget(0,1); + /* Sleep(2000); // sluk lysdiode S3 / RB1 @@ -66,15 +73,28 @@ //aflæser potmeter igen ved 9600 bps std::cout << "--------------------------------------" << std::endl; std::cout << "Potmeter: " << serial.readTarget(5) << std::endl; - } catch (std::exception e) + */ + } + catch (std::runtime_error& e) + { + std::cout << "Error: " << e.what() << std::endl; + exit(1); + } + catch (std::exception& e) + { + std::cout << "Exception: " << e.what() << std::endl; + exit(2); + } + catch(...) { - std::cout << "Exception :" << e.what() << std::endl; + std::cout << "asd" << std::endl; + exit(3); } //std::cout << serial.readTarget(2) << std::endl; - pause(); + my_pause(); return 0; }