Changeset 6185 in vbox
- Timestamp:
- Dec 26, 2007 7:40:48 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp
r6088 r6185 605 605 if (pThread->enmState != PDMTHREADSTATE_RUNNING) 606 606 break; 607 if (!ReadFile(pData->hDeviceFile, abBuffer, sizeof(abBuffer), &dwNumberOfBytesTransferred, &pData->overlappedRecv)) 608 { 609 LogRel(("HostSerial#%d: Read failed with error %Vrc; terminating the worker thread.\n", pDrvIns->iInstance, RTErrConvertFromWin32(GetLastError()))); 610 break; 611 } 612 cbRemaining = dwNumberOfBytesTransferred; 613 607 608 /* Check the event */ 609 if (dwEventMask & EV_RXCHAR) 610 { 611 if (!ReadFile(pData->hDeviceFile, abBuffer, sizeof(abBuffer), &dwNumberOfBytesTransferred, &pData->overlappedRecv)) 612 { 613 LogRel(("HostSerial#%d: Read failed with error %Vrc; terminating the worker thread.\n", pDrvIns->iInstance, RTErrConvertFromWin32(GetLastError()))); 614 break; 615 } 616 cbRemaining = dwNumberOfBytesTransferred; 617 } 618 else 619 { 620 /* The status lines have changed. Notify the device. */ 621 DWORD dwNewStatusLinesState = 0; 622 uint8_t uNewStatusLinesState = 0; 623 624 /* Get the new state */ 625 if (GetModemStatus(pData->hDeviceFile, &dwNewStatusLinesState)) 626 { 627 if (dwNewStatusLinesState & MS_RLSD_ON) 628 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_DCD; 629 if (dwNewStatusLinesState & MS_RING_ON) 630 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_RI; 631 if (dwNewStatusLinesState & MS_DSR_ON) 632 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_DSR; 633 if (dwNewStatusLinesState & MS_CTS_ON) 634 uNewStatusLinesState |= PDM_ICHAR_STATUS_LINES_CTS; 635 rc = pData->pDrvCharPort->pfnNotifyStatusLinesChanged(pData->pDrvCharPort, uNewStatusLinesState); 636 if (VBOX_FAILURE(rc)) 637 { 638 /* Notifying device failed, continue but log it */ 639 LogRel(("HostSerial#%d: Notifying device failed with error %Vrc; continuing.\n", pDrvIns->iInstance, rc); 640 } 641 } 642 else 643 { 644 /* Getting new state failed, continue but log it */ 645 LogRel(("HostSerial#%d: Getting status lines state failed with error %Vrc; continuing.\n", pDrvIns->iInstance, RTErrConvertFromWin32(GetLastError()))); 646 } 647 } 614 648 #endif 615 649 … … 667 701 } 668 702 703 #if defined(RT_OS_LINUX) 669 704 /* -=-=-=-=- Monitor thread -=-=-=-=- */ 670 705 … … 683 718 PDRVHOSTSERIAL pData = PDMINS2DATA(pDrvIns, PDRVHOSTSERIAL); 684 719 int rc = VINF_SUCCESS; 685 686 #if defined (RT_OS_LINUX)687 720 unsigned uStatusLinesToCheck = 0; 688 721 689 722 uStatusLinesToCheck = TIOCM_CAR | TIOCM_RNG | TIOCM_LE | TIOCM_CTS; 690 #endif691 723 692 724 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING) … … 696 728 { 697 729 uint32_t newStatusLine = 0; 698 699 #if defined(RT_OS_LINUX)700 730 unsigned int statusLines; 701 731 … … 718 748 newStatusLine |= PDM_ICHAR_STATUS_LINES_CTS; 719 749 rc = pData->pDrvCharPort->pfnNotifyStatusLinesChanged(pData->pDrvCharPort, newStatusLine); 720 #endif721 750 } 722 751 … … 735 764 PDRVHOSTSERIAL pData = PDMINS2DATA(pDrvIns, PDRVHOSTSERIAL); 736 765 int rc = VINF_SUCCESS; 737 #if defined(RT_OS_LINUX) 766 738 767 /* 739 768 * Linux is a bit difficult as the thread is sleeping in an ioctl call. … … 758 787 AssertMsgFailed(("%s: Setting device into normal mode failed. Device is not in a working state!!\n", __FUNCTION__)); 759 788 760 #elif defined(RT_OS_WINDOWS)761 /** @todo */762 #else763 # error adapt me!764 #endif765 766 789 return rc; 767 790 } 791 #endif /* RT_OS_LINUX */ 768 792 769 793 /** … … 885 909 pData->hDeviceFile = hFile; 886 910 /* for overlapped read */ 887 if (!SetCommMask(hFile, EV_RXCHAR ))911 if (!SetCommMask(hFile, EV_RXCHAR | EV_CTS | EV_DSR | EV_RING | EV_RLSD)) 888 912 { 889 913 LogRel(("HostSerial#%d: SetCommMask failed with error %d.\n", pDrvIns->iInstance, GetLastError())); … … 971 995 972 996 #if defined(RT_OS_LINUX) 997 /* Linux needs a separate thread which monitors the status lines. */ 973 998 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pData->pMonitorThread, pData, drvHostSerialMonitorThread, drvHostSerialWakeupMonitorThread, 0, RTTHREADTYPE_IO, "Serial Monitor"); 974 999 if (VBOX_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.