1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int Biscuit::biscReceiveByte(unsigned char &byte) {
std::lock_guard<std::recursive_mutex> lock(s_mutex);
usleep(10000);
return (read(deviceDescriptor, &byte, 1) == 1 ? BISC_SUCCESS : BISC_ERR);
}
int Biscuit::biscReceiveByte(signed char &byte) {
std::lock_guard<std::recursive_mutex> lock(s_mutex);
usleep(10000);
return (read(deviceDescriptor, &byte, 1) == 1 ? BISC_SUCCESS : BISC_ERR);
}
int isNthBitSet (unsigned char c, int n) {
static unsigned char mask[] = {1, 2, 4, 8, 16, 32, 64, 128};
// c = 00000010 n= 1 ( rightmost bit is n=0, leftmost is n=7), result is 1
return ((c & mask[n]) != 0);
}
| |