// finds an address at a given index on the bus // returns true if the device was found bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index) { uint8_t depth = 0; _wire->reset_search(); while (depth <= index && _wire->search(deviceAddress)) { if (depth == index && validAddress(deviceAddress)) return true; depth++; } return false; }
void TestNetworkAddress::testValidDirectConstructorArguments() { quint16 validPort=8128; QHostAddress validAddress("127.0.0.1"); NetworkAddress *naHeap=new NetworkAddress(validAddress, validPort); scrutinize(naHeap, true, expectedValidAddress, expectedValidPort); NetworkAddress naStack(validAddress, validPort); scrutinize(&naStack, true, expectedValidAddress, expectedValidPort); DECEND(naHeap); ASCEND(naHeap); DECEND(&naStack); ASCEND(&naStack); delete naHeap; }
CalculatorDialog::CalculatorDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CalculatorDialog) { ui->setupUi(this); #if QT_VERSION < QT_VERSION_CHECK(5,0,0) setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); #endif setFixedSize(this->size()); //fixed size connect(this, SIGNAL(validAddress(bool)), ui->btnGoto, SLOT(setEnabled(bool))); emit validAddress(false); ui->txtBin->setInputMask(QString("bbbb ").repeated(sizeof(uint_t) * 2)); ui->txtExpression->setText("0"); ui->txtExpression->selectAll(); ui->txtExpression->setFocus(); mValidateThread = new ValidateExpressionThread(this); connect(mValidateThread, SIGNAL(expressionChanged(bool, bool, int_t)), this, SLOT(expressionChanged(bool, bool, int_t))); connect(ui->txtExpression, SIGNAL(textChanged(QString)), mValidateThread, SLOT(textChanged(QString))); }
DgIVec2D& DgBoundedRF2D::decrementAddress (DgIVec2D& add) const { if (!validAddress(add) || add == lowerLeft()) return add = invalidAdd(); if (add.j() == lowerLeft().j()) { add = DgIVec2D(add.i() - 1, upperRight().j()); } else { add.setJ(add.j() - 1); } return add; } // DgIVec2D& DgBoundedRF2D::decrementAddress
DgIVec2D& DgBoundedRF2D::incrementAddress (DgIVec2D& add) const { if (!validAddress(add)) return add = invalidAdd(); else if (add == upperRight() || add == endAdd()) return add = endAdd(); if (add.j() == upperRight().j()) { add = DgIVec2D(add.i() + 1, lowerLeft().j()); } else { add.setJ(add.j() + 1); } return add; } // DgIVec2D& DgBoundedRF2D::incrementAddress
// initialise the bus void DallasTemperature::begin(void){ DeviceAddress deviceAddress; _wire->reset_search(); devices = 0; // Reset the number of devices when we enumerate wire devices while (_wire->search(deviceAddress)){ if (validAddress(deviceAddress)){ if (!parasite && readPowerSupply(deviceAddress)) parasite = true; bitResolution = max(bitResolution, getResolution(deviceAddress)); devices++; } } }
int shouldSynchronize(void *return_addr) { // Returns 1 if we should synchronize this call, instead of calling _real // version. 0 if we should not. if (!dmtcp_is_running_state()) { return 0; } if (SYNC_IS_NOOP) { return 0; } if (isProcessGDB()) { return 0; } if (dmtcp::ThreadInfo::isOkToLogNextFnc()) { dmtcp::ThreadInfo::unsetOkToLogNextFnc(); return 1; } if (!validAddress(return_addr)) { return 0; } return 1; }
extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) { /* Reap Existing Threads */ dmtcp::ThreadInfo::reapThreads(); int retval; /* Here I've split apart WRAPPER_HEADER_RAW because we need to create the * reaper thread even if the current mode is SYNC_IS_NOOP. */ void *return_addr = GET_RETURN_ADDRESS(); if (!dmtcp_is_running_state() || !validAddress(return_addr) || isProcessGDB()) { retval = _real_pthread_create(thread, attr, start_routine, arg); } else if (SYNC_IS_NOOP) { struct create_arg *createArg = (struct create_arg*) JALLOC_HELPER_MALLOC(sizeof(*createArg)); createArg->fn = start_routine; createArg->thread_arg = arg; createArg->userStack = (void*) -1; // Make sure it is non-NULL if (attr != NULL) { createArg->attr = *attr; pthread_attr_getdetachstate(attr, &createArg->userDetachState); } else { createArg->userDetachState = PTHREAD_CREATE_JOINABLE; } dmtcp::ThreadInfo::prePthreadCreate(); retval = _real_pthread_create(thread, attr, start_wrapper, createArg); if (retval != 0) { dmtcp::ThreadInfo::postPthreadCreate(); } } else { retval = internal_pthread_create(thread, attr, start_routine, arg); } if (!pthread_cancel_initialized) { initialize_pthread_cancel(); } return retval; }
// initialize the bus void DallasTemperature::begin(void) { DeviceAddress deviceAddress; _wire->reset_search(); while (_wire->search(deviceAddress)) { if (validAddress(deviceAddress)) { if (!parasite && readPowerSupply(deviceAddress)) parasite = true; ScratchPad scratchPad; readScratchPad(deviceAddress, scratchPad); if (deviceAddress[0] == DS18S20MODEL) conversionDelay = TEMP_12_BIT; // 750 ms else if (scratchPad[CONFIGURATION] > conversionDelay) conversionDelay = scratchPad[CONFIGURATION]; devices++; } } }
int insertAddress(int line, int row, char *address, int menu) { int valid; char temp[500]; gotoxy(line, row); gets(temp); valid = validAddress(temp, 1); if (valid != -1){ valid = inputInfoYesOrNo(menu); if (valid == 0){ strcpy(address, temp); return 0; } else if (valid == -1) return -2; gotoxy(0, 16); lineClear(); gotoxy(0, 17); lineClear(); gotoxy(0, 18); lineClear(); gotoxy(0, 26); lineClear(); gotoxy(0, 28); lineClear(); } return valid; }
/* * Determines if the device is connected. Note that the value returned here is potentially stale immediately on return, * and should only be used for status reporting. In particular, a return value of true does not provide any guarantee * that subsequent operations will succeed. */ bool OneWireSwitch::isConnected() { return validAddress(oneWire, this->address) && accessRead() >= 0; }