C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[57682] Re:일정부분 자답... 의문점들 아직도 있음.
아~자~~! [minonnet] 2353 읽음    2009-07-20 19:06
실험의 내용은 다음과 같습니다.
1. Virtual Serial Ports Emulator 프로그램을 이용하여,
2. 가상포트 2번과 5번을 연결시켜서.
3. C++ Builder로 작성된 프로그램(이하 CBP)을 COM2에 연결하고,
3. ComMaster라는 시리얼 프로그램을 COM5에 연결했음.
6. 그래서 서로 주고 받기를 하니. 데이터의 누락없이 정확하게 보내고 받는 것을 확인 했음.

그런데.....
실제 보드(DSP보드)에 연결하고 통신을 시도하면
1. ComMaster 시리얼 프로그램은 모든 데이터를 받고 잘 보냄.
2. 하지만, CBP에서는 데이터를 받지  못하고 있음
    ( --> 아직 보내는 것은 실험하지 않았음.)
3. CBP에서는 데이터의 누락이 있음.
이를 어떻게 해야 하나요?




아~자~~! 님이 쓰신 글 :
: Cport를 사용하여 시리얼 통신(RS232)을 하는데요.
: 일단 TComPort4Beta의 예제파일들로 실행시키고 있습니다.
: 예제파일명은 ComExample입니다.
: 문제점은 다음과 같습니다.
:
: 받는 데이터는 "02 01 C4 C7 03" 입니다.
:
: 1. EventChar가 #0 일때에,
:    Cport->ReadStr()에서 데이터를 1개만 받습니다.
:    받는 데이터의 중간에 NULL은 없습니다.
:
: 2. EventChar가 #3 일때에, (데이터 패킷을 마지막은 0x03)으로 끝납니다.)
:    Cport->ReadStr()에서 데이터를 2개만 받습니다.
:    받는 데이터의 중간에 NULL은 없습니다.
:
: 3. Cport->ReadStr()은 동기식이고,
:     Cport->ReadStrAsync()은 비동기식이니까.
:     따라서 RS232는 비동기식이므로  "Cport->ReadStrAsync()"을 사용해야 되지 않나요?
:
: 4. 다음은 ComMainForm.Cpp파일과 Form의 텍스트 파일입니다.
: //**************************//
: //***  ComMainForm.cpp   ***//
: //**************************//
: //---------------------------------------------------------------------------
: #include <vcl.h>
: #pragma hdrstop
:
: #include "ComMainForm.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __fastcall TForm1::TForm1(TComponent* Owner)
:   : TForm(Owner)
: {
: }
: //---------------------------------------------------------------------------
: void __fastcall TForm1::Button_OpenClick(TObject *Sender)
: {
:   if (ComPort->Connected)
:     ComPort->Close();
:   else
:     ComPort->Open();
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Button_SettingsClick(TObject *Sender)
: {
:   ComPort->ShowSetupDialog();
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Button_SendClick(TObject *Sender)
: {
:   AnsiString Str;
:
:   Str = Edit_Data->Text;
:   if (NewLine_CB->Checked)
:     Str = Str + "\r\n";
:   ComPort->WriteStr(Str);
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::ComPortOpen(TObject *Sender)
: {
:   Button_Open->Caption = "Close";
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::ComPortClose(TObject *Sender)
: {
:   Button_Open->Caption = "Open";
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::ComPortRxChar(TObject *Sender, int Count)
: {
:   AnsiString Str;
:
:   ComPort->ReadStr(Str, Count);
:   Memo->Text = Memo->Text + Str;
: }
: //---------------------------------------------------------------------------
:
:
:
:
:
:
:
: //*************************************//
: //***  다음은 Form의 텍스트 파일입니다  ***//
: //*************************************//
: object Form1: TForm1
:   Left = 191
:   Top = 107
:   Caption = 'ComPort Library example'
:   ClientHeight = 363
:   ClientWidth = 558
:   Color = clBtnFace
:   Font.Charset = DEFAULT_CHARSET
:   Font.Color = clWindowText
:   Font.Height = -11
:   Font.Name = 'MS Sans Serif'
:   Font.Style = []
:   OldCreateOrder = True
:   PixelsPerInch = 96
:   TextHeight = 13
:   object Memo: TMemo
:     Left = 1
:     Top = 1
:     Width = 433
:     Height = 297
:     ImeName = 'Microsoft Office IME 2007'
:     ReadOnly = True
:     ScrollBars = ssBoth
:     TabOrder = 0
:   end
:   object Button_Open: TButton
:     Left = 456
:     Top = 8
:     Width = 75
:     Height = 25
:     Caption = 'Open'
:     TabOrder = 1
:     OnClick = Button_OpenClick
:   end
:   object Button_Settings: TButton
:     Left = 456
:     Top = 40
:     Width = 75
:     Height = 25
:     Caption = 'Settings'
:     TabOrder = 2
:     OnClick = Button_SettingsClick
:   end
:   object Edit_Data: TEdit
:     Left = 440
:     Top = 80
:     Width = 113
:     Height = 21
:     ImeName = 'Microsoft Office IME 2007'
:     TabOrder = 3
:   end
:   object Button_Send: TButton
:     Left = 456
:     Top = 104
:     Width = 75
:     Height = 25
:     Caption = 'Send'
:     Default = True
:     TabOrder = 4
:     OnClick = Button_SendClick
:   end
:   object NewLine_CB: TCheckBox
:     Left = 448
:     Top = 136
:     Width = 89
:     Height = 17
:     Caption = 'Send new line'
:     Checked = True
:     State = cbChecked
:     TabOrder = 5
:   end
:   object Panel1: TPanel
:     Left = 0
:     Top = 304
:     Width = 433
:     Height = 57
:     BevelInner = bvRaised
:     BevelOuter = bvLowered
:     TabOrder = 6
:     object ComLed1: TComLed
:       Left = 112
:       Top = 8
:       Width = 25
:       Height = 25
:       ComPort = ComPort
:       LedSignal = lsCTS
:       Kind = lkPurpleLight
:       RingDuration = 0
:     end
:     object ComLed2: TComLed
:       Left = 144
:       Top = 8
:       Width = 25
:       Height = 25
:       ComPort = ComPort
:       LedSignal = lsDSR
:       Kind = lkPurpleLight
:       RingDuration = 0
:     end
:     object ComLed3: TComLed
:       Left = 176
:       Top = 8
:       Width = 25
:       Height = 25
:       ComPort = ComPort
:       LedSignal = lsRLSD
:       Kind = lkPurpleLight
:       RingDuration = 0
:     end
:     object ComLed4: TComLed
:       Left = 256
:       Top = 8
:       Width = 25
:       Height = 25
:       ComPort = ComPort
:       LedSignal = lsRing
:       Kind = lkYellowLight
:       RingDuration = 0
:     end
:     object Label2: TLabel
:       Left = 112
:       Top = 32
:       Width = 21
:       Height = 13
:       Caption = 'CTS'
:     end
:     object Label3: TLabel
:       Left = 144
:       Top = 32
:       Width = 23
:       Height = 13
:       Caption = 'DSR'
:     end
:     object Label4: TLabel
:       Left = 176
:       Top = 32
:       Width = 29
:       Height = 13
:       Caption = 'RLSD'
:     end
:     object Label5: TLabel
:       Left = 256
:       Top = 32
:       Width = 22
:       Height = 13
:       Caption = 'Ring'
:     end
:     object ComLed5: TComLed
:       Left = 344
:       Top = 8
:       Width = 25
:       Height = 25
:       ComPort = ComPort
:       LedSignal = lsTx
:       Kind = lkRedLight
:       RingDuration = 0
:     end
:     object ComLed6: TComLed
:       Left = 376
:       Top = 8
:       Width = 25
:       Height = 25
:       ComPort = ComPort
:       LedSignal = lsRx
:       Kind = lkRedLight
:       RingDuration = 0
:     end
:     object Label1: TLabel
:       Left = 350
:       Top = 32
:       Width = 12
:       Height = 13
:       Caption = 'Tx'
:     end
:     object Label6: TLabel
:       Left = 382
:       Top = 32
:       Width = 13
:       Height = 13
:       Caption = 'Rx'
:     end
:   end
:   object ComPort: TComPort
:     BaudRate = br9600
:     Port = 'COM1'
:     Parity.Bits = prNone
:     StopBits = sbOneStopBit
:     DataBits = dbEight
:     DiscardNull = True
:     Events = [evRxChar, evTxEmpty, evRxFlag, evRing, evBreak, evCTS, evDSR, evError, evRLSD, evRx80Full]
:     FlowControl.OutCTSFlow = False
:     FlowControl.OutDSRFlow = False
:     FlowControl.ControlDTR = dtrEnable
:     FlowControl.ControlRTS = rtsDisable
:     FlowControl.XonXoffOut = False
:     FlowControl.XonXoffIn = False
:     OnAfterOpen = ComPortOpen
:     OnAfterClose = ComPortClose
:     OnRxChar = ComPortRxChar
:     Left = 384
:     Top = 8
:   end
: end

+ -

관련 글 리스트
57675 [질문] Cport->ReadStr()에서 데이터를 다 받질 못하고 있네요.??? 아~자~~! 3121 2009/07/20
57682     Re:일정부분 자답... 의문점들 아직도 있음. 아~자~~! 2353 2009/07/20
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.