#include <qextserialport.h>#include <QObject>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. | |
Definition in file serie.h.
| void serie_closeConnection | ( | void | ) |
| bool serie_openConnection | ( | const char * | port_name | ) |
Opens a serial port.
| port_name | name of the device that provides access to a given serial port |
| 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");
}
| 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
| 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 |
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);
}
| 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
| dat | pointer to data | |
| len | number of bytes to be sent |
Example:
unsigned char dades[] = {35,49,110,69};
serie_sendData(dades, 4);
| 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
| cad | pointer to a null-terminated standard C string |
Example:
serie_sendStr("Les coques amb tomaca estan molt bones\x0D");
1.6.3