亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? spcomm.pas

?? 串口調試用程序
?? PAS
?? 第 1 頁 / 共 4 頁
字號:

     FStopBits := Bits;

     if hCommFile <> 0 then
        _SetCommState
end;

procedure TComm.SetXonChar( c : AnsiChar );
begin
     if c = FXonChar then
        Exit;

     FXonChar := c;

     if hCommFile <> 0 then
        _SetCommState
end;

procedure TComm.SetXoffChar( c : AnsiChar );
begin
     if c = FXoffChar then
        Exit;

     FXoffChar := c;

     if hCommFile <> 0 then
        _SetCommState
end;

procedure TComm.SetReplacedChar( c : AnsiChar );
begin
     if c = FReplacedChar then
        Exit;

     FReplacedChar := c;

     if hCommFile <> 0 then
        _SetCommState
end;

procedure TComm.SetReadIntervalTimeout( v : DWORD );
begin
     if v = FReadIntervalTimeout then
        Exit;

     FReadIntervalTimeout := v;

     if hCommFile <> 0 then
        _SetCommTimeout
end;

procedure TComm.SetReadTotalTimeoutMultiplier( v : DWORD );
begin
     if v = FReadTotalTimeoutMultiplier then
        Exit;

     FReadTotalTimeoutMultiplier := v;

     if hCommFile <> 0 then
        _SetCommTimeout
end;

procedure TComm.SetReadTotalTimeoutConstant( v : DWORD );
begin
     if v = FReadTotalTimeoutConstant then
        Exit;

     FReadTotalTimeoutConstant := v;

     if hCommFile <> 0 then
        _SetCommTimeout
end;

procedure TComm.SetWriteTotalTimeoutMultiplier( v : DWORD );
begin
     if v = FWriteTotalTimeoutMultiplier then
        Exit;

     FWriteTotalTimeoutMultiplier := v;

     if hCommFile <> 0 then
        _SetCommTimeout
end;

procedure TComm.SetWriteTotalTimeoutConstant( v : DWORD );
begin
     if v = FWriteTotalTimeoutConstant then
        Exit;

     FWriteTotalTimeoutConstant := v;

     if hCommFile <> 0 then
        _SetCommTimeout
end;

(******************************************************************************)
//  READ THREAD
(******************************************************************************)

//
//  PROCEDURE: TReadThread.Execute
//
//  PURPOSE: This is the starting point for the Read Thread.
//
//  PARAMETERS:
//    None.
//
//  RETURN VALUE:
//    None.
//
//  COMMENTS:
//
//    The Read Thread uses overlapped ReadFile and sends any data
//    read from the comm port to the Comm32Window.  This is
//    eventually done through a PostMessage so that the Read Thread
//    is never away from the comm port very long.  This also provides
//    natural desynchronization between the Read thread and the UI.
//
//    If the CloseEvent object is signaled, the Read Thread exits.
//
//        Separating the Read and Write threads is natural for a application
//    where there is no need for synchronization between
//    reading and writing.  However, if there is such a need (for example,
//    most file transfer algorithms synchronize the reading and writing),
//    then it would make a lot more sense to have a single thread to handle
//    both reading and writing.
//
//
procedure TReadThread.Execute;
var
   szInputBuffer: array[0..INPUTBUFFERSIZE-1] of Char;
   nNumberOfBytesRead:    DWORD;

   HandlesToWaitFor:      array[0..2] of THandle;
   dwHandleSignaled:      DWORD;

   fdwEvtMask:                    DWORD;

   // Needed for overlapped I/O (ReadFile)
   overlappedRead:                TOverlapped;

   // Needed for overlapped Comm Event handling.
   overlappedCommEvent:   TOverlapped;
label
     EndReadThread;
