/home/aperles/dades/asignatures/dsii/Qt/plantilles_serie/plantilla_serie_nova_r01/serie.cpp File Reference

A generic&simple module that handles a serial port. More...

#include "serie.h"
#include <QtDebug>
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Functions

bool serie_openConnection (const char *port_name)
 Opens a serial port.
void serie_closeConnection (void)
 Closes the serial port ... if it is open.
void serie_sendStr (const char *cad)
 Sends strings of text to the device.
void serie_sendData (const char *dat, int len)
 Sends a given number of to the device.
int serie_receiveData (char *destination, int max_data)
 Receives the data that the devices sends to the host.

Detailed Description

A generic&simple module that handles a serial port.

Serial port service is provided through QextSerialPort class library DSII subject.

Author:
Angel Perles
Date:
2011-02-05

Definition in file serie.cpp.


Function Documentation

void serie_closeConnection ( void   ) 

Closes the serial port ... if it is open.

Example:

      serie_closeConnection();
   

Definition at line 87 of file serie.cpp.

bool serie_openConnection ( const char *  port_name  ) 

Opens a serial port.

Parameters:
port_name name of the device that provides access to a given serial port
Return values:
true if port succesfully openned
false if port can not be openned

Example:

      if (serie_openConnection("COM1")) {
            printf("Port openned.");
      } else {
            printf("Error openning the port");
      }
   

Definition at line 41 of file serie.cpp.

int serie_receiveData ( char *  destination,
int  max_data 
)

Receives the data that the devices sends to the host.

This functions is non-blocking, so it returns inmediately and no waits if data is not available

Parameters:
destination pointer where data buyes will be put
max_data maximum number of bytes that can be received, remaing data is keept in device's buffer
Returns:
number of received bytes, or 0 if nothing received

Example:

      unsigned char buffer[10000];
      int num_bytes;

      num_bytes = serie_receiveData(buffer, 10000);
      if (num_bytes > 0) {
            printf("Received %d byes\n", num_bytes);
      }
   

Definition at line 168 of file serie.cpp.

void serie_sendData ( const char *  dat,
int  len 
)

Sends a given number of to the device.

This functions is non-blocking, so it returns inmediately and no waits until data is sent to the device

Parameters:
dat pointer to data
len number of bytes to be sent

Example:

      unsigned char dades[] = {35,49,110,69};

      serie_sendData(dades, 4);
   

Definition at line 136 of file serie.cpp.

void serie_sendStr ( const char *  cad  ) 

Sends strings of text to the device.

This functions is non-blocking, so it returns inmediately and no waits until data is sent to the device

Parameters:
cad pointer to a null-terminated standard C string

Example:

      serie_sendStr("Les coques amb tomaca estan molt bones\x0D");
   

Definition at line 111 of file serie.cpp.

 All Classes Files Functions
Generated on Sat Feb 5 18:13:16 2011 for Plantilla serie by  doxygen 1.6.3