void MCP4921::sendCommand() { _spi->setBitOrder(SPI_BITORDER_MSBFIRST); _spi->setDataMode(SPI_MODE0); _spi->setClockDivider(SPI_CLOCK_DIV128); beginTransfer(); write((_command >> 8) & 0xff); write((_command >> 0) & 0xff); endTransfer(); }
void DigitalPotMCP4251::write(uint8_t wiper, uint8_t val) { beginTransfer(); DigitalPotMCP4251_Address_t address; if(wiper == 0) { address = DigitalPotMCP4251_Address_Wiper0; } else { address = DigitalPotMCP4251_Address_Wiper1; } writeCommand(address, DigitalPotMCP4251_CommandBits_WriteData, val); endTransfer(); }
void FTPClientSession::logout() { if (!isOpen()) throw FTPException("Connection is closed."); if (_isLoggedIn) { try { endTransfer(); } catch (...) { } _isLoggedIn = false; std::string response; sendCommand("QUIT", response); } }
uint8_t DigitalPotMCP4251::read(uint8_t wiper) { beginTransfer(); DigitalPotMCP4251_Address_t address; if(wiper == 0) { address = DigitalPotMCP4251_Address_Wiper0; } else { address = DigitalPotMCP4251_Address_Wiper1; } uint8_t result = writeCommand(address, DigitalPotMCP4251_CommandBits_ReadData, 0); endTransfer(); return result; }
void FTPClientSession::close() { if (_isOpen) { try { endTransfer(); } catch (...) { } std::string response; sendCommand("QUIT", response); _controlSocket.close(); _isOpen = false; } }
void chatRoom::sendFileSlot() { if(userNr == 2) { QFileDialog explore; fileLocation = explore.getOpenFileName(this); if(fileLocation != NULL) { file.setFileName(fileLocation); file.open(QIODevice::ReadOnly); int n = fileLocation.length(); int i = n - 1; while(fileLocation[i] != '/') { --i; } ++i; fileName = fileLocation.mid(i); //qDebug() << fileName << " " << file.size(); progBar = new Progress(); connect(progBar, SIGNAL(endTransfer()), this, SLOT()); csize = 0; progBar->setMaxValue(file.size()); progBar->setBarValue(0); progBar->setLabel("Waiting for accept..."); progBar->show(); isLast = 0; sendingData = true; /*if(!isActive) { Message m(5, mainUser->getUserId(), this->roomID, 1, "wake up"); m.send(socket); isActive = true; }*/ Message m(9, mainUser->getUserId(), roomID, 0, fileName, file.size(), ""); m.send(socket); } } else { QMessageBox::StandardButton resBtn = QMessageBox::question( this, "ChatClient", "Too many users in this chatroom!", QMessageBox::Ok | QMessageBox::Cancel); } }
void chatRoom::AcceptFileTransfer(Message *message) { QMap<int, User*>::iterator it; it = global->find(message->getFrom()); User *user = it.value(); QMessageBox::StandardButton resBtn = QMessageBox::question( this, "ChatClient", user->getUsername() + " sent you a file: " + message->getFileName(), QMessageBox::Ok | QMessageBox::Cancel); if (resBtn == QMessageBox::Ok) { fileName = message->getFileName(); fileLocation = mainUser->getFilePath() + "/" + message->getFileName(); qDebug() << "File location:" << fileLocation; fileSize = message->getFileSize(); file.setFileName(fileLocation); file.open(QIODevice::Append); Message m(10, mainUser->getUserId(), roomID, 0, message->getFileName(), fileSize, ""); m.send(socket); progBar = new Progress(); connect(progBar, SIGNAL(endTransfer()), this, SLOT()); progBar->setMaxValue(fileSize); progBar->setBarValue(0); progBar->setLabel("Transfering..."); progBar->show(); csize = 0; isLast = 0; receivingData = true; } else { fileLocation = message->getFileName(); fileSize = message->getFileSize(); Message m(11, mainUser->getUserId(), roomID, 0, fileName, fileSize, ""); m.send(socket); receivingData = false; } }
void FTPClientSession::endList() { endTransfer(); }
void FTPClientSession::endUpload() { endTransfer(); }