begin
     FillChar( overlappedRead, Sizeof(overlappedRead), 0 );
     FillChar( overlappedCommEvent, Sizeof(overlappedCommEvent), 0 );

     // Lets put an event in the Read overlapped structure.
     overlappedRead.hEvent := CreateEvent( nil, True, True, nil);
     if overlappedRead.hEvent = 0 then
     begin
          PostHangupCall;
          goto EndReadThread
     end;

     // And an event for the CommEvent overlapped structure.
     overlappedCommEvent.hEvent := CreateEvent( nil, True, True, nil);
     if overlappedCommEvent.hEvent = 0 then
     begin
          PostHangupCall();
          goto EndReadThread
     end;

     // We will be waiting on these objects.
     HandlesToWaitFor[0] := hCloseEvent;
     HandlesToWaitFor[1] := overlappedCommEvent.hEvent;
     HandlesToWaitFor[2] := overlappedRead.hEvent;

     // Setup CommEvent handling.

     // Set the comm mask so we receive error signals.
     if not SetCommMask(hCommFile, EV_ERR or EV_RLSD or EV_RING ) then
     begin
          PostHangupCall;
          goto EndReadThread
     end;

     // Start waiting for CommEvents (Errors)
     if not SetupCommEvent( @overlappedCommEvent,  fdwEvtMask ) then
        goto EndReadThread;

     // Start waiting for Read events.
     if not SetupReadEvent( @overlappedRead,
                            szInputBuffer, INPUTBUFFERSIZE,
                            nNumberOfBytesRead ) then
        goto EndReadThread;

     // Keep looping until we break out.
     while True do
     begin
          // Wait until some event occurs (data to read; error; stopping).
          dwHandleSignaled := WaitForMultipleObjects(3, @HandlesToWaitFor,
                              False, INFINITE);

          // Which event occured?
          case dwHandleSignaled of
               WAIT_OBJECT_0:     // Signal to end the thread.
               begin
                    // Time to exit.
                    goto EndReadThread
               end;

               WAIT_OBJECT_0 + 1: // CommEvent signaled.
               begin
                    // Handle the CommEvent.
                    if not HandleCommEvent( @overlappedCommEvent, fdwEvtMask, TRUE ) then
                       goto EndReadThread;

                    // Start waiting for the next CommEvent.
                    if not SetupCommEvent( @overlappedCommEvent, fdwEvtMask ) then
                       goto EndReadThread
                    {break;??}
               end;

               WAIT_OBJECT_0 + 2: // Read Event signaled.
               begin
                    // Get the new data!
                    if not HandleReadEvent( @overlappedRead,
                                            szInputBuffer,
                                            INPUTBUFFERSIZE,
                                            nNumberOfBytesRead ) then
                       goto EndReadThread;

                    // Wait for more new data.
                    if not SetupReadEvent( @overlappedRead,
                                           szInputBuffer, INPUTBUFFERSIZE,
                                           nNumberOfBytesRead ) then
                       goto EndReadThread
                    {break;}
               end;

               WAIT_FAILED:       // Wait failed.  Shouldn't happen.
               begin
                    PostHangupCall;
                    goto EndReadThread
               end
               else    // This case should never occur.
               begin
                    PostHangupCall;
                    goto EndReadThread
               end
          end {case dwHandleSignaled}
     end; {while True}

        // Time to clean up Read Thread.
 EndReadThread:

     PurgeComm( hCommFile, PURGE_RXABORT + PURGE_RXCLEAR );
     CloseHandle( overlappedRead.hEvent );
     CloseHandle( overlappedCommEvent.hEvent )
end; {TReadThread.Execute}

//
//  FUNCTION: SetupReadEvent(LPOVERLAPPED, LPSTR, DWORD, LPDWORD)
//
//  PURPOSE: Sets up an overlapped ReadFile
//
//  PARAMETERS:
//    lpOverlappedRead      - address of overlapped structure to use.
//    lpszInputBuffer       - Buffer to place incoming bytes.
//    dwSizeofBuffer        - size of lpszInputBuffer.
//    lpnNumberOfBytesRead  - address of DWORD to place the number of read bytes.
//
//  RETURN VALUE:
//    TRUE if able to successfully setup the ReadFile.  FALSE if there
//    was a failure setting up or if the CloseEvent object was signaled.
//
//  COMMENTS:
//
//    This function is a helper function for the Read Thread.  This
//    function sets up the overlapped ReadFile so that it can later
//    be waited on (or more appropriatly, so the event in the overlapped
//    structure can be waited upon).  If there is data waiting, it is
//    handled and the next ReadFile is initiated.
//    Another possible reason for returning FALSE is if the comm port
//    is closed by the service provider.
//
//
//
function TReadThread.SetupReadEvent( lpOverlappedRead: POverlapped;
         lpszInputBuffer: LPSTR; dwSizeofBuffer: DWORD;
         var lpnNumberOfBytesRead: DWORD ): Boolean;
