Wiicom API Lib
 Tutto Strutture dati File Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Definizioni Gruppi
Riferimenti per il file C:/WIICOM-SVN/Sviluppo/Software/library/wiicom_lib/trunk/wiicom_libvcp.h

Wiicom virtual com port library. Continua...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "wiicom_libutil.h"
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>

Vai al codice sorgente di questo file.

Definizioni

Virtual com port Baud rate speeds
#define WIICOM_VCP_BAUDRATE_50   50
 
#define WIICOM_VCP_BAUDRATE_75   75
 
#define WIICOM_VCP_BAUDRATE_110   110
 
#define WIICOM_VCP_BAUDRATE_134   134
 
#define WIICOM_VCP_BAUDRATE_150   150
 
#define WIICOM_VCP_BAUDRATE_200   200
 
#define WIICOM_VCP_BAUDRATE_300   300
 
#define WIICOM_VCP_BAUDRATE_600   600
 
#define WIICOM_VCP_BAUDRATE_1200   1200
 
#define WIICOM_VCP_BAUDRATE_1800   1800
 
#define WIICOM_VCP_BAUDRATE_2400   2400
 
#define WIICOM_VCP_BAUDRATE_4800   4800
 
#define WIICOM_VCP_BAUDRATE_9600   9600
 
#define WIICOM_VCP_BAUDRATE_19200   19200
 
#define WIICOM_VCP_BAUDRATE_38400   38400
 
#define WIICOM_VCP_BAUDRATE_57600   57600
 
#define WIICOM_VCP_BAUDRATE_115200   115200
 
#define WIICOM_VCP_BAUDRATE_128000   128000
 
#define WIICOM_VCP_BAUDRATE_230400   230400
 
#define WIICOM_VCP_BAUDRATE_256000   256000
 
Data bits size
#define WIICOM_VCP_DATA_BITS_SIZE_5   5
 
#define WIICOM_VCP_DATA_BITS_SIZE_6   6
 
#define WIICOM_VCP_DATA_BITS_SIZE_7   7
 
#define WIICOM_VCP_DATA_BITS_SIZE_8   8
 

Ridefinizioni di tipo (typedef)

typedef int t_wiicom_libvcp_handle
 

Parity type

#define WIICOM_VCP_NOPARITY   0
 
#define WIICOM_VCP_EVENPARITY   1
 
#define WIICOM_VCP_ODDPARITY   2
 
void wiicom_libvcp_init ()
 Function that initializes the vitual com port library
Warning! This function should be called before using the virtual com port. Continua...
 
uint8_t wiicom_libvcp_open (t_wiicom_libvcp_handle *fd, char *device, uint32_t vcp_baudrate, uint8_t vcp_parity, uint8_t vcp_stop2bit, uint8_t vcp_data_bits_size)
 Function that open a VCP and returns a VCP handle. Continua...
 
void wiicom_libvcp_close (t_wiicom_libvcp_handle fd)
 Function that close a VCP handle. Continua...
 
long wiicom_libvcp_read (t_wiicom_libvcp_handle fd, uint8_t *buffer, uint32_t buffer_size)
 Function that read data from a VCP handle. Continua...
 
long wiicom_libvcp_write (t_wiicom_libvcp_handle fd, uint8_t *buffer, uint32_t buffer_size)
 Function that write data to a VCP handle. Continua...
 
long wiicom_libvcp_write_string (t_wiicom_libvcp_handle fd, char *string_to_write)
 Function that write a string to a VCP handle. Continua...
 
void wiicom_libvcp_deinit ()
 Function that de-initialize the vitual com port library
Warning! This function is called when not used any more a VCP or, in general, before the close of the program. Continua...
 
int wiicom_libvcp_getcomports (char ports[][15])
 Function that get all system VCP
Warning! This function works only on windows and linux system. Continua...
 

Descrizione dettagliata

Wiicom virtual com port library.

Generic library for managing a virtual com port

Autore
Marco Malano
WIICOM s.r.l
Versione
1.0.0
Data
2012
Attenzione
This library depends on wiicom_libutil
Every function that expects a result, in case of an error, set the Wiicom errno and print to stderr the error occurred.
Nota
None.

Documentazione delle definizioni

#define WIICOM_VCP_BAUDRATE_110   110
#define WIICOM_VCP_BAUDRATE_115200   115200
#define WIICOM_VCP_BAUDRATE_1200   1200
#define WIICOM_VCP_BAUDRATE_128000   128000

