Lines Matching refs:hSession
397 HSession hSession = (HSession)stream->data;
398 unsigned int fd = hSession->dataFd[STREAM_MAIN];
441 RetErrCode HdcUARTBase::DispatchToWorkThread(HSession hSession, uint8_t *readBuf, int readBytes)
443 if (hSession == nullptr) {
446 if (!UartSendToHdcStream(hSession, readBuf, readBytes)) {
452 size_t HdcUARTBase::PackageProcess(vector<uint8_t> &data, HSession hSession)
473 if (hSession == nullptr) {
475 hSession = GetSession(sessionId);
478 hSession = GetSession(sessionId, true);
481 if (hSession == nullptr) {
484 if (hSession->hUART->dispatchedPackageIndex == packageIndex) {
490 hSession->hUART->dispatchedPackageIndex = packageIndex;
491 RetErrCode ret = DispatchToWorkThread(hSession, data.data(), packetSize);
502 ResponseUartTrans(hSession->sessionId, ++hSession->hUART->packageIndex,
525 bool HdcUARTBase::SendUARTRaw(HSession hSession, uint8_t *data, const size_t length)
541 if (hSession == nullptr) {
542 hSession = GetSession(uartHeader->sessionId);
543 if (hSession == nullptr) {
545 WRITE_LOG(LOG_WARN, "%s hSession not found:%zu", __FUNCTION__, uartHeader->sessionId);
549 hSession->ref++;
552 ssize_t sendBytes = WriteUartDev(data, length, *hSession->hUART);
559 OnTransferError(hSession);
561 hSession->ref--;
567 bool HdcUARTBase::UartSendToHdcStream(HSession hSession, uint8_t *data, size_t size)
570 hSession->ToDebugString().c_str(), size);
585 if (head->sessionId != hSession->sessionId) {
586 if (hSession->serverOrDaemon && !hSession->hUART->resetIO) {
589 SendUartSoftReset(hSession, head->sessionId);
590 hSession->hUART->resetIO = true;
596 hSession->hUART->streamSize += head->dataSize; // this is only for debug,
598 hSession->hUART->streamSize.load());
599 if (UartToHdcProtocol(reinterpret_cast<uv_stream_t *>(&hSession->dataPipe[STREAM_MAIN]),
895 int HdcUARTBase::SendUARTData(HSession hSession, uint8_t *data, const size_t length)
898 WRITE_LOG(LOG_DEBUG, "SendUARTData hSession:%u, total length:%d", hSession->sessionId, length);
914 head->sessionId = hSession->sessionId;
915 head->packageIndex = ++hSession->hUART->packageIndex;
948 HSession hSession = (HSession)stream->data;
949 HdcUARTBase *hUARTBase = (HdcUARTBase *)hSession->classModule;
958 hSession->sessionId, nread, buffer,
959 hSession->hUART->streamSize.load());
960 HdcSessionBase *hSessionBase = (HdcSessionBase *)hSession->classInstance;
961 if (nread <= 0 or nread > signed(hSession->hUART->streamSize)) {
965 if (hSessionBase->FetchIOBuf(hSession, hSession->ioBuf, nread) < 0) {
969 hUARTBase->ResponseUartTrans(hSession->sessionId, ++hSession->hUART->packageIndex,
973 hSessionBase->FreeSession(hSession->sessionId);
975 hSession->hUART->streamSize -= nread;
976 WRITE_LOG(LOG_DEBUG, "%s sessionId:%u, nread:%d", __FUNCTION__, hSession->sessionId, nread);
979 bool HdcUARTBase::ReadyForWorkThread(HSession hSession)
981 if (externInterface.UvTcpInit(&hSession->childLoop, &hSession->dataPipe[STREAM_WORK],
982 hSession->dataFd[STREAM_WORK])) {
986 hSession->dataPipe[STREAM_WORK].data = hSession;
987 HdcSessionBase *pSession = (HdcSessionBase *)hSession->classInstance;
988 externInterface.SetTcpOptions(&hSession->dataPipe[STREAM_WORK]);
989 if (externInterface.UvRead((uv_stream_t *)&hSession->dataPipe[STREAM_WORK],
1007 void HdcUARTBase::StopSession(HSession hSession)
1009 if (hSession != nullptr) {
1010 WRITE_LOG(LOG_WARN, "%s:%s", __FUNCTION__, hSession->ToDebugString().c_str());
1011 ClearUARTOutMap(hSession->sessionId);