var
   dwLastError: DWORD;
label
     StartSetupReadEvent;
begin
     Result := False;

StartSetupReadEvent:

     // Make sure the CloseEvent hasn't been signaled yet.
     // Check is needed because this function is potentially recursive.
     if WAIT_TIMEOUT <> WaitForSingleObject(hCloseEvent,0) then
        Exit;

     // Start the overlapped ReadFile.
     if ReadFile( hCommFile,
                  lpszInputBuffer^, dwSizeofBuffer,
                  lpnNumberOfBytesRead, lpOverlappedRead ) then
     begin
          // This would only happen if there was data waiting to be read.

          // Handle the data.
          if not HandleReadData( lpszInputBuffer, lpnNumberOfBytesRead ) then
             Exit;

          // Start waiting for more data.
          goto StartSetupReadEvent
     end;

     // ReadFile failed.  Expected because of overlapped I/O.
     dwLastError := GetLastError;

     // LastError was ERROR_IO_PENDING, as expected.
     if dwLastError = ERROR_IO_PENDING then
     begin
          Result := True;
          Exit
     end;

     // Its possible for this error to occur if the
     // service provider has closed the port.  Time to end.
     if dwLastError = ERROR_INVALID_HANDLE then
        Exit;

     // Unexpected error come here. No idea what could cause this to happen.
     PostHangupCall
end; {TReadThread.SetupReadEvent}

//
//  FUNCTION: HandleReadData(LPCSTR, DWORD)
//
//  PURPOSE: Deals with data after its been read from the comm file.
//
//  PARAMETERS:
//    lpszInputBuffer  - Buffer to place incoming bytes.
//    dwSizeofBuffer   - size of lpszInputBuffer.
//
//  RETURN VALUE:
//    TRUE if able to successfully handle the data.
//    FALSE if unable to allocate memory or handle the data.
//
//  COMMENTS:
//
//    This function is yet another helper function for the Read Thread.
//    It LocalAlloc()s a buffer, copies the new data to this buffer and
//    calls PostWriteToDisplayCtl to let the EditCtls module deal with
//    the data.  Its assumed that PostWriteToDisplayCtl posts the message
//    rather than dealing with it right away so that the Read Thread
//    is free to get right back to waiting for data.  Its also assumed
//    that the EditCtls module is responsible for LocalFree()ing the
//    pointer that is passed on.
//
//
function TReadThread.HandleReadData( lpszInputBuffer: LPCSTR; dwSizeofBuffer: DWORD ): Boolean;
var
   lpszPostedBytes: LPSTR;
begin
     Result := False;

     // If we got data and didn't just time out empty...
     if dwSizeofBuffer <> 0 then
     begin
          // Do something with the bytes read.

          lpszPostedBytes := PChar( LocalAlloc( LPTR, dwSizeofBuffer+1 ) );

          if lpszPostedBytes = nil{NULL} then
          begin
               // Out of memory
               
               PostHangupCall;
               Exit
          end;

          Move( lpszInputBuffer^, lpszPostedBytes^, dwSizeofBuffer );
          lpszPostedBytes[dwSizeofBuffer] := #0;

          Result := ReceiveData( lpszPostedBytes, dwSizeofBuffer )
     end
end; {TReadThread.HandleReadData}

//
//  FUNCTION: HandleReadEvent(LPOVERLAPPED, LPSTR, DWORD, LPDWORD)
//
//  PURPOSE: Retrieves and handles data when there is data ready.
//
//  PARAMETERS:
//    lpOverlappedRead      - address of overlapped structure to use.
//    lpszInputBuffer       - Buffer to place incoming bytes.
//    dwSizeofBuffer        - size of lpszInputBuffer.
//    lpnNumberOfBytesRead  - address of DWORD to place the number of read bytes.
//
//  RETURN VALUE:
//    TRUE if able to successfully retrieve and handle the available data.
//    FALSE if unable to retrieve or handle the data.
//
//  COMMENTS:
//
//    This function is another helper function for the Read Thread.  This
//    is the function that is called when there is data available after
//    an overlapped ReadFile has been setup.  It retrieves the data and
//    handles it.
//
//
function TReadThread.HandleReadEvent( lpOverlappedRead: POverlapped;
         lpszInputBuffer: LPSTR; dwSizeofBuffer: DWORD;
         var lpnNumberOfBytesRead: DWORD ): Boolean;