Only on Windows system

#define WIICOM_VCP_BAUDRATE_134   134

Only on Unix like system

#define WIICOM_VCP_BAUDRATE_150   150

Only on Unix like system

#define WIICOM_VCP_BAUDRATE_1800   1800

Only on Unix like system

#define WIICOM_VCP_BAUDRATE_19200   19200
#define WIICOM_VCP_BAUDRATE_200   200

Only on Unix like system

#define WIICOM_VCP_BAUDRATE_230400   230400

Only on Unix like system

#define WIICOM_VCP_BAUDRATE_2400   2400
#define WIICOM_VCP_BAUDRATE_256000   256000

Only on Windows system

#define WIICOM_VCP_BAUDRATE_300   300
#define WIICOM_VCP_BAUDRATE_38400   38400
#define WIICOM_VCP_BAUDRATE_4800   4800
#define WIICOM_VCP_BAUDRATE_50   50

Only on Unix like system

#define WIICOM_VCP_BAUDRATE_57600   57600
#define WIICOM_VCP_BAUDRATE_600   600
#define WIICOM_VCP_BAUDRATE_75   75

Only on Unix like system

#define WIICOM_VCP_BAUDRATE_9600   9600
#define WIICOM_VCP_DATA_BITS_SIZE_5   5
#define WIICOM_VCP_DATA_BITS_SIZE_6   6
#define WIICOM_VCP_DATA_BITS_SIZE_7   7
#define WIICOM_VCP_DATA_BITS_SIZE_8   8
#define WIICOM_VCP_EVENPARITY   1

Use even parity check

#define WIICOM_VCP_NOPARITY   0

No parity check

#define WIICOM_VCP_ODDPARITY   2

Use odd parity instead of even check

Documentazione delle ridefinizioni di tipo (typedef)

Documentazione delle funzioni

void wiicom_libvcp_close ( t_wiicom_libvcp_handle  fd)

Function that close a VCP handle.

Parametri
[in]fdVCP handle
Restituisce
void
void wiicom_libvcp_deinit ( )

Function that de-initialize the vitual com port library
Warning! This function is called when not used any more a VCP or, in general, before the close of the program.

Restituisce
void
int wiicom_libvcp_getcomports ( char  ports[][15])

Function that get all system VCP
Warning! This function works only on windows and linux system.

Parametri
[out]portsarray width discoverd ports
Restituisce
number of discoverd ports
void wiicom_libvcp_init ( )

Function that initializes the vitual com port library
Warning! This function should be called before using the virtual com port.

Restituisce
void
uint8_t wiicom_libvcp_open ( t_wiicom_libvcp_handle fd,
char *  device,
uint32_t  vcp_baudrate,
uint8_t  vcp_parity,
uint8_t  vcp_stop2bit,
uint8_t  vcp_data_bits_size 
)

Function that open a VCP and returns a VCP handle.

Parametri
[out]fdVCP handle
[in]devicea virtual serial port device (Ex. /dev/stty0 on Unix like, \\\\.\\COM5 on Windows)
[in]vcp_baudratespecifies a Baud rate speeds
[in]vcp_parityspecifies a parity type
[in]vcp_stop2bitspecifies if there is a 2 bits stop, otherwise there is 1 bit stop
[in]vcp_data_bits_sizeit is a data bits size
Restituisce
On success, TRUE is returned, On error, FALSE is returned
long wiicom_libvcp_read ( t_wiicom_libvcp_handle  fd,
uint8_t *  buffer,
uint32_t  buffer_size 
)

Function that read data from a VCP handle.

Parametri
[in]fdVCP handle
[out]bufferbuffer in which datas are loaded
[in]buffer_sizesize of the buffer containing the data read
Restituisce
On success, number of bytes received. On error, -1 is returned
long wiicom_libvcp_write ( t_wiicom_libvcp_handle  fd,
uint8_t *  buffer,
uint32_t  buffer_size 
)

Function that write data to a VCP handle.

Parametri
[in]fdVCP handle
[in]bufferit contains data to send
[in]buffer_sizesize of the buffer to send
Restituisce
On success, number of bytes transmitted. On error, -1 is returned
long wiicom_libvcp_write_string ( t_wiicom_libvcp_handle  fd,
char *  string_to_write 
)

Function that write a string to a VCP handle.

Parametri
[in]fdVCP handle
[in]string_to_writeit contains a string to send
Restituisce
On success, number of bytes transmitted. On error, -1 is returned