Changes between Version 2 and Version 3 of Docs/Prog/Manual/ApplicationLibraries/lib825ev/Comm/CCommSerial


Ignore:
Timestamp:
04/09/18 14:47:06 (7 years ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/Prog/Manual/ApplicationLibraries/lib825ev/Comm/CCommSerial

    v2 v3  
    55CCommSerial is a C++ class that is provided to simplify 825 serial communications. CCommSerial is inherited from the CComm base class.
    66
    7 === Constructor ===
    8 
    9 === Member Functions ===
    10 
    11 
    12 ==== Description ====
     7== Constructors ==
     8
     9{{{
     10CCommSerial(void)
     11CCommSerial(int port);
     12}}}
     13These constructors just create a CCommSerial object without opening a communications channel.
     14
     15==== Parameters ====
     16 * port - serial port number ( 1 = COM1, 2 = COM2 )
     17
     18==== Examples ====
     19
     20{{{
     21CCommSerial *pSerial = new CCommSerial(2);
     22// Creates a CCommSerial instance that when opened will connect to COM2
     23}}}
     24
     25{{{
     26CCommSerial *pSerial = new CCommSerial();
     27// Creates a CCommSerial instance that does not have a port specified yet. Method SetPort() must be called before calling Open().
     28}}}
     29
     30== Member Functions ==
     31
     32=== SetPort ===
     33Sets the communications port to be used when Open() is called.
     34
     35=== Open ===
     36Opens a specified file, or using the filename already stored in the object.
     37
     38{{{
     39int Open(void);
     40}}}
     41
     42==== Parameters ====
     43 * void - no parameters
     44
     45==== Return Value ====
     46
     47Returns 1 if successful or 0 if unsuccessful.
     48
     49==== Remarks ====
     50
     51==== Example ====
     52
     53{{{
     54}}}
     55
     56=== Close ===
     57Closes the connection
     58{{{
     59int Close(void);
     60}}}
     61
     62==== Parameters ====
     63
     64Function does not accept any parameters
     65
     66==== Return Value ====
     67 
     68Function always returns zero.
     69
     70==== Remarks ====
     71
     72For serial ports it may be necessary to provide some delay to allow all of the buffered data to be sent out of the port before closing the port.
     73
     74==== Example ====
     75
     76=== SetParameters ===
     77Set the baud rate, number of data bits, parity, and number of stop bits for serial ports.
     78{{{
     79bool SetParameters(baud_index baud, data_bit_index = data8, parity_index = parityNone, stop_bit_index = stopOne);
     80}}}
     81
     82==== Parameters ====
     83 * baud_index - baud1200, baud2400, baud4800, baud9600, baud19200, baud38400, baud57600, or baud115200
     84 * data_bit_index - data7 or data8
     85 * parity_index - parityNone, parityEven, or parityOdd
     86 * stop_bit_index - stopOne or stopTwo
     87
     88==== Return Value ====
     89
     90Returns true if successful, false if not successful.
     91
     92==== Remarks ====
     93
     94==== Examples ====
     95
     96{{{
     97CCommSerial* pSerial = new CCommSerial(2);
     98if(pSerial->Open())
     99{
     100   pSerial->SetParameters(CCommSerial::baud9600, CCommSerial::data7, CCommSerial::parityEven, CCommSerial::stopOne);
     101}
     102}}}
     103
     104{{{
     105CCommSerial* pSerial = new CCommSerial(2);
     106if(pSerial->Open())
     107{
     108   pSerial->SetParameters(CCommSerial::baud19200);
     109}
     110}}}
     111
     112=== IsReady ===
     113Check the state of the serial CTS input (for serial ports that are equipped with CTS input)
     114{{{
     115bool IsReady(void);
     116}}}
     117==== Parameters ====
     118
     119Function does not accept any parameters.
     120
     121==== Return Value ====
     122
     123Function returns true if CTS is active, false if CTS is inactive.
     124
     125==== Remarks ====
     126
     127IsReady() will return false if the CTS line is unconnected. Printers or other devices must be wired correctly for applications to be able to use this function to determine their readiness. '''The main board COM3 is not currently supported by this function.'''
     128
     129==== Example ====
     130
     131{{{
     132CCommSerial *pSerial = new CCommSerial(2);
     133if(pSerial->Open())
     134{
     135   pSerial->SetRTS(true);
     136   if(pSerial->IsReady() == false)
     137   {
     138      DisplayText(0, 0, "Device offline, or disconnected");
     139   }
     140}
     141}}}
     142
     143
     144=== SetRTS ===
     145Set the state of the serial RTS output
     146
     147{{{
     148bool SetRTS(bool bRTSOn = true);
     149}}}
     150
     151==== Parameters ====
     152
     153 * bRTSOn - true to turn on RTS output, false to turn off RTS output
     154
     155==== Return Value ====
     156
     157Returns true if successfully set RTS state, false otherwise.
     158
     159==== Remarks ====
     160
     161==== Example ====
     162
     163{{{
     164CCommSerial* pSerial = new CCommSerial(2);
     165if(pSerial->Open())
     166{
     167   pSerial->SetRTS(true);
     168}
     169}}}
     170
     171
    13172
    14173