var
   dwLastError: DWORD;
begin
     Result := False;
     
     if GetOverlappedResult( hCommFile,
                             lpOverlappedRead^, lpnNumberOfBytesRead, False ) then
     begin
          Result := HandleReadData( lpszInputBuffer, lpnNumberOfBytesRead );
          Exit
     end;

     // Error in GetOverlappedResult; handle it.

     dwLastError := GetLastError;

     // Its possible for this error to occur if the
     // service provider has closed the port.  Time to end.
     if dwLastError = ERROR_INVALID_HANDLE then
        Exit;

     // Unexpected error come here. No idea what could cause this to happen.
     PostHangupCall
end; {TReadThread.HandleReadEvent}

//
//  FUNCTION: SetupCommEvent(LPOVERLAPPED, LPDWORD)
//
//  PURPOSE: Sets up the overlapped WaitCommEvent call.
//
//  PARAMETERS:
//    lpOverlappedCommEvent - Pointer to the overlapped structure to use.
//    lpfdwEvtMask          - Pointer to DWORD to received Event data.
//
//  RETURN VALUE:
//    TRUE if able to successfully setup the WaitCommEvent.
//    FALSE if unable to setup WaitCommEvent, unable to handle
//    an existing outstanding event or if the CloseEvent has been signaled.
//
//  COMMENTS:
//
//    This function is a helper function for the Read Thread that sets up
//    the WaitCommEvent so we can deal with comm events (like Comm errors)
//    if they occur.
//
//
function TReadThread.SetupCommEvent( lpOverlappedCommEvent: POverlapped;
         var lpfdwEvtMask: DWORD ): Boolean;
var
   dwLastError: DWORD;
label
     StartSetupCommEvent;
begin
     Result := False;
     
