--- branches/linux-serial/H7Serial.cpp 2007/02/04 20:11:41 43 +++ branches/linux-serial/H7Serial.cpp 2007/02/05 10:24:24 56 @@ -1,12 +1,16 @@ -#include "StdAfx.h" -#include ".\h7serial.h" + +#include "stdafx.h" + +#include "H7Serial.h" +#include +#include CH7Serial::CH7Serial(void) : CSlipSerial() { } -CH7Serial::CH7Serial(char* port, int bitrate) +CH7Serial::CH7Serial(char* port, Baudrate bitrate) : CSlipSerial(port, bitrate) { } @@ -17,6 +21,7 @@ short CH7Serial::readTarget(unsigned char target) { + using namespace std; short retval; unsigned char frame[1]; unsigned char hi_target = (target & 0x0F) << 4; @@ -27,13 +32,13 @@ std::vector answer = readFrame(); if (answer.size() == 0) - throw std::exception("No reply"); + throw std::runtime_error("No reply"); if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK - throw std::exception("Request not acknowledged"); + throw std::runtime_error("Request not acknowledged"); if ( (answer[0] & 0xF0) != hi_target) - throw std::exception("Incorrect reply"); + throw std::runtime_error("Incorrect reply"); if (answer.size() == 2) retval = answer[1]; @@ -47,6 +52,7 @@ void CH7Serial::writeTarget(unsigned char target, unsigned char data) { + using namespace std; unsigned char frame[2]; unsigned char hi_target = (target & 0x0F) << 4; frame[0] = hi_target | 0x01; @@ -55,15 +61,15 @@ writeFrame(frame,2); Sleep(50); //be nice and wait a little std::vector answer = readFrame(); - + if (answer.size() == 0) - throw std::exception("No reply"); + throw std::runtime_error("No reply"); if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK - throw std::exception("Request not acknowledged"); + throw std::runtime_error("Request not acknowledged"); if ( (answer[0] & 0xF0) != hi_target) - throw std::exception("Incorrect reply"); + throw std::runtime_error("Incorrect reply"); }