/* * Handle a message that will cause us to start. * * batteriesOnly if true, only start up the battery * related items on the OneWire bus * (useful when just synchronising * remaining battery capacity values), * otherwise setup the PIOs as well. * pSendMsgBody pointer to the relevant message * type to fill in with a response, * which will be overlaid over the * body of the response message. * * @return the length of the message body * to send back. */ static UInt16 actionHardwareServerStart (Bool batteriesOnly, HardwareServerStartCnf *pSendMsgBody) { Bool success; UInt16 sendMsgBodyLength = 0; ASSERT_PARAM (pSendMsgBody != PNULL, (unsigned long) pSendMsgBody); /* First of all, start up the OneWire bus */ success = startOneWireBus(); if (success) { /* Find and setup the devices on the OneWire bus */ success = setupDevices (batteriesOnly); if (!success) { /* If the setup fails, print out what devices we can find */ findAllDevices(); } } pSendMsgBody->success = success; sendMsgBodyLength += sizeof (pSendMsgBody->success); return sendMsgBodyLength; }
void PcapManager::showInterest(const QString& device) { QString error; QStringList devices; if (!_threads.contains(device) && !_skipDeviceValidation) { devices = findAllDevices(error); } if (_skipDeviceValidation || _threads.contains(device) || devices.contains(device)) { bool createNew = true; if (_threads.contains(device)) { // We already have a capture thread for this device. IPcapThread* thread = _threads[device]; if (thread->keepAlive()) { // Thread is still alive and kicking. createNew = false; } else { // Thread is shutting down. Queue it for cleanup and we'll start a new one. release(device); } } if (createNew) { // We need a new capture thread for this device. IPcapThread* thread = createPcapThread(device, _customFilter); _threads.insert(device, thread); thread->begin(); } } else if (!devices.contains(device)) { qWarning("Ingored request to manage unknown device: %s", device.toLatin1().constData()); } }