StartSetupCommEvent:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区免费在线| 日本aⅴ亚洲精品中文乱码| 久久婷婷久久一区二区三区| 欧美蜜桃一区二区三区| 色综合天天综合网天天看片| caoporm超碰国产精品| 国产精品亚洲专一区二区三区| 久久精品国产第一区二区三区 | 国产精品自拍一区| 国内成人免费视频| 国产美女精品在线| 国产91清纯白嫩初高中在线观看 | 色综合久久六月婷婷中文字幕| 91影院在线免费观看| 色综合天天做天天爱| 欧洲一区在线观看| 777奇米四色成人影色区| 欧美一区二区三区免费视频| 欧美大片顶级少妇| 亚洲国产精品精华液ab| 自拍偷自拍亚洲精品播放| 亚洲美女视频在线| 亚洲午夜日本在线观看| 午夜精品成人在线| 精彩视频一区二区| 国产69精品一区二区亚洲孕妇| 91色九色蝌蚪| 欧美狂野另类xxxxoooo| 久久久不卡网国产精品一区| 国产精品久久影院| 亚洲国产精品人人做人人爽| 蜜桃视频免费观看一区| 国产精品91一区二区| 色婷婷综合五月| 日韩写真欧美这视频| 国产女主播一区| 亚洲一级二级在线| 久久99精品国产91久久来源| 成人理论电影网| 欧美日韩电影在线播放| 久久久久久免费毛片精品| 亚洲免费资源在线播放| 久久国产麻豆精品| 91在线视频播放地址| 日韩美女视频在线| 亚洲欧洲色图综合| 丝袜诱惑制服诱惑色一区在线观看 | 欧美一区二区三区四区在线观看 | 亚洲成人av一区二区三区| 久久99精品国产麻豆不卡| 99久久99久久精品免费观看| 欧美影片第一页| 国产日韩三级在线| 亚洲18影院在线观看| 从欧美一区二区三区| 6080午夜不卡| 亚洲精品大片www| 国产一区啦啦啦在线观看| 91福利社在线观看| 欧美va在线播放| 一区二区在线观看免费| 国产一区二区三区最好精华液| 在线一区二区三区| 久久久久久电影| 日韩国产欧美在线播放| 91在线云播放| 国产欧美日韩在线| 欧美成va人片在线观看| 亚洲三级理论片| 国内外成人在线| 欧美一区二区精品久久911| 亚洲美女区一区| 丁香另类激情小说| 成人伦理片在线| 精品国产青草久久久久福利| 亚洲第一精品在线| 色婷婷久久久综合中文字幕| 欧美极品aⅴ影院| 极品少妇xxxx偷拍精品少妇| 精品视频一区二区三区免费| 亚洲三级在线免费| 成人一区在线看| 久久精品视频在线看| 久久se这里有精品| 欧美巨大另类极品videosbest | 一个色在线综合| 成人美女在线视频| 久久久久久综合| 精品一二三四在线| 欧美成人激情免费网| 日韩av电影天堂| 狠狠网亚洲精品| 日韩欧美的一区二区| 日韩高清在线观看| 6080yy午夜一二三区久久| 亚洲v精品v日韩v欧美v专区| 色婷婷综合五月| 一区二区三区四区在线播放| 一本久久综合亚洲鲁鲁五月天| 国产精品欧美经典| av日韩在线网站| 国产精品久久久久久久浪潮网站| 成人午夜碰碰视频| 国产精品久久久一本精品| www.亚洲精品| 亚洲精品欧美激情| 奇米影视7777精品一区二区| 欧美肥妇毛茸茸| 蜜桃视频一区二区| 精品福利一区二区三区免费视频| 国产麻豆一精品一av一免费| 欧美韩国日本不卡| 91浏览器入口在线观看| 亚洲欧美综合在线精品| 91久久一区二区| 日韩专区在线视频| 欧美va在线播放| 国产成人精品免费一区二区| 国产精品久久久久影院| 91麻豆自制传媒国产之光| 一区二区三区蜜桃网| 国产综合色视频| 国产日韩欧美一区二区三区乱码 | 国产精品久久久久桃色tv| 99久久久免费精品国产一区二区| 亚洲欧美在线高清| 在线观看日韩国产| 亚洲成人一二三| 精品欧美乱码久久久久久1区2区| 国产美女主播视频一区| 国产精品不卡在线| 欧美日韩一区二区三区四区| 久久国产夜色精品鲁鲁99| 国产精品亲子乱子伦xxxx裸| 色婷婷av一区二区三区gif| 久久综合狠狠综合久久综合88| 国产成人啪免费观看软件 | 国产一区二区三区不卡在线观看| 国产日韩在线不卡| 欧美四级电影在线观看| 久久精品国产一区二区三| 国产精品理论片在线观看| 欧美日韩免费不卡视频一区二区三区| 蜜桃一区二区三区在线| 国产精品久久久久一区| 666欧美在线视频| 懂色av中文一区二区三区| 亚洲美女淫视频| 欧美大白屁股肥臀xxxxxx| 亚洲成av人片一区二区三区| www成人在线观看| 欧美中文字幕一区二区三区| 国产一区二区三区免费播放 | 91在线精品一区二区| 日韩精品一二区| 欧美国产日本视频| 91精品国产欧美一区二区成人 | 欧美私人免费视频| 国产v日产∨综合v精品视频| 亚洲国产美女搞黄色| 色94色欧美sute亚洲线路二| 久久se这里有精品| 亚洲已满18点击进入久久| 久久久国产综合精品女国产盗摄| 欧美日韩一区精品| av网站免费线看精品| 韩国v欧美v日本v亚洲v| 亚洲福利视频三区| 国产三级欧美三级日产三级99| 欧美三级资源在线| 成人久久视频在线观看| 经典三级视频一区| 天天色天天操综合| 亚洲欧洲成人av每日更新| 久久综合丝袜日本网| 91精品国产色综合久久| 欧美性视频一区二区三区| 亚洲一区二区视频| 成人欧美一区二区三区视频网页| 精品国产一二三区| 欧美日本在线看| 欧美在线观看你懂的| 91丨porny丨国产入口| 国产成人在线免费| 精品一区二区三区免费毛片爱| 亚洲国产综合色| 亚洲精品一二三| 亚洲欧洲日韩女同| 国产精品久久久久久久久图文区| 26uuu国产电影一区二区| 欧美一区二区成人| 欧美日本一道本在线视频| 91视频免费观看| 97久久超碰精品国产| 成人国产精品免费观看动漫| 国产精品66部| 国产成人8x视频一区二区| 国模套图日韩精品一区二区 | 精品国产一区二区三区不卡 | 五月激情综合网|