RS485 Module under WinCE

From LEXWiKi

Jump to: navigation, search


Note:this source code and binary only suppor RS485 test on VIA series motherboard

Contents

The Sample code source you can download from

<Google Drive>

Source file: RS485_CE_Src

Binary file: RS485_CE_Bin


<FTP>

Source file: RS485_CE_Src

Binary file: RS485_CE_Bin

How to use this Demo Application

Image:RS485.jpg

1.Selcet RS485 com port and Rts Signal Control ,Click Open.
2. Put some message in editbox and then press send button
3.Click Recive button and than the message will display in editbox.
4.click AutoFlow if you want to test flowcontrol.

Sample code Introduction

Create Com Port

   bool CreatCom(CString Com_Str,DWORD Send_buf,DWORD Rec_buf,int flow_control)

Parameters
Com_Str: The name of COM port to be created
Send_buf:Setting Send buffer
Rec_buf: Setting Recive buffer
flow_control:flow control flag :1(on) or 0(off)

Setting Com port

   bool SetCom(int rate, BYTE ByteSize, TCHAR parity, TCHAR stopbit, int rtsflag)

Parameters
rate:Specifies the device communication BaudRate.
parity:'E'=EVENPARITY , 'M'=MARKPARITY , 'N'= NOPARITY , 'S'= SPACEPARITY , 'O' = ODDPARITY
stopbit:'1'=ONESTOPBIT , '1.5'=ONE5STOPBITS , '2'=TWOSTOPBITS
rtsflag: 0=no setting(RS232) , 1=default RTS is low , 2=default RTS is high

Send Message or Recive Message

   bool Send(CString)
bool Recive(CString *)

If successful return true else return false

Close Com handle

   bool CloseCom()

Closes a COM handle. if function success , return true.

Close Com handle

   LPCTSTR GetErrMsg()

Get the error message when return value is false from above function

Personal tools