--- trunk/H7 Server/H7Serial.cpp 2007/01/31 17:05:15 32 +++ trunk/H7 Server/H7Serial.cpp 2007/01/31 17:22:59 33 @@ -17,6 +17,7 @@ short CH7Serial::readTarget(unsigned char target) { + serialLock.Lock(); short retval; unsigned char frame[1]; unsigned char hi_target = (target & 0x0F) << 4; @@ -32,8 +33,9 @@ if ( (answer[0] & 0x0F) != 0x02) // tjek for ACK throw std::exception("Request not acknowledged"); - if ( (answer[0] & 0xF0) != hi_target) - throw std::exception("Incorrect reply"); +// if ( (answer[0] & 0xF0) != hi_target) +// throw std::exception("Incorrect reply"); + if (answer.size() == 2) retval = answer[1]; @@ -42,11 +44,13 @@ else retval = -1; + serialLock.Unlock(); return retval; } void CH7Serial::writeTarget(unsigned char target, unsigned char data) { + serialLock.Lock(); unsigned char frame[2]; unsigned char hi_target = (target & 0x0F) << 4; frame[0] = hi_target | 0x01; @@ -64,6 +68,8 @@ if ( (answer[0] & 0xF0) != hi_target) throw std::exception("Incorrect reply"); + + serialLock.Unlock(); }