RS485 Module under WinCE

From LEXWiKi

(Difference between revisions)
Jump to: navigation, search
Line 26: Line 26:
bool SetCom(int rate, BYTE ByteSize, TCHAR parity, TCHAR stopbit, int rtsflag)
bool SetCom(int rate, BYTE ByteSize, TCHAR parity, TCHAR stopbit, int rtsflag)
'''Parameters'''<br />
'''Parameters'''<br />
 +
rate:Specifies the device communication BaudRate.<br />
 +
parity:'E'=EVENPARITY , 'M'=MARKPARITY , 'N'= NOPARITY , 'S'= SPACEPARITY , 'O' = ODDPARITY<br />
 +
stopbit:'1'=ONESTOPBIT , '1.5'=ONE5STOPBITS , '2'=TWOSTOPBITS <br />
 +
rtsflag: 0=no setting(RS232) , 1=default RTS is low , 2=default RTS is high<br />
 +
 +
===Send Message or Recive Message===
 +
bool Send(CString)<br />
 +
bool Recive(CString *)<br />
 +
If successful return true else return false <br />
 +
 +
===Close Com handle===
 +
bool CloseCom()<br />
 +
Closes a COM handle. if function success , return true.<br />
 +
 +
===Close Com handle===
 +
LPCTSTR GetErrMsg()<br />
 +
Get the error message when return value is false from above function <br />

Revision as of 15:15, 18 March 2010


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

Contents

The Sample code source you can download from

   Source file: RS485_Src_CE.rar
   Binary file: RS485_Bin_CE.rar

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